use of cucumber.api.DataTable in project cucumber-jvm by cucumber.
the class TableDifferTest method diff_set_with_itself_in_different_order.
@Test
public void diff_set_with_itself_in_different_order() {
DataTable other = otherTableWithDifferentOrder();
table().unorderedDiff(other);
}
use of cucumber.api.DataTable in project cucumber-jvm by cucumber.
the class TableDifferTest method shouldFindDifferences.
@Test(expected = TableDiffException.class)
public void shouldFindDifferences() {
try {
DataTable otherTable = otherTableWithDeletedAndInserted();
new TableDiffer(table(), otherTable).calculateDiffs();
} catch (TableDiffException e) {
String expected = "" + "Tables were not identical:\n" + " | 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";
assertEquals(expected, e.getMessage());
throw e;
}
}
use of cucumber.api.DataTable in project cucumber-jvm by cucumber.
the class TableDifferTest method unordered_diff_with_list_of_pojos_and_camelcase_header_mapping.
@Test
public void unordered_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(2, "you", 222));
actual.add(new TestPojo(3, "jdoe", 34545));
actual.add(new TestPojo(1, "me", 123));
expected.unorderedDiff(actual);
}
use of cucumber.api.DataTable 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 cucumber.api.DataTable in project cucumber-jvm by cucumber.
the class ToDataTableTest method converts_list_of_beans_with_null_to_table.
@Test
public void converts_list_of_beans_with_null_to_table() {
List<UserPojo> users = tc.toList(personTableWithNull(), UserPojo.class);
DataTable table = tc.toTable(users, "name", "birthDate", "credits");
assertEquals("" + " | name | birthDate | credits |\n" + " | Sid Vicious | | 1,000 |\n" + " | Frank Zappa | 21/12/1940 | 3,000 |\n" + "", table.toString());
}
Aggregations