JsonArray extends JsonValue { public void forEach(JsonArrayIterator iterator) { for (int i = 0; i < storage.size(); ++i) { JsonValue childValue = at(i); iterator.apply(i, childValue); } } JsonArray(List<Object> storage); void forEach(JsonArrayIterator iterator); int length(); @Override R requireArray(Function<JsonArray, R> mapper);  }
@Test public void testForEach() { JSONObject rawObj = new JSONObject(); JsonArray subject = withLs(new JsonArray(asList(true, rawObj))).requireArray(); JsonArrayIterator iterator = mock(JsonArrayIterator.class); subject.forEach(iterator); verify(iterator).apply(0, JsonValue.of(true)); verify(iterator).apply(1, JsonValue.of(rawObj)); }