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));
}
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));
}
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);
}
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;
}
}
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);
}
Aggregations