@Test public void testRemoval() { ObjectNode jsonObject = new ObjectNode(JsonNodeFactory.instance); jsonObject.put("key", "value"); jsonObject.put("hello", "world"); ArrayNode jsonArray = new ArrayNode(JsonNodeFactory.instance); jsonArray.add(new TextNode("Hello there")); jsonArray.add(new IntNode(42)); jsonArray.add(jsonObject); InvalidDocumentFilter filter = new InvalidDocumentFilter(source, registry); ArrayNode jsonResult = filter.doFilter(jsonArray); Assert.assertEquals(1, jsonResult.size()); Assert.assertEquals(jsonResult.get(0), jsonObject); }
@Override protected ArrayNode doFilter(ArrayNode data) { Iterator<JsonNode> iterator = data.elements(); while (iterator.hasNext()) { if (!iterator.next().isObject()) iterator.remove(); } return data; }
InvalidDocumentFilter extends AbstractFilter<ArrayNode, ArrayNode> { @Override protected ArrayNode doFilter(ArrayNode data) { Iterator<JsonNode> iterator = data.elements(); while (iterator.hasNext()) { if (!iterator.next().isObject()) iterator.remove(); } return data; } }
InvalidDocumentFilter extends AbstractFilter<ArrayNode, ArrayNode> { @Override protected ArrayNode doFilter(ArrayNode data) { Iterator<JsonNode> iterator = data.elements(); while (iterator.hasNext()) { if (!iterator.next().isObject()) iterator.remove(); } return data; } @Inject  InvalidDocumentFilter(@Assisted DataSource source, MetricRegistry registry); }
InvalidDocumentFilter extends AbstractFilter<ArrayNode, ArrayNode> { @Override protected ArrayNode doFilter(ArrayNode data) { Iterator<JsonNode> iterator = data.elements(); while (iterator.hasNext()) { if (!iterator.next().isObject()) iterator.remove(); } return data; } @Inject  InvalidDocumentFilter(@Assisted DataSource source, MetricRegistry registry);  }
InvalidDocumentFilter extends AbstractFilter<ArrayNode, ArrayNode> { @Override protected ArrayNode doFilter(ArrayNode data) { Iterator<JsonNode> iterator = data.elements(); while (iterator.hasNext()) { if (!iterator.next().isObject()) iterator.remove(); } return data; } @Inject  InvalidDocumentFilter(@Assisted DataSource source, MetricRegistry registry);   }