Search in sources :

Example 21 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_integers.

@Test
public void converts_table_of_single_column_to_list_of_integers() {
    DataTable table = TableParser.parse("|3|\n|5|\n|6|\n|7|\n", null);
    assertEquals(asList(3, 5, 6, 7), table.asList(Integer.class));
}
Also used : DataTable(cucumber.api.DataTable) Test(org.junit.Test)

Example 22 with DataTable

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

the class TableConverterTest method converts_distinct_tostring_objects_correctly.

@Test
public void converts_distinct_tostring_objects_correctly() {
    DataTable table = TableParser.parse("|first|second|\n|row1.first|row1.second|\n|row2.first|row2.second|\n", null);
    List<ContainsTwoFromStringableFields> converted = table.asList(ContainsTwoFromStringableFields.class);
    List<ContainsTwoFromStringableFields> expected = Arrays.asList(new ContainsTwoFromStringableFields(new FirstFromStringable("row1.first"), new SecondFromStringable("row1.second")), new ContainsTwoFromStringableFields(new FirstFromStringable("row2.first"), new SecondFromStringable("row2.second")));
    assertEquals(expected, converted);
}
Also used : DataTable(cucumber.api.DataTable) Test(org.junit.Test)

Example 23 with DataTable

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

the class TableConverterTest method converts_table_of_several_columns_to_list_of_integers.

@Test
public void converts_table_of_several_columns_to_list_of_integers() {
    DataTable table = TableParser.parse("|3|5|\n|6|7|\n", null);
    List<Integer> converted = table.asList(Integer.class);
    assertEquals(asList(3, 5, 6, 7), converted);
}
Also used : DataTable(cucumber.api.DataTable) Test(org.junit.Test)

Example 24 with DataTable

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

the class TableConverterTest method converts_table_of_single_column_to_enums.

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

Example 25 with DataTable

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

the class TableConverterTest method converts_to_list_of_map_of_date.

@Test
public void converts_to_list_of_map_of_date() {
    DataTable table = TableParser.parse("|Birth Date|Death Cal|\n|1957-05-10|1979-02-02|\n", PARAMETER_INFO);
    List<Map<String, Date>> converted = table.asMaps(String.class, Date.class);
    assertEquals(sidsBirthday(), converted.get(0).get("Birth Date"));
}
Also used : DataTable(cucumber.api.DataTable) HashMap(java.util.HashMap) Map(java.util.Map) 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