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);
}
Aggregations