NodeHasIncomingDependencyTypeFilter implements NodeFilter { @Override public boolean isAccepted(Node node) { return dependencyGraph.getIncomingEdges(node).stream().anyMatch(dep -> dep.getDependencyType() == dependencyType); } NodeHasIncomingDependencyTypeFilter(DependencyGraph dependencyGraph, DependencyType dependencyType); @Override boolean isAccepted(Node node);  }
@Test public void testIsAccepted() { DependencyGraph graph = DependencyGraphFactory.createGraph(); Node n1 = graph.getOrCreateNodeByName("v1"); Node n2 = graph.getOrCreateNodeByName("v2"); Node n3 = graph.getOrCreateNodeByName("v3"); graph.addDependency(n1, n2, DependencyType.READ_ONLY); graph.addDependency(n1, n3, DependencyType.CREATE); NodeHasIncomingDependencyTypeFilter filter = new NodeHasIncomingDependencyTypeFilter(graph, DependencyType.CREATE); assertThat(filter.isAccepted(n1), is(false)); assertThat(filter.isAccepted(n2), is(false)); assertThat(filter.isAccepted(n3), is(true)); }