use of com.airhacks.enhydrator.in.VirtualSinkSource in project enhydrator by AdamBien.
the class FromJsonToCSVTest method filterAndCastFromCSVFileToLog.
@Test
public void filterAndCastFromCSVFileToLog() {
Source source = new CSVFileSource(INPUT + "/languages.csv", ";", "utf-8", true);
VirtualSinkSource sink = new VirtualSinkSource();
Pump pump = new Pump.Engine().from(source).filter("$ROW.getColumnValue('language') === 'java'").startWith(new DatatypeNameMapper().addMapping("rank", Datatype.INTEGER)).to(sink).to(new LogSink()).build();
Memory memory = pump.start();
assertFalse(memory.areErrorsOccured());
assertThat(memory.getProcessedRowCount(), is(5l));
//expecting only "java" language
assertThat(sink.getNumberOfRows(), is(1));
String languageValue = (String) sink.getRow(0).getColumnValue("language");
assertThat(languageValue, is("java"));
//expecting "java" having rank 1 as Integer
Object rankValue = sink.getRow(0).getColumnValue("rank");
assertTrue(rankValue instanceof Integer);
assertThat((Integer) rankValue, is(1));
}
Aggregations