Search in sources :

Example 31 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class JDBCSinkTest method processEmptyRow.

@Test
public void processEmptyRow() {
    this.cut.processRow(null);
    this.cut.processRow(new Row());
}
Also used : Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 32 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class JDBCSinkTest method getEntries.

Row getEntries() {
    Row row = new Row();
    row.addColumn(-1, "a", "java");
    row.addColumn(-1, "b", "tengah");
    return row;
}
Also used : Row(com.airhacks.enhydrator.in.Row)

Example 33 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class Pump method applyRowTransformations.

static Row applyRowTransformations(List<Function<Row, Row>> trafos, Row convertedColumns) {
    if (trafos == null || trafos.isEmpty()) {
        return convertedColumns;
    }
    final Function<Row, Row> composition = trafos.stream().reduce((i, j) -> i.andThen(j)).get();
    Row result = composition.apply(convertedColumns);
    if (result == null) {
        return null;
    } else {
        return result;
    }
}
Also used : LogSink(com.airhacks.enhydrator.out.LogSink) Memory(com.airhacks.enhydrator.transform.Memory) FunctionScriptLoader(com.airhacks.enhydrator.transform.FunctionScriptLoader) HashMap(java.util.HashMap) ColumnTransformation(com.airhacks.enhydrator.flexpipe.ColumnTransformation) Source(com.airhacks.enhydrator.in.Source) Sink(com.airhacks.enhydrator.out.Sink) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) JsonValue(javax.json.JsonValue) Expression(com.airhacks.enhydrator.transform.Expression) List(java.util.List) FilterExpression(com.airhacks.enhydrator.transform.FilterExpression) RowTransformer(com.airhacks.enhydrator.transform.RowTransformer) Map(java.util.Map) NamedSink(com.airhacks.enhydrator.out.NamedSink) Optional(java.util.Optional) Pipeline(com.airhacks.enhydrator.flexpipe.Pipeline) ColumnTransformer(com.airhacks.enhydrator.transform.ColumnTransformer) Row(com.airhacks.enhydrator.in.Row) Row(com.airhacks.enhydrator.in.Row)

Example 34 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class PumpIT method applyRowTransformationsWitDevNull.

@Test
public void applyRowTransformationsWitDevNull() {
    Row input = getEntries();
    List<Function<Row, Row>> funcs = new ArrayList<>();
    funcs.add(l -> new Row());
    Row output = Pump.applyRowTransformations(funcs, input);
    assertTrue(output.isEmpty());
}
Also used : Function(java.util.function.Function) ArrayList(java.util.ArrayList) Row(com.airhacks.enhydrator.in.Row) PipelineTest(com.airhacks.enhydrator.flexpipe.PipelineTest) Test(org.junit.Test)

Example 35 with Row

use of com.airhacks.enhydrator.in.Row in project enhydrator by AdamBien.

the class PumpTest method columnExpressionTransformer.

@Test
public void columnExpressionTransformer() {
    Map<String, Object> bindings = new HashMap<>();
    bindings.put("prefix", "java");
    Row row = new Row();
    row.addColumn(0, "developer", "duke");
    VirtualSinkSource input = new VirtualSinkSource();
    input.addRow(row);
    VirtualSinkSource output = new VirtualSinkSource();
    Pump pump = new Pump.Engine().from(input).homeScriptFolder(EXISTING_HOME_FOLDER, bindings).withColumnExpression("developer", "function execute(column){return prefix + ' ' + column}").to(output).build();
    Memory memory = pump.start();
    assertThat(memory.areErrorsOccured(), is(false));
    Row first = output.getRow(0);
    Object expected = "java duke";
    Object actual = first.getColumnValue("developer");
    assertThat(expected, is(actual.toString()));
}
Also used : VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) HashMap(java.util.HashMap) Memory(com.airhacks.enhydrator.transform.Memory) 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