Search in sources :

Example 11 with Connection

use of org.kie.workbench.common.stunner.core.graph.content.view.Connection in project kie-wb-common by kiegroup.

the class ConnectionAcceptorControlImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getAbstractCanvas()).thenReturn(canvas);
    when(canvas.getView()).thenReturn(canvasView);
    when(edge.getContent()).thenReturn(edgeContent);
    when(edgeContent.getSourceConnection()).thenReturn(Optional.empty());
    when(edgeContent.getTargetConnection()).thenReturn(Optional.empty());
    doAnswer(invocationOnMock -> {
        final Node node = (Node) invocationOnMock.getArguments()[0];
        final Edge edge = (Edge) invocationOnMock.getArguments()[1];
        final Connection connection = (Connection) invocationOnMock.getArguments()[2];
        setConnectionSourceNodeCommand = new SetConnectionSourceNodeCommand(node, edge, connection);
        return setConnectionSourceNodeCommand;
    }).when(canvasCommandFactory).setSourceNode(any(Node.class), any(Edge.class), any(Connection.class));
    doAnswer(invocationOnMock -> {
        final Node node = (Node) invocationOnMock.getArguments()[0];
        final Edge edge = (Edge) invocationOnMock.getArguments()[1];
        final Connection connection = (Connection) invocationOnMock.getArguments()[2];
        setConnectionTargetNodeCommand = new SetConnectionTargetNodeCommand(node, edge, connection);
        return setConnectionTargetNodeCommand;
    }).when(canvasCommandFactory).setTargetNode(any(Node.class), any(Edge.class), any(Connection.class));
    when(commandManager.allow(eq(canvasHandler), eq(setConnectionSourceNodeCommand))).thenReturn(result);
    when(commandManager.execute(eq(canvasHandler), eq(setConnectionSourceNodeCommand))).thenReturn(result);
    when(commandManager.allow(eq(canvasHandler), eq(setConnectionTargetNodeCommand))).thenReturn(result);
    when(commandManager.execute(eq(canvasHandler), eq(setConnectionTargetNodeCommand))).thenReturn(result);
    this.tested = new ConnectionAcceptorControlImpl(canvasCommandFactory, cancelCanvasActionEvent);
    this.tested.setCommandManagerProvider(() -> commandManager);
}
Also used : SetConnectionTargetNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.SetConnectionTargetNodeCommand) Node(org.kie.workbench.common.stunner.core.graph.Node) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) WiresConnection(com.ait.lienzo.client.core.shape.wires.WiresConnection) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) SetConnectionSourceNodeCommand(org.kie.workbench.common.stunner.core.client.canvas.command.SetConnectionSourceNodeCommand) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Before(org.junit.Before)

Aggregations

Connection (org.kie.workbench.common.stunner.core.graph.content.view.Connection)11 Node (org.kie.workbench.common.stunner.core.graph.Node)6 MagnetConnection (org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection)5 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)5 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)4 Test (org.junit.Test)3 Edge (org.kie.workbench.common.stunner.core.graph.Edge)3 DiscreteConnection (org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection)3 ScriptTask (org.kie.workbench.common.stunner.bpmn.definition.ScriptTask)2 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)2 TestingGraphUtils.verifyConnection (org.kie.workbench.common.stunner.core.TestingGraphUtils.verifyConnection)2 Command (org.kie.workbench.common.stunner.core.command.Command)2 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)2 RuleEvaluationContext (org.kie.workbench.common.stunner.core.rule.RuleEvaluationContext)2 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)1 LinkedList (java.util.LinkedList)1 Before (org.junit.Before)1 SetConnectionSourceNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.SetConnectionSourceNodeCommand)1 SetConnectionTargetNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.SetConnectionTargetNodeCommand)1 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)1