### Question:
PathImpl implements Path, Serializable { @Override public String toString() { final StringBuilder builder = new StringBuilder(); for (Path.Node node : this) { NodeImpl.appendNode(node, builder); } return builder.toString(); } private  PathImpl(); private  PathImpl(Iterable<? extends Node> nodes); static PathImpl createPathFromString(String propertyPath); static PathImpl create(); static PathImpl copy(Path path); static PathImpl of(Path path); boolean isRootPath(); PathImpl addNode(Node node); PathImpl addProperty(String name); PathImpl addBean(); NodeImpl removeLeafNode(); NodeImpl getLeafNode(); @Override Iterator<Path.Node> iterator(); boolean isSubPathOf(Path path); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final Comparator<Path> PATH_COMPARATOR; }### Answer:
@Test public void testToString() { PathImpl path = PathImpl.create(); path.addNode(new NodeImpl.PropertyNodeImpl("firstName")); assertEquals("firstName", path.toString()); path = PathImpl.create(); path.getLeafNode().setIndex(2); assertEquals("[2]", path.toString()); path.addNode(new NodeImpl.PropertyNodeImpl("firstName")); assertEquals("[2].firstName", path.toString()); }