Search in sources :

Example 6 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class TableConverterTest method converts_table_of_single_column_to_nullable_enums.

@Test
public void converts_table_of_single_column_to_nullable_enums() {
    DataTable table = TableParser.parse("|RED|\n||\n", null);
    assertEquals(asList(Color.RED, null), table.asList(Color.class));
}
Also used : DataTable(cucumber.api.DataTable) Test(org.junit.Test)

Example 7 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class TableConverterTest method converts_table_of_single_column_to_list_of_without_string_constructor.

@Test
public void converts_table_of_single_column_to_list_of_without_string_constructor() {
    DataTable table = TableParser.parse("|count|\n|5|\n|6|\n|7|\n", null);
    List<WithoutStringConstructor> expected = asList(new WithoutStringConstructor().val("5"), new WithoutStringConstructor().val("6"), new WithoutStringConstructor().val("7"));
    assertEquals(expected, table.asList(WithoutStringConstructor.class));
}
Also used : DataTable(cucumber.api.DataTable) Test(org.junit.Test)

Example 8 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class TableDifferTest method diff_with_list_of_pojos_and_camelcase_header_mapping.

@Test
public void diff_with_list_of_pojos_and_camelcase_header_mapping() {
    String source = "" + "| id | Given Name |\n" + "| 1  | me   |\n" + "| 2  | you  |\n" + "| 3  | jdoe |\n";
    DataTable expected = TableParser.parse(source, null);
    List<TestPojo> actual = new ArrayList<TestPojo>();
    actual.add(new TestPojo(1, "me", 123));
    actual.add(new TestPojo(2, "you", 222));
    actual.add(new TestPojo(3, "jdoe", 34545));
    expected.diff(actual);
}
Also used : DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class TableDifferTest method should_return_tables.

@Test(expected = TableDiffException.class)
public void should_return_tables() {
    DataTable from = table();
    DataTable to = otherTableWithTwoConsecutiveRowsInserted();
    try {
        from.diff(to);
    } catch (TableDiffException e) {
        String expected = "" + "      | Aslak | aslak@email.com      | 123 |\n" + "      | Joe   | joe@email.com        | 234 |\n" + "    + | Doe   | joe@email.com        | 234 |\n" + "    + | Foo   | schnickens@email.net | 789 |\n" + "      | Bryan | bryan@email.org      | 456 |\n" + "      | Ni    | ni@email.com         | 654 |\n";
        assertSame(from, e.getFrom());
        assertSame(to, e.getTo());
        assertEquals(expected, e.getDiff().toString());
        throw e;
    }
}
Also used : DataTable(cucumber.api.DataTable) Test(org.junit.Test)

Example 10 with DataTable

use of cucumber.api.DataTable in project cucumber-jvm by cucumber.

the class TableDifferTest method should_not_fail_with_out_of_memory.

@Test(expected = TableDiffException.class)
public void should_not_fail_with_out_of_memory() {
    DataTable expected = TableParser.parse("" + "| I'm going to work |\n", null);
    List<List<String>> actual = new ArrayList<List<String>>();
    actual.add(asList("I just woke up"));
    actual.add(asList("I'm going to work"));
    expected.diff(actual);
}
Also used : DataTable(cucumber.api.DataTable) ArrayList(java.util.ArrayList) List(java.util.List) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

DataTable (cucumber.api.DataTable)34 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)10 List (java.util.List)7 DataTableRow (gherkin.formatter.model.DataTableRow)4 Arrays.asList (java.util.Arrays.asList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)3 LocalizedXStreams (cucumber.runtime.xstream.LocalizedXStreams)2 Type (java.lang.reflect.Type)2 And (cucumber.api.java.en.And)1 SingleValueConverter (cucumber.deps.com.thoughtworks.xstream.converters.SingleValueConverter)1 Delta (cucumber.deps.difflib.Delta)1 CucumberException (cucumber.runtime.CucumberException)1 Utils.listItemType (cucumber.runtime.Utils.listItemType)1 Utils.mapKeyType (cucumber.runtime.Utils.mapKeyType)1 Utils.mapValueType (cucumber.runtime.Utils.mapValueType)1 TableConverter (cucumber.runtime.table.TableConverter)1 En (gherkin.lexer.En)1 Lexer (gherkin.lexer.Lexer)1