### Question:
ToolboxControlImpl extends AbstractCanvasHandlerRegistrationControl<AbstractCanvasHandler> implements ToolboxControl<AbstractCanvasHandler, Element> { @Override @SuppressWarnings("unchecked") public void register(final Element element) { if (checkNotRegistered(element) && supportsToolbox(element)) { final Shape shape = canvasHandler.getCanvas().getShape(element.getUUID()); final HasEventHandlers hasEventHandlers = (HasEventHandlers) shape.getShapeView(); if (hasEventHandlers.supports(ViewEventType.MOUSE_CLICK)) { final MouseClickHandler clickHandler = new MouseClickHandler() { @Override public void handle(final MouseClickEvent event) { if (event.isButtonLeft()) { show(element); } } }; hasEventHandlers.addHandler(ViewEventType.MOUSE_CLICK, clickHandler); registerHandler(element.getUUID(), clickHandler); } } } ToolboxControlImpl(final Supplier<List<F>> toolboxFactories);   ToolboxControlImpl(final Supplier<List<F>> toolboxFactories,
                       final Predicate<String> showToolboxPredicate); @Override @SuppressWarnings("unchecked") void register(final Element element); @Override Iterator<Toolbox<?>> getToolboxes(final Element element); void destroyToolboxes(); void hideAndDestroyToolboxes(); @SuppressWarnings("unchecked") ToolboxControl<AbstractCanvasHandler, Element> show(final String uuid); ToolboxControl<AbstractCanvasHandler, Element> show(final Element element); AbstractCanvasHandler getCanvasHandler(); boolean isActive(final String uuid); static final Predicate<String> ALWAYS_SHOW_PREDICATE; }### Answer:
@Test public void testRegisterElement() { tested.init(canvasHandler); assertFalse(tested.isRegistered(element)); tested.register(element); verify(shapeEventHandler, times(1)).supports(eq(ViewEventType.MOUSE_CLICK)); verify(shapeEventHandler, times(1)).addHandler(eq(ViewEventType.MOUSE_CLICK), any(MouseClickHandler.class)); assertTrue(tested.isRegistered(element)); }
@Test public void testNotSupportedElement() { tested.init(canvasHandler); final Edge edge = mock(Edge.class); tested.register(edge); assertFalse(tested.isRegistered(edge)); verify(shapeEventHandler, never()).supports(any(ViewEventType.class)); verify(shapeEventHandler, never()).addHandler(any(ViewEventType.class), any(MouseClickHandler.class)); }
@Test @SuppressWarnings("unchecked") public void testDeregisterElement() { tested.init(canvasHandler); tested.register(element); tested.deregister(element); verify(shapeEventHandler, times(1)).removeHandler(any(ViewHandler.class)); assertFalse(tested.isRegistered(element)); }