当前位置: 首页>>代码示例>>Java>>正文


Java DataTable.getGherkinRows方法代码示例

本文整理汇总了Java中cucumber.api.DataTable.getGherkinRows方法的典型用法代码示例。如果您正苦于以下问题:Java DataTable.getGherkinRows方法的具体用法?Java DataTable.getGherkinRows怎么用?Java DataTable.getGherkinRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cucumber.api.DataTable的用法示例。


在下文中一共展示了DataTable.getGherkinRows方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exists

import cucumber.api.DataTable; //导入方法依赖的package包/类
void exists(final String tableName, final DataTable data) throws SQLException,
        ClassNotFoundException {
    final List<DataTableRow> rows = data.getGherkinRows();
    final List<String> columns = rows.get(0).getCells();
    final StringBuilder queryBuilder = new StringBuilder();
    queryBuilder.append(String.format("SELECT %s FROM %s WHERE ", StringUtils.join(columns, ","),
                                      tableName));
    queryBuilder.append(StringUtils.join(columns, " = ? AND "));
    queryBuilder.append(" = ?;");
    try (Connection conn = getConnection()) {
        PreparedStatement stmt = conn.prepareStatement(queryBuilder.toString());
        for (DataTableRow row : rows.subList(1, rows.size())) {
            List<String> rowValues = row.getCells();
            for (int i = 0; i < columns.size(); i++) {
                stmt.setString(i + 1, rowValues.get(i));
            }
            final ResultSet rs = stmt.executeQuery();
            assertThat(rs.next()).isTrue();
        }
    }
}
 
开发者ID:tomitribe,项目名称:beryllium,代码行数:22,代码来源:DatabaseSteps.java

示例2: executeHTTPRequest

import cucumber.api.DataTable; //导入方法依赖的package包/类
/**
 * Expected a table of two column, first is the paramName, second is the paramValue
 *
 * @param table
 */
@Given("^a user request Novie in \"(.*)\" with following parameters:$")
public void executeHTTPRequest(String format, DataTable table) {
    if (format != null && !format.toUpperCase().equals("JSON")
            && !format.toUpperCase().equals("XML")
            && !format.toUpperCase().equals("CSV")) {
        Assert.fail("Only json,xml & csv are supported.");
    }
    if (format == null) {
        _log.info("Format not specified use JSON as default.");
        format = "json";
    }
    context.setResponseType(NovieIntegrationContext.RequestedResponseType.valueOf(format.toUpperCase()));
    if (table != null) {
        List<DataTableRow> rows = table.getGherkinRows();
        //Remove the column headers.
        List<DataTableRow> parameters = new ArrayList<DataTableRow>();
        for (int i = 1; i < rows.size(); i++) {
            parameters.add(rows.get(i));
        }
        context.setHttpResponse(URLConnector.httpCall(novieLocalUrl + applicationEndPoint + (format == null ? "" : ("." + format)), null, parameters));
    } else {
        context.setHttpResponse(URLConnector.httpCall(novieLocalUrl + applicationEndPoint, null, null));
    }
}
 
开发者ID:groupon,项目名称:Novie,代码行数:30,代码来源:NovieRequestDeclarative.java

示例3: exists

import cucumber.api.DataTable; //导入方法依赖的package包/类
void exists(final String tableName, final DataTable data) throws SQLException,
    ClassNotFoundException {
  final List<DataTableRow> rows = data.getGherkinRows();
  final List<String> columns = rows.get(0).getCells();
  final StringBuilder queryBuilder = new StringBuilder();
  queryBuilder.append(String.format("SELECT %s FROM %s WHERE ", StringUtils.join(columns, ","),
      tableName));
  queryBuilder.append(StringUtils.join(columns, " = ? AND "));
  queryBuilder.append(" = ?;");
  try (Connection conn = getConnection()) {
    PreparedStatement stmt = conn.prepareStatement(queryBuilder.toString());
    for (DataTableRow row : rows.subList(1, rows.size())) {
      List<String> rowValues = row.getCells();
      for (int i = 0; i < columns.size(); i++) {
        stmt.setString(i + 1, rowValues.get(i));
      }
      final ResultSet rs = stmt.executeQuery();
      assertThat(rs.next()).isTrue();
    }
  }
}
 
开发者ID:cchacin,项目名称:cucumber-common-steps,代码行数:22,代码来源:DatabaseSteps.java

示例4: msgSentToSlackApi

