Search in sources :

Example 51 with Row

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);
}
Also used : VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) LogSink(com.airhacks.enhydrator.out.LogSink) Memory(com.airhacks.enhydrator.transform.Memory) CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) SkipFirstRow(com.airhacks.enhydrator.transform.SkipFirstRow) SkipFirstRow(com.airhacks.enhydrator.transform.SkipFirstRow) Row(com.airhacks.enhydrator.in.Row) DatatypeNameMapper(com.airhacks.enhydrator.transform.DatatypeNameMapper) CSVFileSource(com.airhacks.enhydrator.in.CSVFileSource) Source(com.airhacks.enhydrator.in.Source) VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Pump(com.airhacks.enhydrator.Pump) Test(org.junit.Test)

Example 52 with Row

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);
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 53 with Row

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);
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 54 with Row

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));
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 55 with 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);
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Aggregations

Row (com.airhacks.enhydrator.in.Row)68 Test (org.junit.Test)54 VirtualSinkSource (com.airhacks.enhydrator.in.VirtualSinkSource)10 Column (com.airhacks.enhydrator.in.Column)8 Memory (com.airhacks.enhydrator.transform.Memory)8 ArrayList (java.util.ArrayList)5 LogSink (com.airhacks.enhydrator.out.LogSink)4 HashMap (java.util.HashMap)4 PipelineTest (com.airhacks.enhydrator.flexpipe.PipelineTest)3 CSVFileSource (com.airhacks.enhydrator.in.CSVFileSource)3 Source (com.airhacks.enhydrator.in.Source)3 SkipFirstRow (com.airhacks.enhydrator.transform.SkipFirstRow)3 List (java.util.List)3 Map (java.util.Map)3 Bindings (javax.script.Bindings)3 Pump (com.airhacks.enhydrator.Pump)2 NamedSink (com.airhacks.enhydrator.out.NamedSink)2 RowTransformer (com.airhacks.enhydrator.transform.RowTransformer)2 Date (java.util.Date)2 Function (java.util.function.Function)2