use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class SingleConnectorPerTypeGraphRuleTest method checkCompleteConnectionDefinitionTriggersCheck.
@Test
@SuppressWarnings("unchecked")
public void checkCompleteConnectionDefinitionTriggersCheck() {
final Node source = mock(Node.class);
final Node target = mock(Node.class);
when(context.getSource()).thenReturn(Optional.of(source));
when(context.getTarget()).thenReturn(Optional.of(target));
when(context.getConnector()).thenReturn(connector);
final RuleViolations result = check.evaluate(rule, context);
assertNotNull(result);
assertFalse(result.violations().iterator().hasNext());
verify(check).isConnectionAlreadyFormed(any(Node.class), any(Node.class), any(Edge.class));
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class SingleConnectorPerTypeGraphRuleTest method checkHasExistingConnection.
@Test
@SuppressWarnings("unchecked")
public void checkHasExistingConnection() {
final Node node1 = new NodeImpl<>("node1");
final Node node2 = new NodeImpl<>("node2");
final Edge existingConnector = new EdgeImpl<>("edge1");
final ViewConnector existingConnectorView = mock(ViewConnector.class);
existingConnector.setContent(existingConnectorView);
when(existingConnectorView.getDefinition()).thenReturn(new Definition());
node1.getOutEdges().add(existingConnector);
node2.getInEdges().add(existingConnector);
existingConnector.setSourceNode(node1);
existingConnector.setTargetNode(node2);
graph.addNode(node1);
graph.addNode(node2);
when(context.getSource()).thenReturn(Optional.of(node1));
when(context.getTarget()).thenReturn(Optional.of(node2));
when(context.getConnector()).thenReturn(connector);
final RuleViolations result = check.evaluate(rule, context);
assertNotNull(result);
assertTrue(result.violations().iterator().hasNext());
final RuleViolation violation = result.violations().iterator().next();
assertNotNull(violation);
assertTrue(violation.getArguments().isPresent());
assertEquals(1, violation.getArguments().get().length);
assertEquals(SingleConnectorPerTypeGraphRule.ERROR_MESSAGE, violation.getArguments().get()[0]);
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class GraphConnectionEvaluationHandlerTest method testEvaluateSuccess1.
@Test
public void testEvaluateSuccess1() {
final RuleViolations violations = tested.evaluate(RULE, context);
assertNotNull(violations);
assertFalse(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class GraphConnectionEvaluationHandlerTest method testEvaluateFailed1.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateFailed1() {
when(context.getSource()).thenReturn(Optional.of(candidate));
when(context.getTarget()).thenReturn(Optional.of(parent));
final RuleViolations violations = tested.evaluate(RULE, context);
assertNotNull(violations);
assertTrue(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class NodeContainmentEvaluationHandlerTest method testEvaluateSuccess.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateSuccess() {
when(context.getCandidate()).thenReturn(candidate);
final RuleViolations violations = tested.evaluate(RULE, context);
assertNotNull(violations);
assertFalse(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext());
}
Aggregations