use of com.airhacks.enhydrator.out.LogSink in project enhydrator by AdamBien.
the class CSVImportTest method getSource.
VirtualSinkSource getSource(final String fileName) {
Source source = new CSVFileSource(fileName, ";", "UTF-8", true);
VirtualSinkSource vss = new VirtualSinkSource();
Pump pump = new Pump.Engine().from(source).to(vss).to(new LogSink()).build();
pump.start();
return vss;
}
use of com.airhacks.enhydrator.out.LogSink in project enhydrator by AdamBien.
the class CsvCharsetTest method fromJSONToCSVWithCharset.
@Test
public void fromJSONToCSVWithCharset() throws FileNotFoundException {
CSVFileSource source = new CSVFileSource(INPUT + "utf8-characters.csv", sourceDelimiter, sourceCharsetName, sourceContainsHeaders);
String fileName = getFileName();
final CSVFileSink csvFileSink = new CSVFileSink(sinkName, fileName, sinkDelimiter, sinkUseNamesAsHeaders, sinkAppend, "UTF-8");
// do the test
Pump pumpOut = new Pump.Engine().from(source).to(new LogSink()).to(csvFileSink).build();
pumpOut.start();
}
use of com.airhacks.enhydrator.out.LogSink 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