@Test public void returnsMissingNodeOnNonexistentKey() { final ObjectNode expected = JsonNodeFactory.instance.objectNode() .put("key", "/feature/admin_widget") .put("value", 10000); final List<JsonNode> list = new ArrayList<>(); list.add(expected); final JsonNode found = ToggleJsonNode.findByKey(list.iterator(), "/feature/na"); assertThat(found.isMissingNode()).isTrue(); }
public static JsonNode findByKey(Iterator<JsonNode> iterator, String key) { while (iterator.hasNext()) { final JsonNode node = iterator.next(); if (node.path("key").textValue().equals(key)) { return node; } } return MissingNode.getInstance(); }
ToggleJsonNode { public static JsonNode findByKey(Iterator<JsonNode> iterator, String key) { while (iterator.hasNext()) { final JsonNode node = iterator.next(); if (node.path("key").textValue().equals(key)) { return node; } } return MissingNode.getInstance(); } }
ToggleJsonNode { public static JsonNode findByKey(Iterator<JsonNode> iterator, String key) { while (iterator.hasNext()) { final JsonNode node = iterator.next(); if (node.path("key").textValue().equals(key)) { return node; } } return MissingNode.getInstance(); }  }
ToggleJsonNode { public static JsonNode findByKey(Iterator<JsonNode> iterator, String key) { while (iterator.hasNext()) { final JsonNode node = iterator.next(); if (node.path("key").textValue().equals(key)) { return node; } } return MissingNode.getInstance(); }  static JsonNode fromString(String json); static JsonNode findByKey(Iterator<JsonNode> iterator, String key); static boolean matchesCohort(JsonNode node, Optional<String> cohortOpt); static JsonNode findByCohort(JsonNode node, Optional<String> cohortOpt); }
ToggleJsonNode { public static JsonNode findByKey(Iterator<JsonNode> iterator, String key) { while (iterator.hasNext()) { final JsonNode node = iterator.next(); if (node.path("key").textValue().equals(key)) { return node; } } return MissingNode.getInstance(); }  static JsonNode fromString(String json); static JsonNode findByKey(Iterator<JsonNode> iterator, String key); static boolean matchesCohort(JsonNode node, Optional<String> cohortOpt); static JsonNode findByCohort(JsonNode node, Optional<String> cohortOpt); static final ObjectReader DEFAULT_OBJECT_READER; }