gherkin.ast.TableCell Java Examples

The following examples show how to use gherkin.ast.TableCell. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 6 votes vote down vote up
private String[][] getTable(List<TableRow> rows) {
    String data[][] = null;
    int rowSize = rows.size();
    for (int i = 0; i < rowSize; i++) {
        TableRow row = rows.get(i);
        List<TableCell> cells = row.getCells();
        int cellSize = cells.size();
        if (data == null) {
            data = new String[rowSize][cellSize];
        }
        for (int j = 0; j < cellSize; j++) {
            data[i][j] = cells.get(j).getValue();
        }
    }
    return data;
}
 
Example #2
Source File: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private List<Parameter> getExamplesAsParameters(final ScenarioOutline scenarioOutline) {
    final int gap = 2;
    final Optional<Examples> examplesBlock = scenarioOutline.getExamples().stream()
            .filter(e -> currentTestCase.getLine() >= e.getLocation().getLine() + gap)
            .filter(e -> currentTestCase.getLine() < e.getLocation().getLine() + e.getTableBody().size() + gap)
            .findFirst();

    if (examplesBlock.isPresent()) {
        final Examples examples = examplesBlock.get();
        final int rowIndex = currentTestCase.getLine() - examples.getLocation().getLine() - gap;
        final List<TableCell> names = examples.getTableHeader().getCells();
        final List<TableCell> values = examples.getTableBody().get(rowIndex).getCells();
        return IntStream.range(0, examplesBlock.get().getTableHeader().getCells().size()).mapToObj(index -> {
            final String name = names.get(index).getValue();
            final String value = values.get(index).getValue();
            return new Parameter().setName(name).setValue(value);
        }).collect(Collectors.toList());
    }
    return Collections.emptyList();
}
 
Example #3
Source File: BddParser.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private void createTestData(TestCase testCase, List<Examples> examples) {
    for (Examples example : examples) {
        TestDataModel tdModel = createTestData(testCase.getName());
        List<String> columns = new ArrayList<>();
        for (TableCell tCell : example.getTableHeader().getCells()) {
            columns.add(tCell.getValue());
            tdModel.addColumn(tCell.getValue());
        }
        for (int i = 0; i < example.getTableBody().size(); i++) {
            TableRow tRow = example.getTableBody().get(i);
            tdModel.addRecord();
            Record record = tdModel.getRecords().get(i);
            record.setScenario(testCase.getScenario().getName());
            record.setTestcase(testCase.getName());
            record.setIteration("1");
            record.setSubIteration("" + (i + 1));
            for (int j = 0; j < tRow.getCells().size(); j++) {
                tdModel.setValueAt(tRow.getCells().get(j).getValue(),
                        i,
                        tdModel.getColumnIndex(columns.get(j)));
            }
        }
    }
}