@Test @SuppressWarnings("unchecked") public void testAcceptSuccess() { when(context.getParent()).thenReturn(parent); when(context.getCandidate()).thenReturn(candidate); final boolean accepts = tested.accepts(RULE, context); assertTrue(accepts); }
@Test @SuppressWarnings("unchecked") public void testAcceptFailed() { when(context.getParent()).thenReturn(element); when(context.getCandidate()).thenReturn(candidate); final boolean accepts = tested.accepts(RULE, context); assertFalse(accepts); }
@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()); } }
@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()); }
@Override public RuleViolations evaluate(final CanDock rule, final NodeDockingContext context) { final Node<? extends Definition<?>, ? extends Edge> target = context.getCandidate(); final Set<String> parentLabels = evalUtils.getLabels(context.getParent()); final Set<String> candidateLabels = evalUtils.getLabels(target); final DefaultRuleViolations result = new DefaultRuleViolations(); result.addViolations( dockingHandler .evaluate(rule, RuleContextBuilder.DomainContexts.docking(parentLabels, candidateLabels)) ); return GraphEvaluationHandlerUtils.addViolationsSourceUUID(target.getUUID(), result); } }
public static void verifyDocking(final NodeDockingContext context, final Element<? extends Definition<?>> parent, final Node<? extends Definition<?>, ? extends Edge> candidate) { assertNotNull(context); final Element<? extends Definition<?>> source = context.getParent(); final Node<? extends Definition<?>, ? extends Edge> target = context.getCandidate(); assertNotNull(source); assertNotNull(target); assertEquals(parent, source); assertEquals(candidate, target); }