本文整理汇总了Java中gherkin.formatter.model.DataTableRow类的典型用法代码示例。如果您正苦于以下问题:Java DataTableRow类的具体用法?Java DataTableRow怎么用?Java DataTableRow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataTableRow类属于gherkin.formatter.model包,在下文中一共展示了DataTableRow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exists
import gherkin.formatter.model.DataTableRow; //导入依赖的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: convertDataTableToStringArray
import gherkin.formatter.model.DataTableRow; //导入依赖的package包/类
/**
* @param dataTable datatable from a step
* @return the converted datatable for transmission to the server.
*/
public StringArrayArray convertDataTableToStringArray(
final List<DataTableRow> dataTable) {
StringArrayArray tableToSend = new StringArrayArray();
if (dataTable != null && dataTable.size() > 0) {
StringArray row;
for (DataTableRow tableRow : dataTable) {
row = new StringArray();
row.getItem().addAll(tableRow.getCells());
tableToSend.getItem().add(row);
}
}
return tableToSend;
}
示例3: executeHTTPRequest
import gherkin.formatter.model.DataTableRow; //导入依赖的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));
}
}
示例4: exists
import gherkin.formatter.model.DataTableRow; //导入依赖的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();
}
}
}
示例5: createDataTableAttachment
import gherkin.formatter.model.DataTableRow; //导入依赖的package包/类
private void createDataTableAttachment(final List<DataTableRow> dataTableRows) {
final StringBuilder dataTableCsv = new StringBuilder();
if (dataTableRows != null && !dataTableRows.isEmpty()) {
dataTableRows.forEach(dataTableRow -> {
dataTableCsv.append(dataTableRow.getCells().stream().collect(Collectors.joining("\t")));
dataTableCsv.append('\n');
});
final String attachmentSource = lifecycle
.prepareAttachment("Data table", "text/tab-separated-values", "csv");
lifecycle.writeAttachment(attachmentSource,
new ByteArrayInputStream(dataTableCsv.toString().getBytes(Charset.forName("UTF-8"))));
}
}
示例6: msgSentToSlackApi
import gherkin.formatter.model.DataTableRow; //导入依赖的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));
}
}
}
示例7: stepHtml
import gherkin.formatter.model.DataTableRow; //导入依赖的package包/类
private void stepHtml(ReportStep reportStep, Node parent) {
Step step = reportStep.getStep();
Result result = reportStep.getResult();
String extraClass = "";
if ("failed".equals(result.getStatus())) {
extraClass = " failed";
} else if ("skipped".equals(result.getStatus())) {
extraClass = " skipped";
}
Node stepRow = div("step-row",
div("step-cell" + extraClass, step.getKeyword() + step.getName()),
div("time-cell" + extraClass, getDuration(result)));
parent.appendChild(stepRow);
if (step.getRows() != null) {
Node table = node("table", null);
parent.appendChild(table);
for (DataTableRow row : step.getRows()) {
Node tr = node("tr", null);
table.appendChild(tr);
for (String cell : row.getCells()) {
tr.appendChild(node("td", null, cell));
}
}
}
if (reportStep.getCalled() != null) { // this is a 'call'
for (ReportStep rs : reportStep.getCalled()) {
Node calledStepsDiv = div("scenario-steps-nested");
parent.appendChild(calledStepsDiv);
stepHtml(rs, calledStepsDiv);
}
} else if (step.getDocString() != null) { // only for non-call, else un-synced stack traces may creep in
DocString docString = step.getDocString();
parent.appendChild(node("div", "preformatted", docString.getValue()));
}
appendLog(parent, reportStep.getLog());
}
示例8: insert
import gherkin.formatter.model.DataTableRow; //导入依赖的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: convertDataTable2StringArrayArray
import gherkin.formatter.model.DataTableRow; //导入依赖的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;
}
示例10: setExpectedDataTable
import gherkin.formatter.model.DataTableRow; //导入依赖的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()]));
}
}
示例11: createDataTableAttachment
import gherkin.formatter.model.DataTableRow; //导入依赖的package包/类
private void createDataTableAttachment(final List<DataTableRow> dataTableRows) {
if (dataTableRows != null && !dataTableRows.isEmpty()) {
final StringBuilder dataTableCsv = new StringBuilder();
for (DataTableRow row : dataTableRows) {
dataTableCsv.append(StringUtils.join(row.getCells().toArray(), "\t"));
dataTableCsv.append('\n');
}
ALLURE_LIFECYCLE.fire(new MakeAttachmentEvent(dataTableCsv.toString().getBytes(),
"Data table", "text/tab-separated-values"));
}
}
示例12: insert
import gherkin.formatter.model.DataTableRow; //导入依赖的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));
}
示例13: matchWithExpresion
import gherkin.formatter.model.DataTableRow; //导入依赖的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);
}
}
示例14: createStepDataTable
import gherkin.formatter.model.DataTableRow; //导入依赖的package包/类
private PdfPTable createStepDataTable(List<DataTableRow> tableRows) {
PdfPTable table = createEmptyStepDataTable(tableRows);
for (int j = 0; j < tableRows.size(); j++) {
boolean firstRow = (j == 0);
Row row = tableRows.get(j);
List<String> cells = row.getCells();
Font font = getTableFont(firstRow);
for (int i = 0; i < cells.size(); i++) {
boolean firstColumn = (i == 0);
String content = cells.get(i);
PdfPCell c = new PdfPCell(new Phrase(content, font));
if (firstRow) {
// c.setPaddingBottom(5);
c.setHorizontalAlignment(Element.ALIGN_CENTER);
BaseColor backgroundColor = configuration.stepDataTableHeaderBackground();
if (backgroundColor != null) {
c.setBackgroundColor(backgroundColor);
}
}
int border = 0;
if (!firstColumn) {
border += Rectangle.LEFT;
}
c.setBorder(border);
table.addCell(c);
}
}
return table;
}
示例15: createEmptyStepDataTable
import gherkin.formatter.model.DataTableRow; //导入依赖的package包/类
private PdfPTable createEmptyStepDataTable(List<DataTableRow> tableRows) {
PdfPTable table = new PdfPTable(getTableColumnCount(tableRows));
table.setTableEvent(new AlternatingBackgroundEvent(configuration.stepDataTableRowAlternateBackground()));
try {
int[] columnMaxSizes = getTableColumnsContentMaxLength(tableRows);
table.setWidths(columnMaxSizes);
} catch (DocumentException e) {
// Should not append since columnMaxSizes comes from tableRows.
}
return table;
}