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