@Test
public void testGetComponentNameWithMaxLength() {

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