### Question:
UniquePathRecordingDependencyVisitor implements DependencyVisitor { public ImmutableList<List<DependencyNode>> getPaths() { return ImmutableList.copyOf(paths); } UniquePathRecordingDependencyVisitor(DependencyFilter filter); ImmutableList<List<DependencyNode>> getPaths(); boolean visitEnter(DependencyNode node); boolean visitLeave(DependencyNode node);  }### Answer:
@Test public void testVisitingUniqueNodes_twoPaths() { DefaultDependencyNode root = new DefaultDependencyNode(new DefaultArtifact("g:r:1")); DefaultDependencyNode a = new DefaultDependencyNode(new DefaultArtifact("g:a:1")); DefaultDependencyNode b = new DefaultDependencyNode(new DefaultArtifact("g:b:1")); DefaultDependencyNode x = new DefaultDependencyNode(new DefaultArtifact("g:x:1")); root.setChildren(ImmutableList.of(a, b)); a.setChildren(ImmutableList.of(x)); b.setChildren(ImmutableList.of(x)); UniquePathRecordingDependencyVisitor visitor = new UniquePathRecordingDependencyVisitor( (DependencyNode node, List<DependencyNode> parents) -> node.getArtifact().getArtifactId().equals("x")); root.accept(visitor); ImmutableList<List<DependencyNode>> paths = visitor.getPaths(); Truth.assertThat(paths).hasSize(2); assertSame(root, paths.get(0).get(0)); assertSame(a, paths.get(0).get(1)); assertSame(x, paths.get(0).get(2)); assertSame(root, paths.get(1).get(0)); assertSame(b, paths.get(1).get(1)); assertSame(x, paths.get(1).get(2)); }
@Test public void testVisitingUniqueNodes() { DefaultDependencyNode root = new DefaultDependencyNode(new DefaultArtifact("g:r:1")); DefaultDependencyNode a = new DefaultDependencyNode(new DefaultArtifact("g:a:1")); DefaultDependencyNode b = new DefaultDependencyNode(new DefaultArtifact("g:b:1")); DefaultDependencyNode x = new DefaultDependencyNode(new DefaultArtifact("g:x:1")); DefaultDependencyNode y = new DefaultDependencyNode(new DefaultArtifact("g:y:1")); root.setChildren(ImmutableList.of(a, b)); a.setChildren(ImmutableList.of(x)); b.setChildren(ImmutableList.of(x)); x.setChildren(ImmutableList.of(y)); UniquePathRecordingDependencyVisitor visitor = new UniquePathRecordingDependencyVisitor( (DependencyNode node, List<DependencyNode> parents) -> node.getArtifact().getArtifactId().equals("y")); root.accept(visitor); ImmutableList<List<DependencyNode>> paths = visitor.getPaths(); Truth.assertThat(paths).hasSize(1); assertSame(root, paths.get(0).get(0)); assertSame(a, paths.get(0).get(1)); assertSame(x, paths.get(0).get(2)); assertSame(y, paths.get(0).get(3)); }