use of gherkin.formatter.model.DataTableRow in project allure-cucumberjvm by allure-framework.
the class AllureReporter method createDataTableAttachment.
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"));
}
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class TableDiffer method calculateUnorderedDiffs.
public void calculateUnorderedDiffs() throws TableDiffException {
boolean isDifferent = false;
List<DataTableRow> diffTableRows = new ArrayList<DataTableRow>();
List<List<String>> missingRow = new ArrayList<List<String>>();
ArrayList<List<String>> extraRows = new ArrayList<List<String>>();
// 1. add all "to" row in extra table
// 2. iterate over "from", when a common row occurs, remove it from extraRows
// finally, only extra rows are kept and in same order that in "to".
extraRows.addAll(to.raw());
int i = 1;
for (DataTableRow r : from.getGherkinRows()) {
if (!to.raw().contains(r.getCells())) {
missingRow.add(r.getCells());
diffTableRows.add(new DataTableRow(r.getComments(), r.getCells(), i, Row.DiffType.DELETE));
isDifferent = true;
} else {
diffTableRows.add(new DataTableRow(r.getComments(), r.getCells(), i++));
extraRows.remove(r.getCells());
}
}
for (List<String> e : extraRows) {
diffTableRows.add(new DataTableRow(Collections.EMPTY_LIST, e, i++, Row.DiffType.INSERT));
isDifferent = true;
}
if (isDifferent) {
throw new TableDiffException(from, to, new DataTable(diffTableRows, from.getTableConverter()));
}
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class CucumberScenarioOutline method rowsWithTokensReplaced.
private static List<DataTableRow> rowsWithTokensReplaced(List<DataTableRow> rows, List<String> headerCells, List<String> exampleCells, Set<Integer> matchedColumns) {
if (rows != null) {
List<DataTableRow> newRows = new ArrayList<DataTableRow>(rows.size());
for (Row row : rows) {
List<String> newCells = new ArrayList<String>(row.getCells().size());
for (String cell : row.getCells()) {
newCells.add(replaceTokens(matchedColumns, headerCells, exampleCells, cell));
}
newRows.add(new DataTableRow(row.getComments(), newCells, row.getLine()));
}
return newRows;
} else {
return null;
}
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class JythonSnippetTest method generatesSnippetWithDataTable.
@Test
public void generatesSnippetWithDataTable() {
String expected = "" + "@Given('^I have:$')\n" + "def i_have(self, arg1):\n" + " # Write code here that turns the phrase above into concrete actions\n" + " # The last argument is a List of List of String\n" + " raise(PendingException())\n" + "";
List<DataTableRow> dataTable = asList(new DataTableRow(NO_COMMENTS, asList("col1"), 1));
assertEquals(expected, snippetForDataTable("I have:", dataTable));
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class FromDataTableTest method listOfDatesWithHeader.
private List<DataTableRow> listOfDatesWithHeader() {
List<DataTableRow> rows = new ArrayList<DataTableRow>();
rows.add(new DataTableRow(NO_COMMENTS, asList("Birth Date"), 1));
rows.add(new DataTableRow(NO_COMMENTS, asList("1957-05-10"), 2));
return rows;
}
Aggregations