Source:
<code>public void testParseRow() throws IOException { final JsonInputFormat format = new JsonInputFormat( new JSONPathSpec( true, ImmutableList.of( new JSONPathFieldSpec(JSONPathFieldType.ROOT, "root_baz", "baz"), new JSONPathFieldSpec(JSONPathFieldType.ROOT, "root_baz2", "baz2"), new JSONPathFieldSpec(JSONPathFieldType.PATH, "path_omg", "$.o.mg"), new JSONPathFieldSpec(JSONPathFieldType.PATH, "path_omg2", "$.o.mg2"), new JSONPathFieldSpec(JSONPathFieldType.JQ, "jq_omg", ".o.mg"), new JSONPathFieldSpec(JSONPathFieldType.JQ, "jq_omg2", ".o.mg2") ) ), null ); final ByteSource source = new ByteSource( StringUtils.toUtf8("{\"timestamp\":\"2019-01-01\",\"bar\":null,\"foo\":\"x\",\"baz\":4,\"o\":{\"mg\":1}}") ); final SplitReader reader = format.createReader( new TimestampSpec("timestamp", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("bar", "foo"))) ); try (CloseableIterator<InputRow> iterator = reader.read(source, null)) { while (iterator.hasNext()) { final InputRow row = iterator.next(); Assert.assertEquals(DateTimes.of("2019-01-01"), row.getTimestamp()); Assert.assertEquals("x", Iterables.getOnlyElement(row.getDimension("foo"))); Assert.assertEquals("4", Iterables.getOnlyElement(row.getDimension("baz"))); Assert.assertEquals("4", Iterables.getOnlyElement(row.getDimension("root_baz"))); Assert.assertEquals("1", Iterables.getOnlyElement(row.getDimension("path_omg"))); Assert.assertEquals("1", Iterables.getOnlyElement(row.getDimension("jq_omg"))); Assert.assertTrue(row.getDimension("root_baz2").isEmpty()); Assert.assertTrue(row.getDimension("path_omg2").isEmpty()); Assert.assertTrue(row.getDimension("jq_omg2").isEmpty()); } <START> } <END> }</code><technical_language>assert expected number of 1 iteration occurred</technical_language>

Target:
public void testParseRow() throws IOException { final JsonInputFormat format = new JsonInputFormat( new JSONPathSpec( true, ImmutableList.of( new JSONPathFieldSpec(JSONPathFieldType.ROOT, "root_baz", "baz"), new JSONPathFieldSpec(JSONPathFieldType.ROOT, "root_baz2", "baz2"), new JSONPathFieldSpec(JSONPathFieldType.PATH, "path_omg", "$.o.mg"), new JSONPathFieldSpec(JSONPathFieldType.PATH, "path_omg2", "$.o.mg2"), new JSONPathFieldSpec(JSONPathFieldType.JQ, "jq_omg", ".o.mg"), new JSONPathFieldSpec(JSONPathFieldType.JQ, "jq_omg2", ".o.mg2") ) ), null ); final ByteEntity source = new ByteEntity( StringUtils.toUtf8("{\"timestamp\":\"2019-01-01\",\"bar\":null,\"foo\":\"x\",\"baz\":4,\"o\":{\"mg\":1}}") ); final InputEntityReader reader = format.createReader( new InputRowSchema( new TimestampSpec("timestamp", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("bar", "foo"))), Collections.emptyList() ) ); final int numExpectedIterations = 1; try (CloseableIterator<InputRow> iterator = reader.read(source, null)) { int numActualIterations = 0; while (iterator.hasNext()) { final InputRow row = iterator.next(); Assert.assertEquals(DateTimes.of("2019-01-01"), row.getTimestamp()); Assert.assertEquals("x", Iterables.getOnlyElement(row.getDimension("foo"))); Assert.assertEquals("4", Iterables.getOnlyElement(row.getDimension("baz"))); Assert.assertEquals("4", Iterables.getOnlyElement(row.getDimension("root_baz"))); Assert.assertEquals("1", Iterables.getOnlyElement(row.getDimension("path_omg"))); Assert.assertEquals("1", Iterables.getOnlyElement(row.getDimension("jq_omg"))); Assert.assertTrue(row.getDimension("root_baz2").isEmpty()); Assert.assertTrue(row.getDimension("path_omg2").isEmpty()); Assert.assertTrue(row.getDimension("jq_omg2").isEmpty()); numActualIterations++; } Assert.assertEquals(numExpectedIterations, numActualIterations); } }