PathAddressIterator implements Iterator<String> { public PathAddress currentAddress() { return currentAddress; } PathAddressIterator(PathAddress address); @Override boolean hasNext(); @Override String next(); PathAddress originalAddress(); PathAddress currentAddress(); @Override void remove(); static final PathAddressIterator EMPTY; }
@Test public void testCurrentAddress() { PathAddressIterator iterator = new PathAddressIterator(PathAddress.pathAddress("one", "two", "three")); assertTrue(iterator.hasNext()); int count = 1; while (iterator.hasNext()) { iterator.next(); switch (count++) { case 1: assertEquals(PathAddress.pathAddress("two", "three"), iterator.currentAddress()); break; case 2: assertEquals(PathAddress.pathAddress("three"), iterator.currentAddress()); break; case 3: assertEquals(PathAddress.EMPTY_ADDRESS, iterator.currentAddress()); break; } } }