public void process(BytesArray storage) { // no extractors, no lookups if (ObjectUtils.isEmpty(paths)) { return; } results.clear(); if (log.isTraceEnabled()) { log.trace(String.format("About to look for paths [%s] in doc [%s]", Arrays.toString(paths), storage)); } results.addAll(ParsingUtils.values(new JacksonJsonParser(storage.bytes(), 0, storage.length()), paths)); }
@Test public void testId() throws Exception { List<Object> values = ParsingUtils.values(parser, "id"); assertEquals(1, values.size()); } }
@Test public void testNestedSecondFieldValue() throws Exception { assertEquals(Collections.singletonList(1), ParsingUtils.values(nestedJsonParser, "nested.foo")); }
@Test public void testRichObjectNested() throws Exception { List<Object> vals = ParsingUtils.values(parser, "address.building"); assertEquals(1, vals.size()); assertThat(vals.get(0).toString(), containsString("floors")); }
@Test public void testRichObject() throws Exception { List<Object> vals = ParsingUtils.values(parser, "address"); assertEquals(1, vals.size()); assertThat(vals.get(0).toString(), containsString("floors")); }
@Test public void testCorrectLevelMatched() throws Exception { List<Object> vals = ParsingUtils.values(parser, "state"); assertEquals(1, vals.size()); assertThat(vals.get(0).toString(), containsString("CA")); }
@Test public void testNested2FieldValue() throws Exception { assertEquals(Collections.singletonList("halen"), ParsingUtils.values(nestedJsonParser, "nested2.van")); } }
@Test public void testMultipleNestedMatches1() throws Exception { List<Object> vals = ParsingUtils.values(parser, "firstName"); assertEquals(1, vals.size()); assertThat(vals.get(0).toString(), containsString("John")); }
@Test public void testMultipleNestedMatches2() throws Exception { List<Object> vals = ParsingUtils.values(parser, "age"); assertEquals(1, vals.size()); assertThat((Integer) vals.get(0), is(Integer.valueOf(25))); }
@Test public void testNestedFieldValue() throws Exception { assertEquals(Collections.singletonList("value"), ParsingUtils.values(nestedJsonParser, "nested.field")); }
@Test public void testFirstLevel() throws Exception { List<Object> vals = ParsingUtils.values(parser, "firstName", "foo", "age"); assertEquals(3, vals.size()); assertEquals("John", vals.get(0)); assertSame(ParsingUtils.NOT_FOUND, vals.get(1)); assertEquals(25, vals.get(2)); }
@Test public void testSmallerMixedLevels() throws Exception { List<Object> vals = ParsingUtils.values(parser, "firstName", "address.state", "state"); assertEquals(3, vals.size()); assertEquals("John", vals.get(0)); assertEquals("NY", vals.get(1)); assertEquals("CA", vals.get(2)); }
@Test public void testSecondLevel() throws Exception { List<Object> vals = ParsingUtils.values(parser, "address.state", "address.foo", "address.building.floors", "address.building.bar"); assertEquals(4, vals.size()); assertEquals("NY", vals.get(0)); assertSame(ParsingUtils.NOT_FOUND, vals.get(1)); assertEquals(10, vals.get(2)); assertSame(ParsingUtils.NOT_FOUND, vals.get(3)); }
@Test public void testMixedLevels() throws Exception { List<Object> vals = ParsingUtils.values(parser, "firstName", "address.building.floors", "address.decor.walls", "zzz"); assertEquals(4, vals.size()); assertEquals("John", vals.get(0)); assertEquals(10, vals.get(1)); assertEquals("white", vals.get(2)); assertEquals("end", vals.get(3)); } }
public void process(BytesArray storage) { // no extractors, no lookups if (ObjectUtils.isEmpty(paths)) { return; } results.clear(); if (log.isTraceEnabled()) { log.trace(String.format("About to look for paths [%s] in doc [%s]", Arrays.toString(paths), storage)); } results.addAll(ParsingUtils.values(new JacksonJsonParser(storage.bytes(), 0, storage.length()), paths)); }
public void process(BytesArray storage) { // no extractors, no lookups if (ObjectUtils.isEmpty(paths)) { return; } results.clear(); if (log.isTraceEnabled()) { log.trace(String.format("About to look for paths [%s] in doc [%s]", Arrays.toString(paths), storage)); } results.addAll(ParsingUtils.values(new JacksonJsonParser(storage.bytes(), 0, storage.length()), paths)); }
public void process(BytesArray storage) { // no extractors, no lookups if (ObjectUtils.isEmpty(paths)) { return; } results.clear(); if (log.isTraceEnabled()) { log.trace(String.format("About to look for paths [%s] in doc [%s]", Arrays.toString(paths), storage)); } results.addAll(ParsingUtils.values(new JacksonJsonParser(storage.bytes(), 0, storage.length()), paths)); }
public void process(BytesArray storage) { // no extractors, no lookups if (ObjectUtils.isEmpty(paths)) { return; } results.clear(); if (log.isTraceEnabled()) { log.trace(String.format("About to look for paths [%s] in doc [%s]", Arrays.toString(paths), storage)); } results.addAll(ParsingUtils.values(new JacksonJsonParser(storage.bytes(), 0, storage.length()), paths)); }