本文整理汇总了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();
}
}
}
示例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));
}
}
示例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();
}
}
}
示例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));
}
}
}
示例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));
}
示例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;
}
示例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()]));
}
}
示例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));
}
示例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);
}
}