DependencyMapper { public static void mapDependencies(DependencyGraph dependencyGraph, String tag) { dependencyGraph.getAllEdges() .stream() .filter(dep -> dep.getDependencyType() != DependencyType.CONTAINS) .forEach(edge -> createArchitectureDependency(dependencyGraph.getBaseGraph(), tag, edge)); } private  DependencyMapper(); static void mapDependencies(DependencyGraph dependencyGraph, String tag);  }
@Test public void testMap() { DependencyGraph dependencyGraph = DependencyGraphFactory.createGraph(); Node a = dependencyGraph.getOrCreateNodeByName("X.A"); Node b = dependencyGraph.getOrCreateNodeByName("X.A.b"); Node c = dependencyGraph.getOrCreateNodeByName("X.A.c"); Node d = dependencyGraph.getOrCreateNodeByName("X.A.d"); Node e = dependencyGraph.getOrCreateNodeByName("Y.E"); Node f = dependencyGraph.getOrCreateNodeByName("Y.E.f"); Node g = dependencyGraph.getOrCreateNodeByName("Y.E.g"); dependencyGraph.addDependency(b, c, DependencyType.CREATE); dependencyGraph.addDependency(b, d, DependencyType.CREATE); dependencyGraph.addDependency(c, d, DependencyType.CREATE); dependencyGraph.addDependency(f, g, DependencyType.CREATE); dependencyGraph.addDependency(b, g, DependencyType.INHERIT); assertThat(dependencyGraph.getEdge(a, e), nullValue()); Architecture packageArchitecture = new DefaultPackageArchitectureFactory(dependencyGraph).createArchitecture(); new ArchitectureNodeCreator(dependencyGraph, packageArchitecture).createAllArchitectureNodes(); DependencyMapper.mapDependencies(dependencyGraph, packageArchitecture.getName()); Node x = dependencyGraph.getNode("X"); assertThat(x, notNullValue()); Node y = dependencyGraph.getNode("Y"); assertThat(y, notNullValue()); assertThat(dependencyGraph.getEdge(a, e), notNullValue()); assertThat(dependencyGraph.getEdge(a, e).getDependencyType(), is(DependencyType.INHERIT)); assertThat(dependencyGraph.getEdge(x, y), nullValue()); }