use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PipelineTest method getJSONToNashornPipeline.
public static Pipeline getJSONToNashornPipeline() {
DestinationMapper targetMapper = new DestinationMapper();
targetMapper.addMapping(0, new TargetMapping("*", "*"));
DatatypeIndexMapper datatypeMapper = new DatatypeIndexMapper();
datatypeMapper.addMapping(1, Datatype.INTEGER);
Source source = new ScriptableSource("./src/test/files/languages.json", "./src/test/files/converter.js", "UTF-8");
NamedSink logSink = new LogSink();
NamedSink virtualSink = new ScriptableSink("./src/test/scripts/sink.js");
Pipeline origin = new Pipeline("json", "src/test/scripts", null, source);
origin.addSink(logSink);
origin.addSink(virtualSink);
origin.addPreRowTransformation(targetMapper);
origin.addPreRowTransformation(datatypeMapper);
origin.addPreRowTransformation(new NashornRowTransformer("src/test/scripts", "encrypt"));
origin.addPostRowTransformation(new NashornRowTransformer("src/test/scripts", "compress"));
origin.addFilter("true");
origin.addExpression("print($ROW); $ROW");
return origin;
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PipelineTest method getCSVPipeline.
public static Pipeline getCSVPipeline() {
DestinationMapper targetMapper = new DestinationMapper();
targetMapper.addMapping(0, new TargetMapping("*", "*"));
DatatypeIndexMapper datatypeMapper = new DatatypeIndexMapper();
datatypeMapper.addMapping(0, Datatype.DOUBLE);
Source source = new CSVFileSource("./src/test/files/pyramid.csv", ";", "UTF-8", true);
NamedSink logSink = new LogSink();
NamedSink jdbcSink = new VirtualSinkSource();
ColumnTransformation e1 = new ColumnTransformation("name", "convert", true);
ColumnTransformation e2 = new ColumnTransformation(42, "compress", true);
Pipeline origin = new Pipeline("csv", "src/test/scripts", "select * from Coffee where name like ? and strength = ?", source);
origin.addSink(logSink);
origin.addSink(jdbcSink);
origin.addQueryParam("arabica");
origin.addQueryParam(2);
origin.addEntryTransformation(e1);
origin.addEntryTransformation(e2);
origin.addPreRowTransformation(targetMapper);
origin.addPreRowTransformation(datatypeMapper);
origin.addEntryTransformation(new ColumnTransformation("1", "function execute(i){return 42;}", false));
origin.addPreRowTransformation(new NashornRowTransformer("src/test/scripts", "encrypt"));
origin.addPostRowTransformation(new NashornRowTransformer("src/test/scripts", "compress"));
origin.addFilter("true");
origin.addExpression("print($ROW); $ROW");
return origin;
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method getMockedSink.
static NamedSink getMockedSink() {
NamedSink mock = mock(NamedSink.class);
when(mock.getName()).thenReturn("*");
return mock;
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method postPreprocessor.
@Test
public void postPreprocessor() {
CoffeeTestFixture.insertCoffee("arabica", 2, "hawai", Roast.LIGHT, "nice", "whole");
CoffeeTestFixture.insertCoffee("niceone", 3, "russia", Roast.MEDIUM, "awful", "java beans");
NamedSink consumer = getMockedSink();
Pump pump = new Pump.Engine().from(source).endWith(l -> l).to(consumer).sqlQuery("select * from Coffee").build();
pump.start();
verify(consumer, times(2)).processRow(any(Row.class));
}
Aggregations