use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ColumnStrategySourceTests method verifyDeleteObjects.
private void verifyDeleteObjects(String resource, String insertSql) throws Exception {
MockSink sink = new MockSink();
boolean[] shouldProductsBeDeleted = new boolean[] { true, true, false };
ProductFixtures productFixtures = createFixturesAndPopulateSink(shouldProductsBeDeleted, sink);
testColumnStrategy(sink, resource, insertSql, productFixtures.fixtures, productFixtures.expectedCount);
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testId.
@Test
public void testId() throws Exception {
List<String> columns = Arrays.asList("_optype", "_id", "label");
List<String> row1 = Arrays.asList("index", "1", "label1");
List<String> row2 = Arrays.asList("index", "2", "label2");
List<String> row3 = Arrays.asList("index", "3", "label3");
List<String> row4 = Arrays.asList("index", "4", "label4");
MockSink output = new MockSink();
new StringKeyValueStreamListener().output(output).begin().keys(columns).values(row1).values(row2).values(row3).values(row4).end();
assertEquals(output.data().size(), 4, "Number of inserted objects");
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testIgnoreNullObject.
@Test
public void testIgnoreNullObject() throws Exception {
List<String> columns = Arrays.asList("_id", "blog.name", "blog.association[id]", "blog.association[name]");
List<Object> row1 = new LinkedList<Object>();
row1.add("4679");
row1.add("Joe");
row1.add("3917");
row1.add("John");
List<Object> row2 = new LinkedList<Object>();
row2.add("4679");
row2.add("Joe");
row2.add("4015");
row2.add("Jack");
List<Object> row3 = new LinkedList<Object>();
row3.add("4679");
row3.add("Joe");
row3.add(null);
row3.add(null);
MockSink output = new MockSink();
new SinkKeyValueStreamListener<String, Object>().shouldIgnoreNull(true).output(output).begin().keys(columns).values(row1).values(row2).values(row3).end();
assertEquals(output.data().toString(), "{[null/null/null/4679]->{blog={name=\"Joe\", association=[{id=\"3917\", name=\"John\"}, {id=\"4015\", name=\"Jack\"}, {id=null, name=null}]}}={\"blog\":{\"name\":\"Joe\",\"association\":[{\"id\":\"3917\",\"name\":\"John\"},{\"id\":\"4015\",\"name\":\"Jack\"}]}}}");
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testDoubleScientificNotation.
@Test
public void testDoubleScientificNotation() throws Exception {
Locale.setDefault(Locale.US);
List<String> columns = Arrays.asList("_id", "lat", "lon");
List<Object> row1 = new LinkedList<Object>();
row1.add("1");
row1.add(50.940664);
row1.add(6.9599115);
MockSink output = new MockSink();
new SinkKeyValueStreamListener<String, Object>().output(output).begin().keys(columns).values(row1).end();
assertEquals(output.data().toString(), "{[null/null/null/1]->{lat=50.940664000000, lon=6.959911500000}={\"lat\":50.940664,\"lon\":6.9599115}}");
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testArrays.
@Test
public void testArrays() throws Exception {
List<String> columns = Arrays.asList("_id", "blog.name", "blog.published", "blog.association[id]", "blog.association[name]", "blog.attachment[id]", "blog.attachment[name]");
List<String> row1 = Arrays.asList("4679", "Tesla, Abe and Elba", "2014-01-06 00:00:00", "3917", "Idris Elba", "9450", "/web/q/g/h/57436356.jpg");
List<String> row2 = Arrays.asList("4679", "Tesla, Abe and Elba", "2014-01-06 00:00:00", "3917", "Idris Elba", "9965", "/web/i/s/q/GS3193626.jpg");
List<String> row3 = Arrays.asList("4679", "Tesla, Abe and Elba", "2014-01-06 00:00:00", "3917", "Idris Elba", "9451", "/web/i/s/q/GS3193626.jpg");
MockSink output = new MockSink();
new StringKeyValueStreamListener().output(output).begin().keys(columns).values(row1).values(row2).values(row3).end();
assertEquals(output.data().toString(), "{[null/null/null/4679]->{blog={name=\"Tesla, Abe and Elba\", published=\"2014-01-06 00:00:00\", association=[{id=\"3917\", name=\"Idris Elba\"}, {id=\"3917\", name=\"Idris Elba\"}, {id=\"3917\", name=\"Idris Elba\"}], attachment=[{id=\"9450\", name=\"/web/q/g/h/57436356.jpg\"}, {id=\"9965\", name=\"/web/i/s/q/GS3193626.jpg\"}, {id=\"9451\", name=\"/web/i/s/q/GS3193626.jpg\"}]}}={\"blog\":{\"name\":\"Tesla, Abe and Elba\",\"published\":\"2014-01-06 00:00:00\",\"association\":[{\"id\":\"3917\",\"name\":\"Idris Elba\"},{\"id\":\"3917\",\"name\":\"Idris Elba\"},{\"id\":\"3917\",\"name\":\"Idris Elba\"}],\"attachment\":[{\"id\":\"9450\",\"name\":\"/web/q/g/h/57436356.jpg\"},{\"id\":\"9965\",\"name\":\"/web/i/s/q/GS3193626.jpg\"},{\"id\":\"9451\",\"name\":\"/web/i/s/q/GS3193626.jpg\"}]}}}");
}
Aggregations