### Question:
LienzoMultipleSelectionControl extends AbstractSelectionControl<H> { void onCanvasSelection(final @Observes CanvasSelectionEvent event) { checkNotNull("event", event); if (Objects.equals(getCanvasHandler(), event.getCanvasHandler())) { if (event.getIdentifiers().size() == 1) { onClearSelection(); } selectionShapeProvider.moveShapeToTop(); } } @Inject  LienzoMultipleSelectionControl(final Event<CanvasSelectionEvent> canvasSelectionEvent,
                                          final Event<CanvasClearSelectionEvent> clearSelectionEvent);   LienzoMultipleSelectionControl(final MapSelectionControl<H> selectionControl,
                                   final Event<CanvasSelectionEvent> canvasSelectionEvent,
                                   final Event<CanvasClearSelectionEvent> clearSelectionEvent,
                                   final CursoredSelectionShapeProvider selectionShapeProvider);   }### Answer:
@Test public void testGroupSelectionWithMultipleItems() { final SelectionManager.SelectedItems selectedItems = mock(SelectionManager.SelectedItems.class); final LienzoMultipleSelectionControl.CursoredSelectionShapeProvider ssp = mock(LienzoMultipleSelectionControl.CursoredSelectionShapeProvider.class); tested = new LienzoMultipleSelectionControl<>(selectionControl, canvasSelectionEvent, clearSelectionEvent, ssp); tested.init(canvasHandler); when(selectionManager.getSelectedItems()).thenReturn(selectedItems); when(selectionManager.getSelectedItems().isSelectionGroup()).thenReturn(true); tested.onCanvasSelection(new CanvasSelectionEvent(canvasHandler, Arrays.asList(ELEMENT_UUID, ELEMENT_UUID_2, ELEMENT_UUID_3, ELEMENT_UUID_4, ELEMENT_UUID_5))); verify(selectionControl, never()).clearSelection(); verify(selectionManager, never()).clearSelection(); }
@Test public void testSingleSelectionFromGroupSelection() { final SelectionManager.SelectedItems selectedItems = mock(SelectionManager.SelectedItems.class); final LienzoMultipleSelectionControl.CursoredSelectionShapeProvider ssp = mock(LienzoMultipleSelectionControl.CursoredSelectionShapeProvider.class); tested = new LienzoMultipleSelectionControl<>(selectionControl, canvasSelectionEvent, clearSelectionEvent, ssp); tested.init(canvasHandler); when(selectionManager.getSelectedItems()).thenReturn(selectedItems); when(selectionManager.getSelectedItems().isSelectionGroup()).thenReturn(true); tested.onCanvasSelection(new CanvasSelectionEvent(canvasHandler, Arrays.asList(ELEMENT_UUID))); verify(selectionControl, never()).clearSelection(); verify(selectionManager, times(1)).clearSelection(); }
@Test public void testMoveSelectionShapeToTop() { final LienzoMultipleSelectionControl.CursoredSelectionShapeProvider ssp = mock(LienzoMultipleSelectionControl.CursoredSelectionShapeProvider.class); tested = new LienzoMultipleSelectionControl<>(selectionControl, canvasSelectionEvent, clearSelectionEvent, ssp); tested.init(canvasHandler); tested.onCanvasSelection(new CanvasSelectionEvent(canvasHandler, Collections.emptyList())); verify(ssp, times(1)).moveShapeToTop(); }