@Test
public void testGetComponentName() {

    DependencyGraph dependencyGraph = DependencyGraphFactory.createGraph();
    DefaultPackageArchitectureFactory factory = new DefaultPackageArchitectureFactory(dependencyGraph);
    assertThat(factory.getComponentName("com.example.api.A", 0), is("com.example.api"));
    assertThat(factory.getComponentName("com.example.api", 0), is("com.example"));
    assertThat(factory.getComponentName("com.example", 0), is("com"));
    assertThat(factory.getComponentName("com", 0), nullValue());
    assertThat(factory.getComponentName("", 0), nullValue());
    try {
        factory.getComponentName(null, 0);
        fail("Expected NPE");
    } catch(NullPointerException e) {
        assertThat(e.getMessage(), is("name"));
    }
}