@Test @SuppressWarnings("unchecked") public void testDestroy() { tested.registerCanvasControl(SomeTestControl.class) .registerCanvasHandlerControl(SomeTestControl.class) .init(metadata, mock(Command.class)); tested.open(); tested.destroy(); assertNull(tested.getCanvas()); assertNull(tested.getCanvasHandler()); assertTrue(tested.getCanvasControls().isEmpty()); assertTrue(tested.getCanvasHandlerControls().isEmpty()); verify(canvas, times(1)).removeRegistrationListener(any(CanvasShapeListener.class)); verify(canvasHandler, times(1)).removeRegistrationListener(any(CanvasElementListener.class)); verify(canvasHandler, times(1)).destroy(); verify(canvasControl, times(1)).destroy(); verify(canvasHandlerControl, times(1)).destroy(); verify(canvasControlInstances, times(1)).destroyAll(); verify(canvasHandlerControlInstances, times(1)).destroyAll(); verify(canvasControlInstances, times(1)).destroyAll(); verify(canvasHandlerControlInstances, times(1)).destroyAll(); }
@Override public void destroy() { sessionLoader.destroy(); removeListeners(); canvasControls.forEach(this::destroyCanvasControl); canvasControls.clear(); canvasControlTypes.clear(); canvasHandlerControls.forEach(this::destroyCanvasHandlerControl); canvasHandlerControls.clear(); canvasHandlerControlTypes.clear(); canvasControlInstances.destroyAll(); canvasHandlerControlInstances.destroyAll(); canvasHandler.destroy(); canvasInstances.destroyAll(); canvasHandlerInstances.destroyAll(); canvas = null; canvasHandler = null; shapeListener = null; elementListener = null; canvasControlRegistered = null; canvasControlDestroyed = null; canvasHandlerControlRegistered = null; canvasHandlerControlDestroyed = null; }
ManagedSession extends AbstractSession<AbstractCanvas, AbstractCanvasHandler> { @Override public void destroy() { sessionLoader.destroy(); removeListeners(); canvasControls.forEach(this::destroyCanvasControl); canvasControls.clear(); canvasControlTypes.clear(); canvasHandlerControls.forEach(this::destroyCanvasHandlerControl); canvasHandlerControls.clear(); canvasHandlerControlTypes.clear(); canvasControlInstances.destroyAll(); canvasHandlerControlInstances.destroyAll(); canvasHandler.destroy(); canvasInstances.destroyAll(); canvasHandlerInstances.destroyAll(); canvas = null; canvasHandler = null; shapeListener = null; elementListener = null; canvasControlRegistered = null; canvasControlDestroyed = null; canvasHandlerControlRegistered = null; canvasHandlerControlDestroyed = null; } }
ManagedSession extends AbstractSession<AbstractCanvas, AbstractCanvasHandler> { @Override public void destroy() { sessionLoader.destroy(); removeListeners(); canvasControls.forEach(this::destroyCanvasControl); canvasControls.clear(); canvasControlTypes.clear(); canvasHandlerControls.forEach(this::destroyCanvasHandlerControl); canvasHandlerControls.clear(); canvasHandlerControlTypes.clear(); canvasControlInstances.destroyAll(); canvasHandlerControlInstances.destroyAll(); canvasHandler.destroy(); canvasInstances.destroyAll(); canvasHandlerInstances.destroyAll(); canvas = null; canvasHandler = null; shapeListener = null; elementListener = null; canvasControlRegistered = null; canvasControlDestroyed = null; canvasHandlerControlRegistered = null; canvasHandlerControlDestroyed = null; } @Inject  ManagedSession(final DefinitionUtils definitionUtils,
                          final SessionLoader sessionLoader,
                          final @Any ManagedInstance<AbstractCanvas> canvasInstances,
                          final @Any ManagedInstance<AbstractCanvasHandler> canvasHandlerInstances,
                          final @Any ManagedInstance<CanvasControl<AbstractCanvas>> canvasControlInstances,
                          final @Any ManagedInstance<CanvasControl<AbstractCanvasHandler>> canvasHandlerControlInstances); }
