@Test public void visitChildrenTest() throws ValidationException { dependenciesMock = buildProjectDependencyNodeSpies(10); doReturn(dependenciesMock).when(nodeMock).getChildren(any()); Set<ArtifactCoordinates> dependenciesCollected = buildDependencies(3); visitor.setChildVisitor(() -> getChildVisitorMock(dependenciesCollected)); visitor.visitChildren(nodeMock); for (ProjectDependencyNode dependencyNode : dependenciesMock) { verify(dependencyNode, times(1)).accept(any()); } assertThat("Collected dependencies is not the expected", visitor.getCollectedDependencies(), equalTo(dependenciesCollected)); }
protected void visitChildren(ProjectDependencyNode node) throws ValidationException { Set<ProjectDependencyNode> dependencies = node.getChildren(dependenciesFilter); for (ProjectDependencyNode dependency : dependencies) { DependencyNodeVisitor visitor = childVisitor.get(); dependency.accept(visitor); collectedDependencies.addAll(visitor.getCollectedDependencies()); } }
AbstractArtifactVisitor implements DependencyNodeVisitor { protected void visitChildren(ProjectDependencyNode node) throws ValidationException { Set<ProjectDependencyNode> dependencies = node.getChildren(dependenciesFilter); for (ProjectDependencyNode dependency : dependencies) { DependencyNodeVisitor visitor = childVisitor.get(); dependency.accept(visitor); collectedDependencies.addAll(visitor.getCollectedDependencies()); } } }
AbstractArtifactVisitor implements DependencyNodeVisitor { protected void visitChildren(ProjectDependencyNode node) throws ValidationException { Set<ProjectDependencyNode> dependencies = node.getChildren(dependenciesFilter); for (ProjectDependencyNode dependency : dependencies) { DependencyNodeVisitor visitor = childVisitor.get(); dependency.accept(visitor); collectedDependencies.addAll(visitor.getCollectedDependencies()); } } AbstractArtifactVisitor(String classifier, String scope, Supplier<DependencyNodeVisitor> childVisitor); protected  AbstractArtifactVisitor(); }
AbstractArtifactVisitor implements DependencyNodeVisitor { protected void visitChildren(ProjectDependencyNode node) throws ValidationException { Set<ProjectDependencyNode> dependencies = node.getChildren(dependenciesFilter); for (ProjectDependencyNode dependency : dependencies) { DependencyNodeVisitor visitor = childVisitor.get(); dependency.accept(visitor); collectedDependencies.addAll(visitor.getCollectedDependencies()); } } AbstractArtifactVisitor(String classifier, String scope, Supplier<DependencyNodeVisitor> childVisitor); protected  AbstractArtifactVisitor(); @Override void visit(ProjectDependencyNode node); abstract void collectDependencies(ProjectDependencyNode node); @Override Set<ArtifactCoordinates> getCollectedDependencies(); void setChildVisitor(Supplier<DependencyNodeVisitor> childVisitor); }
AbstractArtifactVisitor implements DependencyNodeVisitor { protected void visitChildren(ProjectDependencyNode node) throws ValidationException { Set<ProjectDependencyNode> dependencies = node.getChildren(dependenciesFilter); for (ProjectDependencyNode dependency : dependencies) { DependencyNodeVisitor visitor = childVisitor.get(); dependency.accept(visitor); collectedDependencies.addAll(visitor.getCollectedDependencies()); } } AbstractArtifactVisitor(String classifier, String scope, Supplier<DependencyNodeVisitor> childVisitor); protected  AbstractArtifactVisitor(); @Override void visit(ProjectDependencyNode node); abstract void collectDependencies(ProjectDependencyNode node); @Override Set<ArtifactCoordinates> getCollectedDependencies(); void setChildVisitor(Supplier<DependencyNodeVisitor> childVisitor);  }