### Question:
PathProxy implements Path { @Override public Iterator<PropertyContainer> iterator() { return new Iterator<PropertyContainer>() { int i; boolean relationship; @Override public boolean hasNext() { return i < relationships.length || !relationship; } @Override public PropertyContainer next() { if ( relationship ) { relationship = false; return relationship( i++ ); } else { relationship = true; return new NodeProxy( proxySPI, nodes[i] ); } } }; } PathProxy( EmbeddedProxySPI proxySPI, long[] nodes, long[] relationships, int[] directedTypes ); @Override String toString(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override Node startNode(); @Override Node endNode(); @Override Relationship lastRelationship(); @Override Iterable<Relationship> relationships(); @Override Iterable<Relationship> reverseRelationships(); @Override Iterable<Node> nodes(); @Override Iterable<Node> reverseNodes(); @Override int length(); @Override Iterator<PropertyContainer> iterator();  }### Answer:
@Test public void shouldIterateAlternatingNodesAndRelationships() { Path path = new PathProxy( proxySPI, new long[] {1, 2, 3}, new long[] {100, 200}, new int[] {0, ~0} ); Iterator<PropertyContainer> iterator = path.iterator(); PropertyContainer entity; assertTrue( iterator.hasNext() ); assertThat( entity = iterator.next(), instanceOf( Node.class ) ); assertEquals( 1, ((Entity) entity).getId() ); assertTrue( iterator.hasNext() ); assertThat( entity = iterator.next(), instanceOf( Relationship.class ) ); assertEquals( 100, ((Entity) entity).getId() ); assertTrue( iterator.hasNext() ); assertThat( entity = iterator.next(), instanceOf( Node.class ) ); assertEquals( 2, ((Entity) entity).getId() ); assertTrue( iterator.hasNext() ); assertThat( entity = iterator.next(), instanceOf( Relationship.class ) ); assertEquals( 200, ((Entity) entity).getId() ); assertTrue( iterator.hasNext() ); assertThat( entity = iterator.next(), instanceOf( Node.class ) ); assertEquals( 3, ((Entity) entity).getId() ); assertFalse( iterator.hasNext() ); }