CreatedComponentRedistry extends AbstractComponentRegistry implements ComponentRegistry { @Override public Map<String, Object> allComponents() { return new HashMap<>(components); }  @Override String doAdd(Object component); @Override boolean doRemove(Object component); @Override Object getComponent(String name); @Override Map<String, Object> allComponents(); @Override List<Lifecycle> lifecycleCallable(); @Override void cleanComponents();  }
@Test public void test() throws Exception{ CreatedComponentRedistry registry = new CreatedComponentRedistry(); String name = registry.add(new Object()); logger.info("{}", name); Lifecycle lifecycle = new NoOpLifecycleObject(); registry.add(lifecycle); registry.initialize(); registry.start(); Assert.assertTrue(lifecycle.getLifecycleState().isStarted()); Lifecycle lifecycle2 = new NoOpLifecycleObject(); registry.add(lifecycle2); Assert.assertTrue(lifecycle2.getLifecycleState().isStarted()); registry.remove(lifecycle2); Assert.assertTrue(lifecycle2.getLifecycleState().isDisposed()); Assert.assertEquals(2, registry.allComponents().size()); }