Search in sources :

Example 1 with MouseClickEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.

the class CreateConnectorActionTest method testStartDrag.

@SuppressWarnings("unchecked")
private DragProxyCallback testStartDrag() {
    final MouseClickEvent event = mock(MouseClickEvent.class);
    when(event.getX()).thenReturn(100d);
    when(event.getY()).thenReturn(500d);
    when(graphBoundsIndexer.getAt(eq(100d), eq(500d))).thenReturn(targetNode);
    ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, NODE_UUID, event);
    assertEquals(tested, cascade);
    verify(edge, times(1)).setSourceNode(eq(element));
    verify(connectorDragProxyFactory, times(1)).proxyFor(eq(canvasHandler));
    ArgumentCaptor<DragProxyCallback> proxyArgumentCaptor = ArgumentCaptor.forClass(DragProxyCallback.class);
    verify(connectorDragProxyFactory, times(1)).show(any(ConnectorDragProxy.Item.class), eq(100), eq(500), proxyArgumentCaptor.capture());
    final DragProxyCallback callback = proxyArgumentCaptor.getValue();
    // Verify drag proxy start.
    callback.onStart(0, 0);
    assertNotNull(tested.getCanvasHighlight());
    verify(graphBoundsIndexer, times(1)).setRootUUID(eq(ROOT_UUID));
    verify(graphBoundsIndexer, times(1)).build(eq(graph));
    verify(edgeBuilderControl, times(1)).enable(eq(canvasHandler));
    ArgumentCaptor<RequiresCommandManager.CommandManagerProvider> providerArgumentCaptor = ArgumentCaptor.forClass(RequiresCommandManager.CommandManagerProvider.class);
    verify(edgeBuilderControl, times(1)).setCommandManagerProvider(providerArgumentCaptor.capture());
    RequiresCommandManager.CommandManagerProvider cmProvider = providerArgumentCaptor.getValue();
    assertEquals(sessionCommandManager, cmProvider.getCommandManager());
    return callback;
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) RequiresCommandManager(org.kie.workbench.common.stunner.core.client.command.RequiresCommandManager) DragProxyCallback(org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)

Example 2 with MouseClickEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.

the class DeleteNodeActionTest method testSkipAction.

@Test
@SuppressWarnings("unchecked")
public void testSkipAction() {
    this.tested = new DeleteNodeAction(translationService, sessionCommandManager, commandFactory, action -> false);
    final MouseClickEvent event = mock(MouseClickEvent.class);
    ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
    assertEquals(tested, cascade);
    verify(sessionCommandManager, never()).execute(eq(canvasHandler), any(CanvasCommand.class));
}
Also used : GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) CanvasCommandFactory(org.kie.workbench.common.stunner.core.client.command.CanvasCommandFactory) Mock(org.mockito.Mock) Index(org.kie.workbench.common.stunner.core.graph.processing.index.Index) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) SessionCommandManager(org.kie.workbench.common.stunner.core.client.command.SessionCommandManager) Mockito.verify(org.mockito.Mockito.verify) CanvasCommand(org.kie.workbench.common.stunner.core.client.command.CanvasCommand) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) CoreTranslationMessages(org.kie.workbench.common.stunner.core.i18n.CoreTranslationMessages) Mockito.never(org.mockito.Mockito.never) Matchers.eq(org.mockito.Matchers.eq) Mockito.any(org.mockito.Mockito.any) Node(org.kie.workbench.common.stunner.core.graph.Node) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) CanvasCommand(org.kie.workbench.common.stunner.core.client.command.CanvasCommand) Test(org.junit.Test)

Example 3 with MouseClickEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.

the class DeleteNodeActionTest method testAction.

@Test
public void testAction() {
    final MouseClickEvent event = mock(MouseClickEvent.class);
    ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
    assertEquals(tested, cascade);
    verify(commandFactory, times(1)).deleteNode(eq(element));
    verify(sessionCommandManager, times(1)).execute(eq(canvasHandler), eq(deleteNodeCommand));
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Test(org.junit.Test)

Example 4 with MouseClickEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.

the class DMNEditDecisionToolboxActionTest method testAction.

@Test
public void testAction() {
    final MouseClickEvent event = mock(MouseClickEvent.class);
    final ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
    assertEquals(tested, cascade);
    final ArgumentCaptor<EditExpressionEvent> eventCaptor = ArgumentCaptor.forClass(EditExpressionEvent.class);
    verify(editExpressionEvent, times(1)).fire(eventCaptor.capture());
    final EditExpressionEvent editExprEvent = eventCaptor.getValue();
    assertEquals(E_UUID, editExprEvent.getNodeUUID());
    assertEquals(decision, editExprEvent.getHasExpression());
    assertEquals(decision, editExprEvent.getHasName().get());
    assertEquals(session, editExprEvent.getSession());
    assertFalse(editExprEvent.isOnlyVisualChangeAllowed());
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Test(org.junit.Test)

Example 5 with MouseClickEvent

use of org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent in project kie-wb-common by kiegroup.

the class DMNDeleteNodeToolboxActionTest method testOnMouseClickWhenNodeDoesNotRequiresDeletionConfirmation.

@Test
public void testOnMouseClickWhenNodeDoesNotRequiresDeletionConfirmation() {
    final String nodeUuid = "node uuid";
    final Element element = mock(Element.class);
    final Node node = mock(Node.class);
    final MouseClickEvent event = new MouseClickEvent(0, 0, 0, 0);
    when(element.asNode()).thenReturn(node);
    when(graphIndex.get(nodeUuid)).thenReturn(element);
    when(deleteNodeConfirmation.requiresDeletionConfirmation(Collections.singleton(node))).thenReturn(false);
    toolboxAction.onMouseClick(canvasHandler, nodeUuid, event);
    verify(deleteNodeConfirmation, never()).confirmDeletion(any(), any(), any());
    verify(toolboxAction).superOnMouseClick(canvasHandler, nodeUuid, event);
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Node(org.kie.workbench.common.stunner.core.graph.Node) MouseClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent) Test(org.junit.Test)

Aggregations

MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)25 Test (org.junit.Test)17 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)11 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)7 MouseClickHandler (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickHandler)7 CanvasClearSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent)4 Node (org.kie.workbench.common.stunner.core.graph.Node)4 NodeMouseClickEvent (com.ait.lienzo.client.core.event.NodeMouseClickEvent)2 NodeMouseClickHandler (com.ait.lienzo.client.core.event.NodeMouseClickHandler)2 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)2 Consumer (java.util.function.Consumer)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Before (org.junit.Before)2 RunWith (org.junit.runner.RunWith)2 EditExpressionEvent (org.kie.workbench.common.dmn.client.events.EditExpressionEvent)2 CanvasCommand (org.kie.workbench.common.stunner.core.client.command.CanvasCommand)2 SessionCommandManager (org.kie.workbench.common.stunner.core.client.command.SessionCommandManager)2 ClientTranslationService (org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService)2 HasEventHandlers (org.kie.workbench.common.stunner.core.client.shape.view.HasEventHandlers)2