@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 testEvaluateFailed() { when(context.getCandidate()).thenReturn(candidate); final RuleViolations violations = tested.evaluate(RULE_INVALID, context); assertNotNull(violations); assertTrue(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext()); } }
@Override public boolean accepts(final CanDock rule, final NodeDockingContext context) { final Set<String> parentLabels = evalUtils.getLabels(context.getParent()); // As for acceptance checking, the delegated handler only needs the parent node id, no need // to calculate roles for the candidate node, so using an empty set. return dockingHandler.accepts(rule, RuleContextBuilder.DomainContexts.docking(parentLabels, Collections.emptySet())); }
@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()); }
@Before @SuppressWarnings("unchecked") public void setup() throws Exception { super.setup(); when(context.getParent()).thenReturn(parent); tested = new NodeDockingEvaluationHandler(definitionManager, HANDLER); }
@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); }
@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); }