use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class ConnectorCardinalityEvaluationHandlerTest method testEvaluateInMaxOneFailed.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateInMaxOneFailed() {
when(evalUtils.countEdges(anyString(), any(List.class))).thenReturn(1);
when(context.getDirection()).thenReturn(EdgeCardinalityContext.Direction.INCOMING);
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.ADD));
RuleViolations violations = tested.evaluate(RULE_IN_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 ElementCardinalityEvaluationHandlerTest method testMax0EvaluateSuccess.
@Test
@SuppressWarnings("unchecked")
public void testMax0EvaluateSuccess() {
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.empty());
when(context.getOperation()).thenReturn(Optional.empty());
final RuleViolations violations = tested.evaluate(RULE_MAX_0, 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 ElementCardinalityEvaluationHandlerTest method testEvaluateSuccessAgain.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateSuccessAgain() {
final Map<String, Integer> count = new HashMap<String, Integer>(2) {
{
put(CANDIDATE_ROLE1, 100);
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.ADD));
final RuleViolations violations = tested.evaluate(RULE_NO_LIMIT, 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 ElementCardinalityEvaluationHandlerTest method testMin1EvaluateFailed.
@Test
@SuppressWarnings("unchecked")
public void testMin1EvaluateFailed() {
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.empty());
when(context.getOperation()).thenReturn(Optional.empty());
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 ElementCardinalityEvaluationHandlerTest method testEvaluateSuccess.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateSuccess() {
final Map<String, Integer> count = new HashMap<String, Integer>(2) {
{
put(CANDIDATE_ROLE1, 0);
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.ADD));
final RuleViolations violations = tested.evaluate(RULE_NO_LIMIT, context);
assertNotNull(violations);
assertFalse(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext());
}
Aggregations