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));
}
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));
}
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;
}
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));
}
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"));
}
Aggregations