use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class FromDataTableTest method listOfDatesAndNamesWithHeader.
private List<DataTableRow> listOfDatesAndNamesWithHeader() {
List<DataTableRow> rows = new ArrayList<DataTableRow>();
rows.add(new DataTableRow(NO_COMMENTS, asList("Birth Date", "Name"), 1));
rows.add(new DataTableRow(NO_COMMENTS, asList("1957-05-10", "Sid Vicious"), 2));
return rows;
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class GosuSnippetTest method generatesSnippetWithDataTable.
@Test
public void generatesSnippetWithDataTable() {
String expected = "" + "Dsl.Given('^I have:$', \\ arg1 : DataTable -> {\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));
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class TableParser method parse.
public static DataTable parse(String source, ParameterInfo parameterInfo) {
final List<DataTableRow> rows = new ArrayList<DataTableRow>();
Lexer l = new En(new Listener() {
@Override
public void comment(String comment, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void tag(String tag, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void feature(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void background(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void scenario(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void scenarioOutline(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void examples(String keyword, String name, String description, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void step(String keyword, String name, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void row(List<String> cells, Integer line) {
rows.add(new DataTableRow(NO_COMMENTS, cells, line));
}
@Override
public void docString(String contentType, String string, Integer line) {
throw new UnsupportedOperationException();
}
@Override
public void eof() {
}
});
l.scan(source);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return new DataTable(rows, new TableConverter(new LocalizedXStreams(classLoader).get(Locale.US), parameterInfo));
}
use of gherkin.formatter.model.DataTableRow in project cucumber-jvm by cucumber.
the class JavaSnippetTest method generatesSnippetWithDataTable.
@Test
public void generatesSnippetWithDataTable() {
String expected = "" + "@Given(\"^I have:$\")\n" + "public void i_have(DataTable arg1) throws Throwable {\n" + " // Write code here that turns the phrase above into concrete actions\n" + " // For automatic transformation, change DataTable to one of\n" + " // List<YourType>, List<List<E>>, List<Map<K,V>> or Map<K,V>.\n" + " // E,K,V must be a scalar (String, Integer, Date, enum etc)\n" + " throw new PendingException();\n" + "}\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 DataTableTest method createTable.
private DataTable createTable(List<String>... rows) {
List<DataTableRow> simpleRows = new ArrayList<DataTableRow>();
for (int i = 0; i < rows.length; i++) {
simpleRows.add(new DataTableRow(new ArrayList<Comment>(), rows[i], i + 1));
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
LocalizedXStreams.LocalizedXStream xStream = new LocalizedXStreams(classLoader).get(Locale.US);
return new DataTable(simpleRows, new TableConverter(xStream, null));
}
Aggregations