ManagedSession extends AbstractSession<AbstractCanvas, AbstractCanvasHandler> { @Override public void destroy() { sessionLoader.destroy(); removeListeners(); canvasControls.forEach(this::destroyCanvasControl); canvasControls.clear(); canvasControlTypes.clear(); canvasHandlerControls.forEach(this::destroyCanvasHandlerControl); canvasHandlerControls.clear(); canvasHandlerControlTypes.clear(); canvasControlInstances.destroyAll(); canvasHandlerControlInstances.destroyAll(); canvasHandler.destroy(); canvasInstances.destroyAll(); canvasHandlerInstances.destroyAll(); canvas = null; canvasHandler = null; shapeListener = null; elementListener = null; canvasControlRegistered = null; canvasControlDestroyed = null; canvasHandlerControlRegistered = null; canvasHandlerControlDestroyed = null; } @Inject  ManagedSession(final DefinitionUtils definitionUtils,
                          final SessionLoader sessionLoader,
                          final @Any ManagedInstance<AbstractCanvas> canvasInstances,
                          final @Any ManagedInstance<AbstractCanvasHandler> canvasHandlerInstances,
                          final @Any ManagedInstance<CanvasControl<AbstractCanvas>> canvasControlInstances,
                          final @Any ManagedInstance<CanvasControl<AbstractCanvasHandler>> canvasHandlerControlInstances); @SuppressWarnings("unchecked") ManagedSession registerCanvasControl(final Class<? extends CanvasControl> type); @SuppressWarnings("unchecked") ManagedSession registerCanvasControl(final Class<? extends CanvasControl> type,
                                                final Class<? extends Annotation> qualifier); @SuppressWarnings("unchecked") ManagedSession registerCanvasHandlerControl(final Class<? extends CanvasControl> type); @SuppressWarnings("unchecked") ManagedSession registerCanvasHandlerControl(final Class<? extends CanvasControl> type,
                                                       final Class<? extends Annotation> qualifier); ManagedSession isControlActive(final Predicate<Class<? extends CanvasControl>> predicate); ManagedSession onCanvasControlRegistered(final Consumer<CanvasControl<AbstractCanvas>> c); ManagedSession onCanvasControlDestroyed(final Consumer<CanvasControl<AbstractCanvas>> c); ManagedSession onCanvasHandlerControlRegistered(final Consumer<CanvasControl<AbstractCanvasHandler>> c); ManagedSession onCanvasHandlerControlDestroyed(final Consumer<CanvasControl<AbstractCanvasHandler>> c); @Override void init(final Metadata metadata,
                     final Command callback); @Override void open(); @Override void destroy(); @Override String getSessionUUID(); @Override AbstractCanvas getCanvas(); @Override AbstractCanvasHandler getCanvasHandler(); CanvasControl<AbstractCanvas> getCanvasControl(final Class<? extends CanvasControl> type); CanvasControl<AbstractCanvasHandler> getCanvasHandlerControl(final Class<? extends CanvasControl> type); static Annotation buildQualifier(final Class<? extends Annotation> type); }
ManagedSession extends AbstractSession<AbstractCanvas, AbstractCanvasHandler> { @Override public void destroy() { sessionLoader.destroy(); removeListeners(); canvasControls.forEach(this::destroyCanvasControl); canvasControls.clear(); canvasControlTypes.clear(); canvasHandlerControls.forEach(this::destroyCanvasHandlerControl); canvasHandlerControls.clear(); canvasHandlerControlTypes.clear(); canvasControlInstances.destroyAll(); canvasHandlerControlInstances.destroyAll(); canvasHandler.destroy(); canvasInstances.destroyAll(); canvasHandlerInstances.destroyAll(); canvas = null; canvasHandler = null; shapeListener = null; elementListener = null; canvasControlRegistered = null; canvasControlDestroyed = null; canvasHandlerControlRegistered = null; canvasHandlerControlDestroyed = null; } @Inject  ManagedSession(final DefinitionUtils definitionUtils,
                          final SessionLoader sessionLoader,
                          final @Any ManagedInstance<AbstractCanvas> canvasInstances,
                          final @Any ManagedInstance<AbstractCanvasHandler> canvasHandlerInstances,
                          final @Any ManagedInstance<CanvasControl<AbstractCanvas>> canvasControlInstances,
                          final @Any ManagedInstance<CanvasControl<AbstractCanvasHandler>> canvasHandlerControlInstances); @SuppressWarnings("unchecked") ManagedSession registerCanvasControl(final Class<? extends CanvasControl> type); @SuppressWarnings("unchecked") ManagedSession registerCanvasControl(final Class<? extends CanvasControl> type,
                                                final Class<? extends Annotation> qualifier); @SuppressWarnings("unchecked") ManagedSession registerCanvasHandlerControl(final Class<? extends CanvasControl> type); @SuppressWarnings("unchecked") ManagedSession registerCanvasHandlerControl(final Class<? extends CanvasControl> type,
                                                       final Class<? extends Annotation> qualifier); ManagedSession isControlActive(final Predicate<Class<? extends CanvasControl>> predicate); ManagedSession onCanvasControlRegistered(final Consumer<CanvasControl<AbstractCanvas>> c); ManagedSession onCanvasControlDestroyed(final Consumer<CanvasControl<AbstractCanvas>> c); ManagedSession onCanvasHandlerControlRegistered(final Consumer<CanvasControl<AbstractCanvasHandler>> c); ManagedSession onCanvasHandlerControlDestroyed(final Consumer<CanvasControl<AbstractCanvasHandler>> c); @Override void init(final Metadata metadata,
                     final Command callback); @Override void open(); @Override void destroy(); @Override String getSessionUUID(); @Override AbstractCanvas getCanvas(); @Override AbstractCanvasHandler getCanvasHandler(); CanvasControl<AbstractCanvas> getCanvasControl(final Class<? extends CanvasControl> type); CanvasControl<AbstractCanvasHandler> getCanvasHandlerControl(final Class<? extends CanvasControl> type); static Annotation buildQualifier(final Class<? extends Annotation> type);  }