@Test
public void iterationWorksAsExpected() {

    final JsonKey first = JsonFactory.newKey("first");
    final JsonKey second = JsonFactory.newKey("second");
    final JsonKey third = JsonFactory.newKey("third");
    final List<JsonKey> knownLevels = Arrays.asList(first, second, third);
    final List<JsonKey> levelsFromIteration = new ArrayList<>();
    final JsonPointer underTest = ImmutableJsonPointer.of(first, second, third);
    for (final JsonKey jsonKey : underTest) {
        levelsFromIteration.add(jsonKey);
    }
    assertThat(levelsFromIteration).containsExactly(knownLevels.toArray(new JsonKey[knownLevels.size()]));
}