Search in sources :

Example 21 with ContextualGraphCommandExecutionContext

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

the class ConnectorParentsMatchLevel1Tests method testAddNewEdgeAndNodeButNoParentsTypeMatch.

@Test
public void testAddNewEdgeAndNodeButNoParentsTypeMatch() {
    Command<GraphCommandExecutionContext, RuleViolation> command = addNewEdgeAndNodeIntoParent(graph.parentNode);
    ContextualGraphCommandExecutionContext executionContext = createConstrainedExecutionContext();
    CommandResult<RuleViolation> result = command.allow(executionContext);
    assertRuleFailedResult(result);
}
Also used : ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 22 with ContextualGraphCommandExecutionContext

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

the class MultipleEvaluationContextStatesTest method testAllowShortcutWithRules.

@Test
@SuppressWarnings("unchecked")
public void testAllowShortcutWithRules() {
    SafeDeleteNodeCommand deleteNodeCommand = new SafeDeleteNodeCommand(graph1Instance.intermNode);
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    CommandResult<RuleViolation> result = deleteNodeCommand.allow(executionContext);
    assertFalse(isError(result));
    assertFalse(isWarn(result));
    assertFalse(result.getViolations().iterator().hasNext());
}
Also used : SafeDeleteNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 23 with ContextualGraphCommandExecutionContext

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

the class ConnectorParentsMatchLevel2Tests method testSetEdge1SourceAsNodeB.

@Test
@SuppressWarnings("unchecked")
public void testSetEdge1SourceAsNodeB() {
    SetConnectionSourceNodeCommand setTarget = new SetConnectionSourceNodeCommand(graph.nodeB, graph.edge1);
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    CommandResult<RuleViolation> result = setTarget.allow(executionContext);
    assertRuleFailedResult(result);
}
Also used : SetConnectionSourceNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetConnectionSourceNodeCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 24 with ContextualGraphCommandExecutionContext

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

the class ConnectorParentsMatchLevel2Tests method testMoveStartNodeIntoNodeA.

// CONTAINMENT contexts
@Test
@SuppressWarnings("unchecked")
public void testMoveStartNodeIntoNodeA() {
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    SetChildrenCommand setChildren = new SetChildrenCommand(graph.nodeA, graph.startNode);
    CommandResult<RuleViolation> result = setChildren.allow(executionContext);
    assertTrue(isError(result));
    assertTrue(result.getViolations().iterator().hasNext());
    RuleViolation ruleViolation = result.getViolations().iterator().next();
    assertTrue(ruleViolation instanceof ContextOperationNotAllowedViolation);
}
Also used : SetChildrenCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand) ContextOperationNotAllowedViolation(org.kie.workbench.common.stunner.core.rule.violations.ContextOperationNotAllowedViolation) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 25 with ContextualGraphCommandExecutionContext

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

the class ConnectorParentsMatchLevel2Tests method testMoveEndNodeIntoSubProcessNode.

@Test
@SuppressWarnings("unchecked")
public void testMoveEndNodeIntoSubProcessNode() {
    SetChildrenCommand setChildren = new SetChildrenCommand(graph.subProcessNode, graph.endNode);
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    CommandResult<RuleViolation> result = setChildren.allow(executionContext);
    assertSuccessfullResult(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

ContextualGraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext)39 Test (org.junit.Test)37 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)35 SetChildrenCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SetChildrenCommand)20 SetConnectionTargetNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SetConnectionTargetNodeCommand)8 SetConnectionSourceNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SetConnectionSourceNodeCommand)5 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)2 SafeDeleteNodeCommand (org.kie.workbench.common.stunner.core.graph.command.impl.SafeDeleteNodeCommand)2 ContextOperationNotAllowedViolation (org.kie.workbench.common.stunner.core.rule.violations.ContextOperationNotAllowedViolation)2 Lists (org.kie.soup.commons.util.Lists)1 RuleExtension (org.kie.workbench.common.stunner.core.rule.ext.RuleExtension)1 CanConnect (org.kie.workbench.common.stunner.core.rule.impl.CanConnect)1 EdgeOccurrences (org.kie.workbench.common.stunner.core.rule.impl.EdgeOccurrences)1