Search in sources :

Example 1 with BuildCanvasShapeEvent

use of org.kie.workbench.common.stunner.core.client.canvas.controls.event.BuildCanvasShapeEvent in project kie-wb-common by kiegroup.

the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsNotDuplicated.

@Test
public void testMakeDragProxyCallbackImplWhenNodeIsNotDuplicated() {
    final ShapeFactory factory = mock(ShapeFactory.class);
    final DRGElement drgElement1 = mock(DRGElement.class);
    final DRGElement drgElement2 = mock(DRGElement.class);
    final DRGElement drgElement3 = mock(DRGElement.class);
    final ClientSession currentSession = mock(ClientSession.class);
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    final Graph<?, Node> graph = mock(Graph.class);
    final List<Node> nodes = new ArrayList<>();
    final int x = 10;
    final int y = 20;
    final String id1 = "123";
    final String id2 = "456";
    final String id3 = "789";
    nodes.add(createNode(id1));
    nodes.add(createNode(id2));
    when(graph.nodes()).thenReturn(nodes);
    when(drgElement1.getId()).thenReturn(new Id(id1));
    when(drgElement2.getId()).thenReturn(new Id(id2));
    when(drgElement3.getId()).thenReturn(new Id(id3));
    when(sessionManager.getCurrentSession()).thenReturn(currentSession);
    when(currentSession.getCanvasHandler()).thenReturn(canvasHandler);
    doReturn(graph).when(view).getGraph();
    view.makeDragProxyCallbackImpl(drgElement3, factory).onComplete(x, y);
    verify(notificationEvent, never()).fire(any());
    verify(buildCanvasShapeEvent).fire(buildCanvasShapeEventArgumentCaptor.capture());
    final BuildCanvasShapeEvent canvasShapeEvent = buildCanvasShapeEventArgumentCaptor.getValue();
    assertEquals(canvasHandler, canvasShapeEvent.getCanvasHandler());
    assertEquals(drgElement3, canvasShapeEvent.getDefinition());
    assertEquals(factory, canvasShapeEvent.getShapeFactory());
    assertEquals(x, canvasShapeEvent.getClientX(), 0.1);
    assertEquals(y, canvasShapeEvent.getClientY(), 0.1);
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) DecisionComponentsItemView_DuplicatedNode(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) DMNShapeFactory(org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BuildCanvasShapeEvent(org.kie.workbench.common.stunner.core.client.canvas.controls.event.BuildCanvasShapeEvent) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)1 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)1 DecisionComponentsItemView_DuplicatedNode (org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode)1 DMNShapeFactory (org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 BuildCanvasShapeEvent (org.kie.workbench.common.stunner.core.client.canvas.controls.event.BuildCanvasShapeEvent)1 ClientSession (org.kie.workbench.common.stunner.core.client.session.ClientSession)1 ShapeFactory (org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1