ComponentManager { public <T extends Component> T create(Class<T> type) { ComponentType<T> typeInfo = getType(type); return typeInfo.create(); } ComponentManager();  ComponentManager(ComponentTypeFactory componentTypeFactory); T create(Class<T> type); T copy(T instance); @SuppressWarnings("unchecked") ComponentType<T> getType(Class<T> type); @SuppressWarnings("unchecked") ComponentType<T> getType(T instance); void clearCache();  }
@Test public void constructComponent() { BasicComponent instance = componentManager.create(BasicComponent.class); assertNotNull(instance); instance.setName("World"); assertEquals("World", instance.getName()); }
@Test public void constructComponentGetType() { BasicComponent instance = componentManager.create(BasicComponent.class); assertNotNull(instance); assertEquals(BasicComponent.class, instance.getClass()); }
@Test public void constructEmptyComponent() { Empty instance = componentManager.create(Empty.class); assertNotNull(instance); }
@Test public void emptyComponentsSingletons() { Empty instance = componentManager.create(Empty.class); Empty instance2 = componentManager.create(Empty.class); assertSame(instance, instance2); }
@Test public void publicAttributesPreventSingletons() { ArrayContainingComponent instance = componentManager.create(ArrayContainingComponent.class); ArrayContainingComponent instance2 = componentManager.create(ArrayContainingComponent.class); assertNotSame(instance, instance2); }