use of org.kie.workbench.common.stunner.core.client.canvas.controls.MediatorsControl in project kie-wb-common by kiegroup.
the class DiagramViewerTest method testOpen.
@Test
@SuppressWarnings("unchecked")
public void testOpen() {
tested.open(diagram, callback);
assertEquals(diagram, tested.getInstance());
verify(canvasHandler, times(1)).handle(eq(canvas));
verify(canvasHandler, times(1)).draw(eq(diagram), any(ParameterizedCommand.class));
verify(callback, times(1)).afterCanvasInitialized();
verify(mediatorsControlInstance, times(1)).init(eq(canvas));
verify(selectionControlInstance, times(1)).init(eq(canvasHandler));
verify(view, times(1)).setWidget(eq(canvasViewWidget));
ArgumentCaptor<CanvasShapeListener> shapeListenerArgumentCaptor = ArgumentCaptor.forClass(CanvasShapeListener.class);
ArgumentCaptor<CanvasElementListener> elementListenerArgumentCaptor = ArgumentCaptor.forClass(CanvasElementListener.class);
verify(canvas, times(1)).addRegistrationListener(shapeListenerArgumentCaptor.capture());
verify(canvasHandler, times(1)).addRegistrationListener(elementListenerArgumentCaptor.capture());
DefaultCanvasShapeListener shapeListener = (DefaultCanvasShapeListener) shapeListenerArgumentCaptor.getValue();
Iterator<CanvasControl<AbstractCanvas>> canvasControls = shapeListener.getCanvasControls().iterator();
assertTrue(canvasControls.next() instanceof MediatorsControl);
assertFalse(canvasControls.hasNext());
DefaultCanvasElementListener elementListener = (DefaultCanvasElementListener) elementListenerArgumentCaptor.getValue();
Iterator<CanvasControl<AbstractCanvasHandler>> canvasHandlerControls1 = elementListener.getCanvasControls().iterator();
assertTrue(canvasHandlerControls1.next() instanceof SelectionControl);
assertFalse(canvasHandlerControls1.hasNext());
}
Aggregations