use of org.kie.workbench.common.stunner.core.rule.RuleViolations in project kie-wb-common by kiegroup.
the class CardinalityEvaluationHandlerTest method testMinOneFailed1.
@Test
public void testMinOneFailed1() {
when(context.getCandidateCount()).thenReturn(1);
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.DELETE));
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 CardinalityEvaluationHandlerTest method testMaxOneSuccess.
@Test
public void testMaxOneSuccess() {
when(context.getCandidateCount()).thenReturn(0);
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.ADD));
RuleViolations violations = tested.evaluate(RULE_MAX_1, 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 ConnectionEvaluationHandlerTest method testEvaluateSuccess2.
@Test
public void testEvaluateSuccess2() {
final Set<String> sourceRoles = new HashSet<String>(1) {
{
add("r2");
}
};
final Set<String> targetRoles = new HashSet<String>(1) {
{
add("o2");
}
};
when(context.getConnectorRole()).thenReturn(EDGE_ID);
when(context.getSourceRoles()).thenReturn(Optional.of(sourceRoles));
when(context.getTargetRoles()).thenReturn(Optional.of(targetRoles));
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 ConnectionEvaluationHandlerTest method testEvaluateSuccess1.
@Test
public void testEvaluateSuccess1() {
final Set<String> sourceRoles = new HashSet<String>(1) {
{
add("r1");
}
};
final Set<String> targetRoles = new HashSet<String>(1) {
{
add("o1");
}
};
when(context.getConnectorRole()).thenReturn(EDGE_ID);
when(context.getSourceRoles()).thenReturn(Optional.of(sourceRoles));
when(context.getTargetRoles()).thenReturn(Optional.of(targetRoles));
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 ConnectorCardinalityEvaluationHandlerTest method testEvaluateInMinOneSucess.
@Test
@SuppressWarnings("unchecked")
public void testEvaluateInMinOneSucess() {
when(evalUtils.countEdges(anyString(), any(List.class))).thenReturn(0);
when(context.getDirection()).thenReturn(EdgeCardinalityContext.Direction.INCOMING);
when(context.getOperation()).thenReturn(Optional.of(CardinalityContext.Operation.ADD));
RuleViolations violations = tested.evaluate(RULE_IN_MIN_1, context);
assertNotNull(violations);
assertFalse(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext());
}
Aggregations