use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method scriptRowTransformer.
@Test
public void scriptRowTransformer() {
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().homeScriptFolder("./src/test/scripts").startWith("validate").from(source).to(consumer).sqlQuery("select * from Coffee").build();
pump.start();
verify(consumer, times(2)).processRow(any(Row.class));
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method acceptingFilter.
@Test
public void acceptingFilter() {
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().filter("true").filter("$ROW.empty === false").from(source).to(consumer).sqlQuery("select * from Coffee").build();
long rowCount = pump.start().getProcessedRowCount();
assertThat(rowCount, is(2l));
verify(consumer, times(2)).processRow(any(Row.class));
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method oneToOneTransformationWithName.
@Test
public void oneToOneTransformationWithName() {
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).with("name", t -> t).to(consumer).sqlQuery("select * from Coffee").build();
pump.start();
verify(consumer, times(2)).processRow(any(Row.class));
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method usePipeline.
@Test
public void usePipeline() {
Pipeline pipeline = PipelineTest.getCSVPipeline();
NamedSink consumer = getMockedSink();
Pump pump = new Pump.Engine().flowListener(l -> System.out.println(l)).use(pipeline).to(consumer).build();
pump.start();
verify(consumer, times(4)).processRow(any(Row.class));
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PipelineTest method getJSONPipeline.
public static Pipeline getJSONPipeline() {
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 VirtualSinkSource();
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;
}
Aggregations