Search in sources :

Example 16 with Row

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

the class DestinationMapperTest method mapping.

@Test
public void mapping() {
    Row input = new Row();
    final int INDEX = 0;
    input.addColumn(INDEX, "name", "duke");
    final String expectedSink = "customSink";
    final String expectedObject = "targetObject";
    this.cut.addMapping(INDEX, new TargetMapping(expectedSink, expectedObject));
    Row output = this.cut.execute(input);
    Column column = output.getColumnByIndex(INDEX);
    assertThat(column.getTargetObject(), is(expectedObject));
    assertThat(column.getTargetSink(), is(expectedSink));
}
Also used : Column(com.airhacks.enhydrator.in.Column) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 17 with Row

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

the class PumpIT method applyRowTransformationsWithoutFunctions.

@Test
public void applyRowTransformationsWithoutFunctions() {
    Row input = getEntries();
    Row output = Pump.applyRowTransformations(new ArrayList<>(), input);
    assertThat(output, is(input));
}
Also used : Row(com.airhacks.enhydrator.in.Row) PipelineTest(com.airhacks.enhydrator.flexpipe.PipelineTest) Test(org.junit.Test)

Example 18 with Row

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

the class PumpTest method getStringRow.

Row getStringRow() {
    Row row = new Row();
    row.useMemory(new Memory());
    row.addColumn(0, "a", "java");
    row.addColumn(1, "b", "tengah");
    return row;
}
Also used : Memory(com.airhacks.enhydrator.transform.Memory) Row(com.airhacks.enhydrator.in.Row)

Example 19 with Row

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

the class PumpTest method continueOnError.

@Test
public void continueOnError() {
    List<Row> inputRows = new ArrayList<>();
    inputRows.add(getStringRow());
    inputRows.add(getIntRow());
    VirtualSinkSource in = new VirtualSinkSource("in", inputRows);
    VirtualSinkSource out = new VirtualSinkSource();
    Pump cut = new Pump.Engine().from(in).startWith(t -> {
        t.getColumnByName("a").convertToInteger();
        return t;
    }).to(out).continueOnError().build();
    Memory memory = cut.start();
    assertTrue(memory.areErrorsOccured());
    Set<Row> erroneousRows = memory.getErroneousRows();
    assertNotNull(erroneousRows);
    assertFalse(erroneousRows.isEmpty());
    assertThat(memory.getProcessedRowCount(), is(1l));
}
Also used : Memory(com.airhacks.enhydrator.transform.Memory) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Date(java.util.Date) Assert.assertNotNull(org.junit.Assert.assertNotNull) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) HashMap(java.util.HashMap) Test(org.junit.Test) ArrayList(java.util.ArrayList) Mockito.verify(org.mockito.Mockito.verify) Assert.assertThat(org.junit.Assert.assertThat) List(java.util.List) VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Assert.assertFalse(org.junit.Assert.assertFalse) RowTransformer(com.airhacks.enhydrator.transform.RowTransformer) Map(java.util.Map) Row(com.airhacks.enhydrator.in.Row) Mockito.mock(org.mockito.Mockito.mock) VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) Memory(com.airhacks.enhydrator.transform.Memory) ArrayList(java.util.ArrayList) Row(com.airhacks.enhydrator.in.Row) Test(org.junit.Test)

Example 20 with Row

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

the class PumpTest method scriptEngineBindings.

@Test
public void scriptEngineBindings() {
    List<Row> inputRows = new ArrayList<>();
    inputRows.add(getStringRow());
    Map<String, Object> bindings = new HashMap<>();
    bindings.put("date", new Date());
    VirtualSinkSource in = new VirtualSinkSource("in", inputRows);
    VirtualSinkSource out = new VirtualSinkSource();
    Pump cut = new Pump.Engine().homeScriptFolder(EXISTING_HOME_FOLDER, bindings).from(in).startWith("date_should_exist").to(out).build();
    Memory memory = cut.start();
    assertNotNull(memory.get("date"));
}
Also used : VirtualSinkSource(com.airhacks.enhydrator.in.VirtualSinkSource) HashMap(java.util.HashMap) Memory(com.airhacks.enhydrator.transform.Memory) ArrayList(java.util.ArrayList) Row(com.airhacks.enhydrator.in.Row) Date(java.util.Date) 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