import cucumber.api.DataTable; //导入方法依赖的package包/类
@Given("^a (?:message|positive message|negative message|neutral message) is sent to a slack channel$")
public void msgSentToSlackApi(DataTable dataTable) throws Throwable {

	for (DataTableRow row : dataTable.getGherkinRows()) {
		List<String> cells = row.getCells();

		if ("message".equals(cells.get(0))) {
			continue;
		}
		for (int i = 0; i < cells.size(); i++) {
			slackList = slackApiHelper.slackMessagePost(cells.get(i));
		}

	}
}
 
开发者ID:ClearPointNZ,项目名称:connect-sample-apps,代码行数:16,代码来源:MyStepdefs.java

示例5: insert

import cucumber.api.DataTable; //导入方法依赖的package包/类
void insert(final String tableName, final DataTable data) {
    final List<DataTableRow> rows = data.getGherkinRows();
    final List<String> columns = rows.get(0).getCells();

    final List<Operation> operations = new ArrayList<>();

    for (DataTableRow row : rows.subList(1, rows.size())) {
        final Insert.Builder builder = Insert.into(tableName);
        builder.columns(columns.toArray(new String[columns.size()]));
        builder.values(row.getCells().toArray(new String[row.getCells().size()]));
        operations.add(builder.build());
    }

    this.apply(sequenceOf(operations));
}
 
开发者ID:tomitribe,项目名称:beryllium,代码行数:16,代码来源:DatabaseSteps.java

示例6: convertDataTable2StringArrayArray

import cucumber.api.DataTable; //导入方法依赖的package包/类
private StringArrayArray convertDataTable2StringArrayArray(DataTable table) {
  StringArrayArray datatable = new StringArrayArray();

  for (DataTableRow row : table.getGherkinRows()) {
    StringArray rowElement = new StringArray();
    rowElement.getItem().addAll(row.getCells());
    datatable.getItem().add(rowElement);
  }
  
  return datatable;
}
 
开发者ID:shell88,项目名称:bdd_videoannotator,代码行数:12,代码来源:ReportingTest.java

示例7: setExpectedDataTable

import cucumber.api.DataTable; //导入方法依赖的package包/类
/**
 * @param dataTable DataTable element From a CucumberJVM-Feature-File.
 */
public void setExpectedDataTable(DataTable dataTable) {
  for (DataTableRow tableRow : dataTable.getGherkinRows()) {
    this.addDataTableRow(tableRow.getCells().toArray(
        new String[tableRow.getCells().size()]));
  }

}
 
开发者ID:shell88,项目名称:bdd_videoannotator,代码行数:11,代码来源:ExpectedResultStep.java

示例8: insert

import cucumber.api.DataTable; //导入方法依赖的package包/类
void insert(final String tableName, final DataTable data) {
  final List<DataTableRow> rows = data.getGherkinRows();
  final List<String> columns = rows.get(0).getCells();

  final List<Operation> operations = new ArrayList<>();

  for (DataTableRow row : rows.subList(1, rows.size())) {
    final Insert.Builder builder = Insert.into(tableName);
    builder.columns(columns.toArray(new String[columns.size()]));
    builder.values(row.getCells().toArray(new String[row.getCells().size()]));
    operations.add(builder.build());
  }

  this.apply(sequenceOf(operations));
}
 
开发者ID:cchacin,项目名称:cucumber-common-steps,代码行数:16,代码来源:DatabaseSteps.java

示例9: matchWithExpresion

import cucumber.api.DataTable; //导入方法依赖的package包/类
/**
 * Check if expression defined by JSOPath (http://goessner.net/articles/JsonPath/index.html)
 * match in JSON stored in a environment variable.
 *
 * @param envVar environment variable where JSON is stored
 * @param table  data table in which each row stores one expression
 */
@Then("^'(.+?)' matches the following cases:$")
public void matchWithExpresion(String envVar, DataTable table) throws Exception {
    String jsonString = ThreadProperty.get(envVar);

    for (DataTableRow row : table.getGherkinRows()) {
        String expression = row.getCells().get(0);
        String condition = row.getCells().get(1);
        String result = row.getCells().get(2);

        String value = commonspec.getJSONPathString(jsonString, expression, null);
        commonspec.evaluateJSONElementOperation(value, condition, result);
    }
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:21,代码来源:ThenGSpec.java


注:本文中的cucumber.api.DataTable.getGherkinRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。