@Test public void testDeriveChildTraverser_ZeroRemaining() { DependencyTraverser other1 = new DummyDependencyTraverser(true, null); DependencyTraverser other2 = new DummyDependencyTraverser(false, null); DependencyTraverser traverser = new AndDependencyTraverser(other1, other2); assertNull(traverser.deriveChildTraverser(null)); }
@Test public void testDeriveChildTraverser_Unchanged() { DependencyTraverser other1 = new DummyDependencyTraverser(true); DependencyTraverser other2 = new DummyDependencyTraverser(false); DependencyTraverser traverser = new AndDependencyTraverser(other1, other2); assertSame(traverser, traverser.deriveChildTraverser(null)); }
@Test public void testHashCode() { DependencyTraverser other1 = new DummyDependencyTraverser(true); DependencyTraverser other2 = new DummyDependencyTraverser(false); DependencyTraverser traverser1 = new AndDependencyTraverser(other1, other2); DependencyTraverser traverser2 = new AndDependencyTraverser(other2, other1); assertEquals(traverser1.hashCode(), traverser2.hashCode()); }
@Test public void testTraverseDependency() { Dependency dependency = new Dependency(new DefaultArtifact("g:a:v:1"), "runtime"); DependencyTraverser traverser = new AndDependencyTraverser(); assertTrue(traverser.traverseDependency(dependency)); traverser = new AndDependencyTraverser( new DummyDependencyTraverser(false), new DummyDependencyTraverser(false)); assertFalse(traverser.traverseDependency(dependency)); traverser = new AndDependencyTraverser( new DummyDependencyTraverser(true), new DummyDependencyTraverser(false)); assertFalse(traverser.traverseDependency(dependency)); traverser = new AndDependencyTraverser( new DummyDependencyTraverser(true), new DummyDependencyTraverser(true)); assertTrue(traverser.traverseDependency(dependency)); }