Search in sources :

Example 6 with ContextualGraphCommandExecutionContext

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

the class ConnectorParentsMatchLevel1Tests method testSetEdge1TargetAsEndNode.

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

Example 7 with ContextualGraphCommandExecutionContext

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

the class MultipleEvaluationContextStatesTest method testExecuteShortcutWithRules.

@Test
@SuppressWarnings("unchecked")
public void testExecuteShortcutWithRules() {
    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 8 with ContextualGraphCommandExecutionContext

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

the class MultipleEvaluationContextStatesTest method createExecutionContext.

@SuppressWarnings("unchecked")
private ContextualGraphCommandExecutionContext createExecutionContext() {
    EdgeOccurrences rule1 = new EdgeOccurrences("restrictEdge1InEdgesCount", "edgeBeanId", "endNodeBeanLabel", EdgeCardinalityContext.Direction.INCOMING, 0, 1);
    graphTestHandler.ruleSet.getRules().add(rule1);
    CanConnect connectionRule = new CanConnect("allowConnectionsForEdge1", "edgeBeanId", new Lists.Builder<CanConnect.PermittedConnection>().add(new CanConnect.PermittedConnection("all", "all")).build());
    graphTestHandler.ruleSet.getRules().add(connectionRule);
    RuleManager ruleManager = graphTestHandler.createRuleManagerImplementation();
    return new ContextualGraphCommandExecutionContext(graphTestHandler.getDefinitionManager(), graphTestHandler.getFactoryManager(), ruleManager, graphTestHandler.graphIndex, graphTestHandler.ruleSet);
}
Also used : EdgeOccurrences(org.kie.workbench.common.stunner.core.rule.impl.EdgeOccurrences) Lists(org.kie.soup.commons.util.Lists) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) CanConnect(org.kie.workbench.common.stunner.core.rule.impl.CanConnect)

Example 9 with ContextualGraphCommandExecutionContext

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

the class ConnectorParentsMatchLevel2Tests method testSetEdge1TargetAsEndNode.

// CONNECTION contexts
@Test
@SuppressWarnings("unchecked")
public void testSetEdge1TargetAsEndNode() {
    SetConnectionTargetNodeCommand setTarget = new SetConnectionTargetNodeCommand(graph.endNode, graph.edge1);
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    CommandResult<RuleViolation> result = setTarget.allow(executionContext);
    assertSuccessfullResult(result);
}
Also used : SetConnectionTargetNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetConnectionTargetNodeCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) ContextualGraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.ContextualGraphCommandExecutionContext) Test(org.junit.Test)

Example 10 with ContextualGraphCommandExecutionContext

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

the class ConnectorParentsMatchLevel2Tests method testSetEdge1TargetAsNodeA.

@Test
@SuppressWarnings("unchecked")
public void testSetEdge1TargetAsNodeA() {
    SetConnectionTargetNodeCommand setTarget = new SetConnectionTargetNodeCommand(graph.nodeA, graph.edge1);
    ContextualGraphCommandExecutionContext executionContext = createExecutionContext();
    CommandResult<RuleViolation> result = setTarget.allow(executionContext);
    assertSuccessfullResult(result);
}
Also used : SetConnectionTargetNodeCommand(org.kie.workbench.common.stunner.core.graph.command.impl.SetConnectionTargetNodeCommand) 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