use of org.kie.workbench.common.stunner.core.client.canvas.controls.CanvasControl in project kie-wb-common by kiegroup.
the class ManagedSessionTest method testInit.
@Test
@SuppressWarnings("unchecked")
public void testInit() {
Command callback = mock(Command.class);
Consumer<CanvasControl<AbstractCanvas>> canvasControlConsumer = mock(Consumer.class);
Consumer<CanvasControl<AbstractCanvasHandler>> canvasHandlerControlConsumer = mock(Consumer.class);
tested.registerCanvasControl(SomeTestControl.class).registerCanvasHandlerControl(SomeTestControl.class).onCanvasControlRegistered(canvasControlConsumer).onCanvasHandlerControlRegistered(canvasHandlerControlConsumer).init(metadata, callback);
assertEquals(canvas, tested.getCanvas());
assertEquals(canvasHandler, tested.getCanvasHandler());
assertEquals(canvasControl, tested.getCanvasControls().get(0));
assertEquals(canvasHandlerControl, tested.getCanvasHandlerControls().get(0));
verify(sessionLoader, times(1)).load(eq(metadata), any(ParameterizedCommand.class), any(ParameterizedCommand.class));
verify(canvasInstances, times(1)).select(eq(qualifier));
verify(canvasHandlerInstances, times(1)).select(eq(qualifier));
verify(canvasControlInstances, times(1)).select(eq(SomeTestControl.class), eq(qualifier));
verify(canvasHandlerControlInstances, times(1)).select(eq(SomeTestControl.class), eq(qualifier));
verify(canvasControlConsumer, times(1)).accept(eq(canvasControl));
verify(canvasHandlerControlConsumer, times(1)).accept(eq(canvasHandlerControl));
verify(callback, times(1)).execute();
}
use of org.kie.workbench.common.stunner.core.client.canvas.controls.CanvasControl in project kie-wb-common by kiegroup.
the class DiagramEditorTest method testOpen.
@Test
@SuppressWarnings("unchecked")
public void testOpen() {
tested.open(diagram, callback);
assertEquals(diagram, tested.getInstance());
verify(viewer, times(1)).open(eq(diagram), any(DiagramViewer.DiagramViewerCallback.class));
verify(locationControlInstance, times(1)).init(eq(canvasHandler));
verify(resizeControlInstance, times(1)).init(eq(canvasHandler));
verify(builderControlInstance, times(1)).init(eq(canvasHandler));
verify(nodeBuilderControlInstance, times(1)).init(eq(canvasHandler));
verify(edgeBuilderControlInstance, times(1)).init(eq(canvasHandler));
verify(cpControlInstance, times(1)).init(eq(canvasHandler));
verify(connectionAcceptorControlInstance, times(1)).init(eq(canvasHandler));
verify(containmentAcceptorControlInstance, times(1)).init(eq(canvasHandler));
verify(dockingAcceptorControlInstance, times(1)).init(eq(canvasHandler));
ArgumentCaptor<CanvasElementListener> elementListenerArgumentCaptor = ArgumentCaptor.forClass(CanvasElementListener.class);
verify(canvasHandler, times(1)).addRegistrationListener(elementListenerArgumentCaptor.capture());
DefaultCanvasElementListener elementListener = (DefaultCanvasElementListener) elementListenerArgumentCaptor.getValue();
Iterator<CanvasControl<AbstractCanvasHandler>> canvasHandlerControls1 = elementListener.getCanvasControls().iterator();
assertTrue(canvasHandlerControls1.next() instanceof LocationControl);
assertTrue(canvasHandlerControls1.next() instanceof ResizeControl);
assertTrue(canvasHandlerControls1.next() instanceof ElementBuilderControl);
assertTrue(canvasHandlerControls1.next() instanceof NodeBuilderControl);
assertTrue(canvasHandlerControls1.next() instanceof EdgeBuilderControl);
assertTrue(canvasHandlerControls1.next() instanceof ControlPointControl);
assertTrue(canvasHandlerControls1.next() instanceof ContainmentAcceptorControl);
assertTrue(canvasHandlerControls1.next() instanceof ConnectionAcceptorControl);
assertTrue(canvasHandlerControls1.next() instanceof DockingAcceptorControl);
assertFalse(canvasHandlerControls1.hasNext());
}
use of org.kie.workbench.common.stunner.core.client.canvas.controls.CanvasControl 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