public class PackageHierarchyTest {
@Test
public void testSimple() {
PackageHierarchy h = new PackageHierarchy();
h.addPackage(new PackageConfigData("com.foo"));
Folder root = h.getRoot();
assertEquals(1, root.getChildren().size());
Folder f = (Folder) root.getChildren().get(0);
assertEquals(null, f.getConfig());
assertEquals("com", f.getName());
assertEquals(1, f.getChildren().size());
f = (Folder) f.getChildren().get(0);
assertEquals("foo", f.getName());
assertNotNull(f.getConfig());
h.addPackage(new PackageConfigData("com.bar"));
f = (Folder) root.getChildren().get(0);
assertEquals("com", f.getName());
assertNull(f.getConfig());
assertEquals(2, f.getChildren().size());
f = (Folder) f.getChildren().get(1);
assertEquals("bar", f.getName());
assertNotNull(f.getConfig());
h.addPackage(new PackageConfigData("goo.bar.baz"));
assertEquals(2, root.getChildren().size());
f = (Folder) root.getChildren().get(1);
assertEquals("goo", f.getName());
assertEquals(1, f.getChildren().size());
f = (Folder) f.getChildren().get(0);
assertEquals("bar", f.getName());
assertEquals(1, f.getChildren().size());
f= (Folder) f.getChildren().get(0);
assertEquals("baz", f.getName());
h.addPackage(new PackageConfigData("goo.char.baz"));
assertEquals(2, root.getChildren().size());
f = (Folder) root.getChildren().get(1);
assertEquals(2, f.getChildren().size());
f = (Folder) f.getChildren().get(1);
assertEquals("char", f.getName());
assertEquals(1, f.getChildren().size());
f = (Folder) f.getChildren().get(0);
assertEquals("baz", f.getName());
h.addPackage(new PackageConfigData("Whee"));
assertEquals(3, root.getChildren().size());
}