use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class ReadJDKVersionsTest method readFromCSV.
@Test
public void readFromCSV() {
Source input = new CSVFileSource("./src/test/files/jdk-dates.csv", ";", "UTF-8", true);
VirtualSinkSource output = new VirtualSinkSource();
Pump pump = new Pump.Engine().from(input).startWith(new SkipFirstRow()).startWith(new DatatypeNameMapper().addMapping("Year", Datatype.INTEGER)).filter("$ROW.getColumnValue('Year') > 2000").to(new LogSink()).to(output).build();
Memory memory = pump.start();
Assert.assertFalse(memory.areErrorsOccured());
List<Row> rows = output.getRows();
assertFalse(rows.isEmpty());
Row first = rows.get(1);
Object year = first.getColumnValue("Year");
System.out.println("The year is: " + year);
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class DatatypeMapperTest method doubleMapping.
@Test
public void doubleMapping() {
Row input = getRow();
this.cut.addMapping(0, Datatype.DOUBLE);
Row output = this.cut.execute(input);
assertTrue(output.getColumnByIndex(0).getValue() instanceof Double);
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class DatatypeMapperTest method integerMapping.
@Test
public void integerMapping() {
Row input = getRow();
this.cut.addMapping(0, Datatype.INTEGER);
Row output = this.cut.execute(input);
assertTrue(output.getColumnByIndex(0).getValue() instanceof Integer);
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class ExpressionTest method emptyExpression.
@Test
public void emptyExpression() {
Row row = new Row();
row.addColumn(-1, "chief", "duke");
Row result = this.cut.execute(row, "");
assertThat(result, is(row));
}
use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.
the class FilterExpressionTest method wrongReturnTypeIsFalse.
@Test
public void wrongReturnTypeIsFalse() {
Boolean result = this.fe.execute(new Row(), "'hey'");
assertFalse(result);
}
Aggregations