use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class DockNodeCommandTest method testExecute.
@Test
@SuppressWarnings("unchecked")
public void testExecute() {
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.INFO, result.getType());
assertFalse(parent.getOutEdges().isEmpty());
assertFalse(candidate.getInEdges().isEmpty());
Edge edge = (Edge) parent.getOutEdges().get(0);
assertTrue(edge.getContent() instanceof Dock);
assertEquals(parent, edge.getSourceNode());
assertEquals(candidate, edge.getTargetNode());
verify(graphIndex, times(1)).addEdge(eq(edge));
verify(graphIndex, times(0)).addNode(any(Node.class));
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class SetChildNodeCommandTest method testExecute.
@Test
@SuppressWarnings("unchecked")
public void testExecute() {
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.INFO, result.getType());
assertFalse(parent.getOutEdges().isEmpty());
assertFalse(candidate.getInEdges().isEmpty());
Edge edge = (Edge) parent.getOutEdges().get(0);
assertTrue(edge.getContent() instanceof Child);
assertEquals(parent, edge.getSourceNode());
assertEquals(candidate, edge.getTargetNode());
verify(graphIndex, times(1)).addEdge(eq(edge));
verify(graphIndex, times(0)).addNode(any(Node.class));
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class SetChildNodeCommandTest method testNotAllowed.
@Test
@SuppressWarnings("unchecked")
public void testNotAllowed() {
final RuleViolations FAILED_VIOLATIONS = new DefaultRuleViolations().addViolation(new ContainmentRuleViolation(graph.getUUID(), PARENT_UUID));
when(ruleManager.evaluate(any(RuleSet.class), any(RuleEvaluationContext.class))).thenReturn(FAILED_VIOLATIONS);
CommandResult<RuleViolation> result = tested.allow(graphCommandExecutionContext);
assertEquals(CommandResult.Type.ERROR, result.getType());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class SetChildNodeCommandTest method testExecuteCheckFailed.
@Test
@SuppressWarnings("unchecked")
public void testExecuteCheckFailed() {
final RuleViolations FAILED_VIOLATIONS = new DefaultRuleViolations().addViolation(new ContainmentRuleViolation(graph.getUUID(), PARENT_UUID));
when(ruleManager.evaluate(any(RuleSet.class), any(RuleEvaluationContext.class))).thenReturn(FAILED_VIOLATIONS);
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.ERROR, result.getType());
assertTrue(parent.getOutEdges().isEmpty());
assertTrue(candidate.getInEdges().isEmpty());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class SetConnectionTargetNodeCommandTest method testExecuteOnlyConnectionsHasBeenChanged.
@Test
@SuppressWarnings("unchecked")
public void testExecuteOnlyConnectionsHasBeenChanged() {
when(edge.getTargetNode()).thenReturn(node);
MagnetConnection connection = MagnetConnection.Builder.at(MAGNETX, MAGNETY);
tested = new SetConnectionTargetNodeCommand(node, edge, connection);
CommandResult<RuleViolation> result = tested.execute(graphCommandExecutionContext);
assertEquals(CommandResult.Type.INFO, result.getType());
verify(ruleManager, never()).evaluate(eq(ruleSet), any(RuleEvaluationContext.class));
verify(edgeContent, times(1)).setTargetConnection(eq(connection));
verify(edgeContent, never()).setSourceConnection(any(Connection.class));
assertEquals(targetMagnet.get(), tested.lastConnection);
}
Aggregations