JsonNodePiiReplacer implements Function<JsonNode, JsonNode> { @Override public JsonNode apply(JsonNode value) { if (value instanceof TextNode) { return TextNode.valueOf(replacer.replace(value.asText())); } else if (value instanceof BinaryNode) { return BinaryNode.valueOf(new byte[0]); } else { return value; } }  @Override JsonNode apply(JsonNode value);  }
@Test public void binaryNode() throws Exception { JsonNode jsonNode = underTest.apply(BinaryNode.valueOf(new byte[] { 1, 0, 1, 2 })); assertThat(jsonNode.isBinary(), is(true)); assertThat(jsonNode.binaryValue().length, is(0)); }
@Test public void textNode() throws Exception { doReturn("replaced").when(replacer).replace(EXAMPLE_STRING); JsonNode jsonNode = underTest.apply(TextNode.valueOf(EXAMPLE_STRING)); assertThat(jsonNode.asText(), is("replaced")); }
@Test public void nullNode() throws Exception { JsonNode jsonNode = underTest.apply(NullNode.getInstance()); assertThat(jsonNode.isNull(), is(true)); }
@Test public void longNode() throws Exception { JsonNode jsonNode = underTest.apply(LongNode.valueOf(0L)); assertThat(jsonNode.isLong(), is(true)); assertThat(jsonNode.longValue(), is(0L)); }