use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchContainmentHandlerTest method testEvaluateParentSuccess.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateParentSuccess() {
when(ruleExtension.getTypeArguments()).thenReturn(new Class[] { ParentDefinition.class });
when(containmentContext.getCandidate()).thenReturn(nodeA);
when(containmentContext.getParent()).thenReturn(parentNode);
graphHandler.addEdge(connector, nodeA).connectTo(connector, nodeB);
final RuleViolations violations = tested.evaluate(ruleExtension, containmentContext);
assertNotNull(violations);
assertFalse(violations.violations(Violation.Type.ERROR).iterator().hasNext());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchContainmentHandlerTest method testEvaluateParentFailed.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateParentFailed() {
when(ruleExtension.getTypeArguments()).thenReturn(new Class[] { ParentDefinition.class });
when(containmentContext.getCandidate()).thenReturn(nodeA);
when(containmentContext.getParent()).thenReturn(parentNode);
graphHandler.addEdge(connector, nodeA).connectTo(connector, nodeC);
final RuleViolations violations = tested.evaluate(ruleExtension, containmentContext);
assertNotNull(violations);
assertTrue(violations.violations(Violation.Type.ERROR).iterator().hasNext());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class AbstractGraphRuleHandlerTest method mockWithViolations.
protected RuleViolations mockWithViolations() {
RuleViolation v1 = mock(RuleViolation.class);
when(v1.getViolationType()).thenReturn(RuleViolation.Type.ERROR);
RuleViolations violations = mock(RuleViolations.class);
List<RuleViolation> result = new ArrayList<RuleViolation>(1) {
{
add(v1);
}
};
when(violations.violations(eq(RuleViolation.Type.ERROR))).thenReturn(result);
return violations;
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class CardinalityEvaluationHandlerTest method testMaxOneFailed1.
@Test
public void testMaxOneFailed1() {
when(context.getCandidateCount()).thenReturn(1);
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.ADD));
RuleViolations violations = tested.evaluate(RULE_MAX_1, 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 CardinalityEvaluationHandlerTest method testMinOneSuccess.
@Test
public void testMinOneSuccess() {
when(context.getCandidateCount()).thenReturn(0);
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.ADD));
RuleViolations violations = tested.evaluate(RULE_MIN_1, context);
assertNotNull(violations);
assertFalse(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext());
}
Aggregations