use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class TableDiffer method createTableDiff.
private DataTable createTableDiff(Map<Integer, Delta> deltasByLine) {
List<DataTableRow> diffTableRows = new ArrayList<DataTableRow>();
List<List<String>> rows = from.raw();
for (int i = 0; i < rows.size(); i++) {
Delta delta = deltasByLine.get(i);
if (delta == null) {
diffTableRows.add(from.getGherkinRows().get(i));
} else {
addRowsToTableDiff(diffTableRows, delta);
// skipping lines involved in a delta
if (delta.getType() == Delta.TYPE.CHANGE || delta.getType() == Delta.TYPE.DELETE) {
i += delta.getOriginal().getLines().size() - 1;
} else {
diffTableRows.add(from.getGherkinRows().get(i));
}
}
}
// Can have new lines at end
Delta remainingDelta = deltasByLine.get(rows.size());
if (remainingDelta != null) {
addRowsToTableDiff(diffTableRows, remainingDelta);
}
return new DataTable(diffTableRows, from.getTableConverter());
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class ClojureSnippetTest method generatesSnippetWithDataTable.
@Test
public void generatesSnippetWithDataTable() throws Exception {
List<DataTableRow> dataTable = asList(new DataTableRow(NO_COMMENTS, asList("col1"), 1));
Step step = new Step(NO_COMMENTS, "Given ", "I have:", 0, dataTable, null);
String snippet = (newBackend()).getSnippet(step, null);
String expected = "" + "(Given #\"^I have:$\" [arg1]\n" + " (comment Write code here that turns the phrase above into concrete actions )\n" + " (throw (cucumber.api.PendingException.)))\n";
assertEquals(expected, snippet);
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class StepDefinitionMatch method createArgumentsForErrorMessage.
private List<Argument> createArgumentsForErrorMessage(Step step) {
List<Argument> arguments = new ArrayList<Argument>(getArguments());
if (step.getDocString() != null) {
arguments.add(new Argument(-1, "DocString:" + step.getDocString().getValue()));
}
if (step.getRows() != null) {
List<List<String>> rows = map(step.getRows(), new Mapper<DataTableRow, List<String>>() {
@Override
public List<String> map(DataTableRow row) {
return row.getCells();
}
});
arguments.add(new Argument(-1, "Table:" + rows.toString()));
}
return arguments;
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class CucumberScenarioOutlineTest method replaces_tokens_in_data_tables.
@Test
public void replaces_tokens_in_data_tables() {
List<DataTableRow> rows = asList(new DataTableRow(C, asList("I", "have <n> cukes"), 1));
Step outlineStep = new Step(C, null, "I have <n> cukes", 0, rows, null);
Step exampleStep = CucumberScenarioOutline.createExampleStep(outlineStep, new ExamplesTableRow(C, asList("n"), 1, ""), new ExamplesTableRow(C, asList("10"), 1, ""));
assertEquals(asList("I", "have 10 cukes"), exampleStep.getRows().get(0).getCells());
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class GroovySnippetTest method generatesSnippetWithDataTable.
@Test
public void generatesSnippetWithDataTable() {
String expected = "" + "Given(~/^I have:$/) { DataTable arg1 ->\n" + " // Write code here that turns the phrase above into concrete actions\n" + " throw new PendingException()\n" + "}\n";
List<DataTableRow> dataTable = asList(new DataTableRow(NO_COMMENTS, asList("col1"), 1));
assertEquals(expected, snippetForDataTable("I have:", dataTable));
}
Aggregations