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


Java DataTableRow类代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:tomitribe,项目名称:beryllium,代码行数:22,代码来源:DatabaseSteps.java

示例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;
}
 
开发者ID:shell88,项目名称:bdd_videoannotator,代码行数:20,代码来源:CucumberReportingAdapter.java

示例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));
    }
}
 
开发者ID:groupon,项目名称:Novie,代码行数:30,代码来源:NovieRequestDeclarative.java

示例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();
    }
  }
}
 
开发者ID:cchacin,项目名称:cucumber-common-steps,代码行数:22,代码来源:DatabaseSteps.java

示例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"))));
    }
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:16,代码来源:AllureCucumberJvm.java

示例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));
		}

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

示例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());
}
 
开发者ID:intuit,项目名称:karate,代码行数:37,代码来源:KarateHtmlReporter.java

示例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));
}
 
开发者ID:tomitribe,项目名称:beryllium,代码行数:16,代码来源:DatabaseSteps.java

示例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;
}
 
开发者ID:shell88,项目名称:bdd_videoannotator,代码行数:12,代码来源:ReportingTest.java

示例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()]));
  }

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

示例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"));
    }
}
 
开发者ID:allure-framework,项目名称:allure-cucumberjvm,代码行数:12,代码来源:AllureReporter.java

示例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));
}
 
开发者ID:cchacin,项目名称:cucumber-common-steps,代码行数:16,代码来源:DatabaseSteps.java

示例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);
    }
}
 
开发者ID:Stratio,项目名称:bdt,代码行数:21,代码来源:ThenGSpec.java

示例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;
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:36,代码来源:PdfEmitter.java

示例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;
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:12,代码来源:PdfEmitter.java


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