### Question:
ConnectorParentsMatchContainmentHandler extends AbstractParentsMatchHandler<ConnectorParentsMatchContainmentHandler, NodeContainmentContext> { @Override public RuleViolations evaluate(final RuleExtension rule, final NodeContainmentContext context) { return evaluateContainment(rule, context); } protected  ConnectorParentsMatchContainmentHandler(); @Inject  ConnectorParentsMatchContainmentHandler(final DefinitionManager definitionManager,
                                                   final TreeWalkTraverseProcessor treeWalkTraverseProcessor); @Override Class<ConnectorParentsMatchContainmentHandler> getExtensionType(); @Override Class<NodeContainmentContext> getContextType(); @Override @SuppressWarnings("unchecked") boolean accepts(final RuleExtension rule,
                           final NodeContainmentContext context); @Override RuleViolations evaluate(final RuleExtension rule,
                                   final NodeContainmentContext context);  }### Answer:
@Test @SuppressWarnings("unchecked") public void testEvaluateParentSuccess() { when(ruleExtension.getTypeArguments()).thenReturn(new Class[]{ParentDefinition.class}); when(containmentContext.getCandidates()).thenReturn(candidates); when(containmentContext.getParent()).thenReturn(parentNode); graphHandler.addEdge(connector, nodeA) .connectTo(connector, nodeB); final RuleViolations violations = tested.evaluate(ruleExtension, containmentContext); assertNotNull(violations); assertViolations(violations, true); }
@Test @SuppressWarnings("unchecked") public void testEvaluateParentFailed() { when(ruleExtension.getTypeArguments()).thenReturn(new Class[]{ParentDefinition.class}); when(containmentContext.getCandidates()).thenReturn(candidates); when(containmentContext.getParent()).thenReturn(parentNode); graphHandler.addEdge(connector, nodeA) .connectTo(connector, nodeC); final RuleViolations violations = tested.evaluate(ruleExtension, containmentContext); assertNotNull(violations); assertViolations(violations, false); }