Search in sources :

Example 26 with DataTableRow

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;
}
Also used : ArrayList(java.util.ArrayList) DataTableRow(gherkin.formatter.model.DataTableRow)

Example 27 with DataTableRow

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));
}
Also used : DocString(gherkin.formatter.model.DocString) DataTableRow(gherkin.formatter.model.DataTableRow) Test(org.junit.Test)

Example 28 with DataTableRow

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));
}
Also used : DataTable(cucumber.api.DataTable) Listener(gherkin.lexer.Listener) ArrayList(java.util.ArrayList) En(gherkin.lexer.En) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) Lexer(gherkin.lexer.Lexer) DataTableRow(gherkin.formatter.model.DataTableRow)

Example 29 with DataTableRow

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));
}
Also used : DocString(gherkin.formatter.model.DocString) DataTableRow(gherkin.formatter.model.DataTableRow) Test(org.junit.Test)

Example 30 with DataTableRow

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));
}
Also used : DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) LocalizedXStreams(cucumber.runtime.xstream.LocalizedXStreams) DataTableRow(gherkin.formatter.model.DataTableRow)

Aggregations

DataTableRow (gherkin.formatter.model.DataTableRow)46 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)9 List (java.util.List)6 And (cucumber.api.java.en.And)5 DataTable (cucumber.api.DataTable)4 DocString (gherkin.formatter.model.DocString)4 Step (gherkin.formatter.model.Step)4 Given (cucumber.api.java.en.Given)3 Then (cucumber.api.java.en.Then)3 LocalizedXStreams (cucumber.runtime.xstream.LocalizedXStreams)3 ExamplesTableRow (gherkin.formatter.model.ExamplesTableRow)3 Argument (gherkin.formatter.Argument)2 Arrays.asList (java.util.Arrays.asList)2 Map (java.util.Map)2 Pair (org.activityinfo.model.util.Pair)2 Usage (alien4cloud.model.common.Usage)1 Delta (cucumber.deps.difflib.Delta)1 I18n (gherkin.I18n)1 Row (gherkin.formatter.model.Row)1