use of com.airhacks.enhydrator.transform.Memory 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.transform.Memory 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.transform.Memory 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"));
}
use of com.airhacks.enhydrator.transform.Memory 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()));
}
use of com.airhacks.enhydrator.transform.Memory in project enhydrator by AdamBien.
the class PumpTest method getIntRow.
Row getIntRow() {
Row row = new Row();
row.useMemory(new Memory());
row.addColumn(0, "a", "1");
row.addColumn(1, "b", "2");
return row;
}
Aggregations