use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testSequenceObjects.
@Test
public void testSequenceObjects() throws Exception {
List<String> columns = Arrays.asList("_id", "person.name", "person.coursename[name]", "person.coursename[count]");
List<String> row1 = Arrays.asList("1", "Andrew Ng", "Machine Learning", "5");
List<String> row2 = Arrays.asList("1", "Andrew Ng", "Recommender Systems", "5");
List<String> row3 = Arrays.asList("2", "Doug Cutting", "Hadoop Internals", "12");
List<String> row4 = Arrays.asList("2", "Doug Cutting", "Basic of Lucene", "25");
List<String> row5 = Arrays.asList("2", "Doug Cutting", "Advanced Lucene", "5");
List<String> row6 = Arrays.asList("2", "Doug Cutting", "Introduction to Apache Avro", "5");
MockSink output = new MockSink();
new StringKeyValueStreamListener().output(output).begin().keys(columns).values(row1).values(row2).values(row3).values(row4).values(row5).values(row6).end();
assertEquals(output.data().toString(), "{[null/null/null/1]->{person={name=\"Andrew Ng\", coursename=[{name=\"Machine Learning\", count=\"5\"}, {name=\"Recommender Systems\", count=\"5\"}]}}={\"person\":{\"name\":\"Andrew Ng\",\"coursename\":[{\"name\":\"Machine Learning\",\"count\":\"5\"},{\"name\":\"Recommender Systems\",\"count\":\"5\"}]}}, [null/null/null/2]->{person={name=\"Doug Cutting\", coursename=[{name=\"Hadoop Internals\", count=\"12\"}, {name=\"Basic of Lucene\", count=\"25\"}, {name=\"Advanced Lucene\", count=\"5\"}, {name=\"Introduction to Apache Avro\", count=\"5\"}]}}={\"person\":{\"name\":\"Doug Cutting\",\"coursename\":[{\"name\":\"Hadoop Internals\",\"count\":\"12\"},{\"name\":\"Basic of Lucene\",\"count\":\"25\"},{\"name\":\"Advanced Lucene\",\"count\":\"5\"},{\"name\":\"Introduction to Apache Avro\",\"count\":\"5\"}]}}}");
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testNestedObjects.
@Test
public void testNestedObjects() throws Exception {
List<String> columns = Arrays.asList("_id", "person.salary", "person.name", "person.position.name", "person.position.since");
List<String> row1 = Arrays.asList("1", "$1000", "Joe Doe", "Worker", "2012-06-12");
List<String> row2 = Arrays.asList("2", "$2000", "Bill Smith", "Boss", "2012-06-13");
MockSink output = new MockSink();
new StringKeyValueStreamListener().output(output).begin().keys(columns).values(row1).values(row2).end();
assertEquals(output.data().size(), 2, "Number of inserted objects");
assertEquals(output.data().toString(), "{[null/null/null/1]->{person={salary=\"$1000\", name=\"Joe Doe\", position={name=\"Worker\", since=\"2012-06-12\"}}}={\"person\":{\"salary\":\"$1000\",\"name\":\"Joe Doe\",\"position\":{\"name\":\"Worker\",\"since\":\"2012-06-12\"}}}, [null/null/null/2]->{person={salary=\"$2000\", name=\"Bill Smith\", position={name=\"Boss\", since=\"2012-06-13\"}}}={\"person\":{\"salary\":\"$2000\",\"name\":\"Bill Smith\",\"position\":{\"name\":\"Boss\",\"since\":\"2012-06-13\"}}}}");
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testJSON.
@Test
public void testJSON() throws Exception {
List<String> columns = Arrays.asList("_optype", "_id", "message", "person", "person.attributes");
List<String> row1 = Arrays.asList("index", "1", "{\"Hello\":\"World\"}", "{\"name\":[\"Joe\",\"John\"]}", "{\"haircolor\":\"blue\"}");
MockSink output = new MockSink();
new StringKeyValueStreamListener().output(output).begin().keys(columns).values(row1).end();
assertEquals(output.data().toString(), "{[index/null/null/1]->{message=\"{Hello=World}\", person=\"{name=[Joe, John], attributes=\"{haircolor=blue}\"}\"}={\"message\":{\"Hello\":\"World\"},\"person\":{\"name\":[\"Joe\",\"John\"],\"attributes\":{\"haircolor\":\"blue\"}}}}");
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testOverlappingOps.
@Test
public void testOverlappingOps() throws Exception {
List<String> columns = Arrays.asList("_optype", "_id", "label");
List<String> row1 = Arrays.asList("index", "1", "label1");
List<String> row2 = Arrays.asList("create", "1", "label2");
List<String> row3 = Arrays.asList("delete", "2", "label3");
List<String> row4 = Arrays.asList("index", "2", "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(), 3, "Number of objects");
}
use of org.xbib.elasticsearch.jdbc.strategy.mock.MockSink in project elasticsearch-jdbc by jprante.
the class ValueListenerTests method testJSONSource.
@Test
public void testJSONSource() throws Exception {
List<String> columns = Arrays.asList("_optype", "_id", "_source");
List<String> row1 = Arrays.asList("index", "1", "{\"Hello\":\"World\"}");
MockSink output = new MockSink();
new StringKeyValueStreamListener().output(output).begin().keys(columns).values(row1).end();
assertEquals(output.data().toString(), "{[index/null/null/1]->{Hello=World}={\"Hello\":\"World\"}}");
}
Aggregations