ComponentNameTagger { public static List<String> tagComponentNames(DependencyGraph dependencyGraph, Architecture architecture) { final List<String> unmappedClasses = new ArrayList<>(); dependencyGraph.getAllNodes().forEach(node -> { if (!tagComponentName(node, architecture)) { unmappedClasses.add(node.getName()); } }); return unmappedClasses; } private  ComponentNameTagger(); static List<String> tagComponentNames(DependencyGraph dependencyGraph, Architecture architecture);  }
@Test public void testTagComponentNames() { DependencyGraph dependencyGraph = DependencyGraphFactory.createGraph(); dependencyGraph.getOrCreateNodeByName("X.A.b"); dependencyGraph.getOrCreateNodeByName("X.A.c"); dependencyGraph.getOrCreateNodeByName("X.A.d"); dependencyGraph.getOrCreateNodeByName("com.company.project.E.f"); dependencyGraph.getOrCreateNodeByName("com.company.project.E.g"); Architecture packageArchitecture = new DefaultPackageArchitectureFactory(dependencyGraph).createArchitecture(); List<String> unmappedClasses = ComponentNameTagger.tagComponentNames(dependencyGraph, packageArchitecture); String tag = packageArchitecture.getName() + Constants.PARENT_SUFFIX; assertThat(dependencyGraph.getNode("X.A.b").getProperty(tag), is("X.A")); assertThat(dependencyGraph.getNode("X.A.c").getProperty(tag), is("X.A")); assertThat(dependencyGraph.getNode("X.A.d").getProperty(tag), is("X.A")); assertThat(dependencyGraph.getNode("com.company.project.E.f").getProperty(tag), is("com.company.project.E")); assertThat(dependencyGraph.getNode("com.company.project.E.g").getProperty(tag), is("com.company.project.E")); assertThat(dependencyGraph.getNode("com.company.project.E"), nullValue()); assertThat(unmappedClasses, notNullValue()); assertThat(unmappedClasses, hasSize(0)); }