### Question:
DependencyPath { @Override public String toString() { List<String> formatted = path.stream().map(DependencyPath::formatDependency).collect(Collectors.toList()); StringBuilder builder = new StringBuilder(); if (root != null) { builder.append(root); if (!path.isEmpty()) { builder.append(" / "); } } builder.append(Joiner.on(" / ").join(formatted)); return builder.toString(); } DependencyPath(@Nullable Artifact root); @VisibleForTesting DependencyPath append(Dependency dependency); DependencyPath concat(DependencyPath childPath); int size(); Artifact getLeaf(); ImmutableList<String> getArtifactKeys(); Artifact get(int i); Dependency getDependency(int i); Artifact findExclusion(String groupId, String artifactId); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testToString_nullRoot() { Assert.assertEquals( "com.google:foo:1 (test) / com.google:bar:1 (compile, optional)", pathNullRootFooBar.toString()); }
@Test public void testToString() { Assert.assertEquals( "a:b:jar:1 / com.google:foo:1 (test) / com.google:bar:1 (compile, optional)", pathRootFooBar.toString()); }
@Test public void testToString_singleElement() { Assert.assertEquals("a:b:jar:1", new DependencyPath(root).toString()); }