use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class ElementCardinalityEvaluationHandlerTest method testMax0Failed.
@Test
@SuppressWarnings("unchecked")
public void testMax0Failed() {
final Map<String, Integer> count = new HashMap<String, Integer>(1) {
{
put(CANDIDATE_ROLE1, 0);
}
};
doReturn(count).when(tested).countLabels(any(Graph.class), anySet());
when(context.getCandidate()).thenReturn(Optional.of(candidate));
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.ADD));
final RuleViolations violations = tested.evaluate(RULE_MAX_0, 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 ElementCardinalityEvaluationHandlerTest method testMax0EvaluateFailed.
@Test
@SuppressWarnings("unchecked")
public void testMax0EvaluateFailed() {
final Map<String, Integer> count = new HashMap<String, Integer>(1) {
{
put(CANDIDATE_ROLE1, 1);
}
};
doReturn(count).when(tested).countLabels(any(Graph.class), anySet());
when(context.getCandidate()).thenReturn(Optional.empty());
when(context.getOperation()).thenReturn(Optional.empty());
final RuleViolations violations = tested.evaluate(RULE_MAX_0, context);
assertNotNull(violations);
assertTrue(violations.violations(RuleViolation.Type.WARNING).iterator().hasNext());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class ElementCardinalityEvaluationHandlerTest method testMin1DeleteFailed.
@Test
@SuppressWarnings("unchecked")
public void testMin1DeleteFailed() {
final Map<String, Integer> count = new HashMap<String, Integer>(2) {
{
put(CANDIDATE_ROLE1, 1);
put(CANDIDATE_ROLE2, 0);
}
};
doReturn(count).when(tested).countLabels(any(Graph.class), anySet());
when(context.getCandidate()).thenReturn(Optional.of(candidate));
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.DELETE));
final RuleViolations violations = tested.evaluate(RULE_MIN_1, context);
assertNotNull(violations);
assertTrue(violations.violations(RuleViolation.Type.WARNING).iterator().hasNext());
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class NodeContainmentEvaluationHandlerTest method testEvaluateFailed.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateFailed() {
when(context.getCandidate()).thenReturn(candidate);
final RuleViolations violations = tested.evaluate(RULE_INVALID, 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 AcyclicDirectedGraphRuleTest method checkMissingConnectionNodesDoesNotTriggerGraphWalk.
@Test
@SuppressWarnings("unchecked")
public void checkMissingConnectionNodesDoesNotTriggerGraphWalk() {
when(context.getSource()).thenReturn(Optional.empty());
when(context.getTarget()).thenReturn(Optional.empty());
when(context.getConnector()).thenReturn(connector);
when(check.getTreeWalker(any(Node.class), any(Node.class), any(Edge.class))).thenReturn(walker);
final RuleViolations result = check.evaluate(rule, context);
assertNotNull(result);
assertFalse(result.violations().iterator().hasNext());
verify(walker, never()).traverse(any(Graph.class), any(TreeTraverseCallback.class));
}
Aggregations