Search in sources :

Example 1 with SetChildrenCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand in project kie-wb-common by kiegroup.

the class NodeProxyTest method testCreateTargetNodeInSomeParent.

@Test
@SuppressWarnings("all")
public void testCreateTargetNodeInSomeParent() {
    Node<View<?>, Edge> parentNode = new NodeImpl<>(PARENT_NODE_ID);
    parentNode.setContent(new ViewImpl<>(mock(Object.class), Bounds.create()));
    DirectGraphCommandExecutionContext context = new DirectGraphCommandExecutionContext(definitionManager, factoryManager, new MapIndexBuilder().build(graph));
    new AddNodeCommand(parentNode).execute(context);
    new SetChildrenCommand(parentNode, sourceNode).execute(context);
    CanvasCommand<AbstractCanvasHandler> addConnector = mock(CanvasCommand.class);
    CanvasCommand<AbstractCanvasHandler> addNode = mock(CanvasCommand.class);
    CanvasCommand<AbstractCanvasHandler> setTargetNode = mock(CanvasCommand.class);
    doReturn(addConnector).when(commandFactory).addConnector(eq(sourceNode), eq(edge), Mockito.<MagnetConnection>any(), eq(SHAPE_SET_ID));
    doReturn(addNode).when(commandFactory).addChildNode(eq(parentNode), eq(targetNode), eq(SHAPE_SET_ID));
    doReturn(setTargetNode).when(commandFactory).setTargetNode(eq(targetNode), eq(edge), any());
    verifyCreateTargetNode(addConnector, addNode, setTargetNode);
}
Also used : AddNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AddNodeCommand) SetChildrenCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) MapIndexBuilder(org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndexBuilder) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) DirectGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.DirectGraphCommandExecutionContext) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 2 with SetChildrenCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand in project kie-wb-common by kiegroup.

the class ConnectorParentsMatchLevel1Tests method testConstrainedMoveEndNodeIntoParentNode.

@Test
@SuppressWarnings("unchecked")
public void testConstrainedMoveEndNodeIntoParentNode() {
    ContextualGraphCommandExecutionContext executionContext = createConstrainedExecutionContext();
    SetChildrenCommand setChildren = new SetChildrenCommand(graph.parentNode, graph.endNode);
    CommandResult<RuleViolation> result = setChildren.allow(executionContext);
    assertRuleFailedResult(result);
}
Also used : SetChildrenCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 3 with SetChildrenCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand in project kie-wb-common by kiegroup.

the class ConnectorParentsMatchLevel1Tests method testConstrainedMoveStartNodeIntoParentNode.

@Test
@SuppressWarnings("unchecked")
public void testConstrainedMoveStartNodeIntoParentNode() {
    ContextualGraphCommandExecutionContext executionContext = createConstrainedExecutionContext();
    SetChildrenCommand setChildren = new SetChildrenCommand(graph.parentNode, graph.startNode);
    CommandResult<RuleViolation> result = setChildren.allow(executionContext);
    assertRuleFailedResult(result);
}
Also used : SetChildrenCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 4 with SetChildrenCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand in project kie-wb-common by kiegroup.

the class ConnectorParentsMatchLevel1Tests method testConstrainedMoveStartIntermNodesIntoParentNode.

@Test
@SuppressWarnings("unchecked")
public void testConstrainedMoveStartIntermNodesIntoParentNode() {
    ContextualGraphCommandExecutionContext executionContext = createConstrainedExecutionContext();
    SetChildrenCommand setChildren = new SetChildrenCommand(graph.parentNode, Arrays.asList(graph.startNode, graph.intermNode));
    CommandResult<RuleViolation> result = setChildren.allow(executionContext);
    assertRuleFailedResult(result);
}
Also used : SetChildrenCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 5 with SetChildrenCommand

use of org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand in project kie-wb-common by kiegroup.

the class ConnectorParentsMatchLevel1Tests method testConstrainedMoveIntermNodeIntoParentNode.

@Test
@SuppressWarnings("unchecked")
public void testConstrainedMoveIntermNodeIntoParentNode() {
    ContextualGraphCommandExecutionContext executionContext = createConstrainedExecutionContext();
    SetChildrenCommand setChildren = new SetChildrenCommand(graph.parentNode, graph.intermNode);
    CommandResult<RuleViolation> result = setChildren.allow(executionContext);
    assertRuleFailedResult(result);
}
Also used : SetChildrenCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 SetChildrenCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand)21 ContextualGraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext)20 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)20 ContextOperationNotAllowedViolation (org.kie.workbench.common.stunner.core.rule.violations.ContextOperationNotAllowedViolation)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 DirectGraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.DirectGraphCommandExecutionContext)1 AddNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.AddNodeCommand)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)1 MapIndexBuilder (org.kie.workbench.common.stunner.core.graph.processing.index.map.MapIndexBuilder)1