JsonObject extends JsonValue { void forEach(JsonObjectIterator iterator) { storage.entrySet().forEach(entry -> iterateOnEntry(entry, iterator)); } JsonObject(Map<String, Object> storage); @Override R requireObject(Function<JsonObject, R> mapper); Set<String> keySet(); Object get(String name);  }
@Test public void testForEach() { JsonObjectIterator iterator = mock(JsonObjectIterator.class); JsonObject subject = subject(); subject.forEach(iterator); verify(iterator).apply("a", JsonValue.of(true)); verify(iterator).apply("b", JsonValue.of(new JSONObject())); }