### Question:
JsonNodeUtils { public static Optional<JsonNode> resolveChildNode(JsonNode p, String key) { return p != null && p.hasNonNull(key) ? Optional.of(p.get(key)) : Optional.empty(); } private  JsonNodeUtils(); static Optional<JsonNode> resolveChildNode(JsonNode p, String key);  }### Answer:
@Test void shouldReturnEmptyIfJsonNodeIsNull() { Optional<JsonNode> o = JsonNodeUtils.resolveChildNode(null, "property"); assertThat(o).isEmpty(); }
@Test void shouldReturnEmptyIfJsonNodePropertyIsNull() throws IOException { JsonNode node = mapper.readTree("" + "{" + " \"property\": null" + "}"); Optional<JsonNode> o = JsonNodeUtils.resolveChildNode(node, "property"); assertThat(o).isEmpty(); }
@Test void shouldReturnValueIfJsonNodePropertyIsNotNull() throws IOException { JsonNode node = mapper.readTree("" + "{" + " \"property\": \"PROPERTY_VALUE\"" + "}"); Optional<JsonNode> o = JsonNodeUtils.resolveChildNode(node, "property"); assertThat(o).isNotEmpty(); assertThat(o).hasValueSatisfying( n -> { assertThat(n).isNotNull(); assertThat(n.textValue()).isEqualTo("PROPERTY_VALUE"); } ); }