@Inject public NodeDockingEvaluationHandler(final DefinitionManager definitionManager, final DockingEvaluationHandler dockingHandler) { this.dockingHandler = dockingHandler; this.evalUtils = new GraphEvaluationHandlerUtils(definitionManager); }
@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())); }
@Override public boolean accepts(final CanContain rule, final NodeContainmentContext context) { final Set<String> parenteLabels = 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. return containmentHandler.accepts(rule, RuleContextBuilder.DomainContexts.containment(parenteLabels, Collections.emptySet())); }
@Test public void testEvaluateContainmentContextOnce() { tested.evaluate(ruleSet, containmentContext); tested.evaluate(ruleSet, containmentContext); verify(ruleSet, times(1)).getRules(); verify(containmentHandler, times(2)).evaluate(eq(containmentRule), eq(containmentContext)); verify(connectionHandler, never()).evaluate(any(CanConnect.class), any(ConnectionContext.class)); }
@Override public boolean accepts(final EdgeOccurrences rule, final ConnectorCardinalityContext context) { final Edge<? extends View<?>, Node> edge = context.getEdge(); final Element<? extends View<?>> candidate = context.getCandidate(); final String edgeId = evalUtils.getElementDefinitionId(edge); final Set<String> candidateRoles = evalUtils.getLabels(candidate); // Take into account that there is no need to provide the candidate count value, as not necessary // just to check if the handler accepts the runtime rule and candidates. return edgeCardinalityEvaluationHandler.accepts(rule, RuleContextBuilder.DomainContexts.edgeCardinality(candidateRoles, edgeId, -1, context.getDirection(), context.getOperation())); }
@Override @SuppressWarnings("unchecked") public boolean accepts(final Occurrences rule, final ElementCardinalityContext context) { if (context.getCandidate().isPresent()) { final Set<String> candidateLabels = evalUtils.getLabels(context.getCandidate().get()); return cardinalityEvaluationHandler .accepts(rule, RuleContextBuilder.DomainContexts.cardinality( candidateLabels, -1, context.getOperation())); } return true; }
@Before @SuppressWarnings("unchecked") public void setup() throws Exception { super.setup(); tested = spy(new ElementCardinalityEvaluationHandler(definitionManager, HANDLER)); }
@Before @SuppressWarnings("unchecked") public void setup() throws Exception { super.setup(); when(context.getParent()).thenReturn(parent); tested = new NodeDockingEvaluationHandler(definitionManager, HANDLER); }
@Before @SuppressWarnings("unchecked") public void setup() throws Exception { super.setup(); when(context.getParent()).thenReturn(element); tested = new NodeContainmentEvaluationHandler(definitionManager, CONTAINMENT_HANDLER); }
public static RuleViolations addViolationsSourceUUID(final String uuid, final RuleViolations result) { result.violations().forEach(v -> addViolationSourceUUID(uuid, v)); return result; }
@Before public void setup() throws Exception { tested = new ContainmentEvaluationHandler(); }
@Before public void setup() throws Exception { tested = new ConnectionEvaluationHandler(); }
@Before public void setup() throws Exception { tested = new DockingEvaluationHandler(); }
@Test public void testEvaluateConnectionContextOnce() { tested.evaluate(ruleSet, connectionContext); tested.evaluate(ruleSet, connectionContext); verify(ruleSet, times(1)).getRules(); verify(connectionHandler, times(2)).evaluate(eq(connectionRule), eq(connectionContext)); verify(containmentHandler, never()).evaluate(any(CanContain.class), any(ContainmentContext.class)); } }
@Inject public NodeContainmentEvaluationHandler(final DefinitionManager definitionManager, final ContainmentEvaluationHandler containmentHandler) { this.containmentHandler = containmentHandler; this.evalUtils = new GraphEvaluationHandlerUtils(definitionManager); }
@Inject public ConnectorParentsMatchContainmentHandler(final DefinitionManager definitionManager, final TreeWalkTraverseProcessor treeWalkTraverseProcessor) { this.definitionManager = definitionManager; this.treeWalkTraverseProcessor = treeWalkTraverseProcessor; this.evalUtils = new GraphEvaluationHandlerUtils(definitionManager); }
@Inject public ElementCardinalityEvaluationHandler(final DefinitionManager definitionManager, final CardinalityEvaluationHandler cardinalityEvaluationHandler) { this.cardinalityEvaluationHandler = cardinalityEvaluationHandler; this.evalUtils = new GraphEvaluationHandlerUtils(definitionManager); }
@Inject public ConnectorParentsMatchConnectionHandler(final DefinitionManager definitionManager) { this.definitionManager = definitionManager; this.evalUtils = new GraphEvaluationHandlerUtils(definitionManager); }
@Inject public GraphConnectionEvaluationHandler(final DefinitionManager definitionManager, final ConnectionEvaluationHandler connectionEvaluationHandler) { this.connectionEvaluationHandler = connectionEvaluationHandler; this.evalUtils = new GraphEvaluationHandlerUtils(definitionManager); }
@Inject public ConnectorCardinalityEvaluationHandler(final DefinitionManager definitionManager, final EdgeCardinalityEvaluationHandler edgeCardinalityEvaluationHandler) { this.evalUtils = new GraphEvaluationHandlerUtils(definitionManager); this.edgeCardinalityEvaluationHandler = edgeCardinalityEvaluationHandler; }