@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");
    // Note that this does not create architecture nodes in the dependency graph.
    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));
}