use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method ignoringPreprocessor.
@Test
public void ignoringPreprocessor() {
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).startWith(l -> null).sqlQuery("select * from Coffee").to(consumer).build();
pump.start();
verify(consumer, never()).processRow(any(Row.class));
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method ignoringFilter.
@Test
public void ignoringFilter() {
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("false").from(source).to(consumer).sqlQuery("select * from Coffee").build();
long rowCount = pump.start().getProcessedRowCount();
//counts all rows, not processed rows
assertThat(rowCount, is(2l));
verify(consumer, never()).processRow(any(Row.class));
}
use of com.airhacks.enhydrator.out.NamedSink in project enhydrator by AdamBien.
the class PumpIT method scriptEntryTransformer.
@Test
public void scriptEntryTransformer() {
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").from(source).withColumnScript("Name", "quote").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 passThrough.
@Test
public void passThrough() {
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).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 PipelineTest method getJDBCPipeline.
public static Pipeline getJDBCPipeline() {
DestinationMapper mapper = new DestinationMapper();
mapper.addMapping(0, new TargetMapping("*", "*"));
JDBCSource source = JDBCSourceIT.getSource();
NamedSink logSink = new LogSink();
NamedSink jdbcSink = JDBCSinkTest.getSink();
ColumnTransformation e1 = new ColumnTransformation("name", "convert", true);
ColumnTransformation e2 = new ColumnTransformation(42, "compress", true);
Pipeline origin = new Pipeline("jdbc", "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(mapper);
origin.addPostRowTransformation(new SkipFirstRow());
origin.addPreRowTransformation(new NashornRowTransformer("src/test/scripts", "encrypt"));
origin.addPostRowTransformation(new NashornRowTransformer("src/test/scripts", "compress"));
Map<String, ColumnCopier.NameList> mappings = new HashMap<>();
mappings.put("duke", new ColumnCopier.NameList(Arrays.asList("java", "javaee")));
origin.addPostRowTransformation(new ColumnCopier(mappings));
origin.addFilter("true");
origin.addExpression("print($ROW); $ROW");
return origin;
}
Aggregations