use of io.bootique.jdbc.test.Column in project bootique-jdbc by bootique.
the class CsvDataSetBuilderTest method before.
@Before
public void before() {
DatabaseChannel mockChannel = mock(DatabaseChannel.class);
table = Table.builder(mockChannel, "t_t").columns(new Column("c1", Types.VARCHAR), new Column("c2", Types.INTEGER), new Column("c3", Types.VARBINARY)).build();
}
use of io.bootique.jdbc.test.Column in project bootique-jdbc by bootique.
the class CsvReader method loadDataSet.
TableDataSet loadDataSet(Reader dataReader) throws IOException {
try (CSVParser parser = new CSVParser(dataReader, CSVFormat.DEFAULT, 0, 0)) {
Iterator<CSVRecord> rows = parser.iterator();
if (!rows.hasNext()) {
return new TableDataSet(table, Collections.emptyList(), Collections.emptyList());
}
List<Column> header = getHeader(rows.next());
return readData(header, rows);
}
}
use of io.bootique.jdbc.test.Column in project bootique-jdbc by bootique.
the class CsvMatcherRunner method matchData.
private void matchData(Map<RowKey, Object[]> mappedData) {
referenceData.getRecords().forEach(ref -> {
RowKey rowKey = keyFactory.createKey(ref);
Object[] row = mappedData.get(rowKey);
assertNotNull("No DB records for key: " + rowKey, row);
for (int i = 0; i < row.length; i++) {
Object refVal = ref[i];
Object dbVal = row[i];
Column c = referenceData.getHeader().get(i);
if (refVal == null) {
compareNull(c, rowKey, dbVal);
continue;
}
switch(c.getType()) {
case Types.VARBINARY:
case Types.BINARY:
case Types.LONGVARBINARY:
case Types.BLOB:
// TODO: check that data type is actually a byte[]?
compareByteArrays(c, rowKey, (byte[]) refVal, (byte[]) dbVal);
break;
default:
compareValues(c, rowKey, refVal, dbVal);
break;
}
}
});
}
Aggregations