@Test @SuppressWarnings("unchecked") public void testAccepts() { when(context.getDirection()).thenReturn(EdgeCardinalityContext.Direction.INCOMING); assertTrue(tested.accepts(RULE_IN_NO_LIMIT, context)); when(context.getDirection()).thenReturn(EdgeCardinalityContext.Direction.OUTGOING); assertFalse(tested.accepts(RULE_IN_NO_LIMIT, context)); when(context.getDirection()).thenReturn(EdgeCardinalityContext.Direction.INCOMING); when(definitionAdapter.getId(eq(edgeDefinition))).thenReturn(DefinitionId.build("anotherId")); assertFalse(tested.accepts(RULE_IN_NO_LIMIT, context)); }
@Override @SuppressWarnings("unchecked") 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); return edgeCardinalityEvaluationHandler.accepts(rule, RuleEvaluationContextBuilder.DomainContexts.edgeCardinality(candidateRoles, edgeId, -1, context.getDirection(), context.getOperation())); }
ConnectorCardinalityEvaluationHandler implements RuleEvaluationHandler<EdgeOccurrences, ConnectorCardinalityContext> { @Override @SuppressWarnings("unchecked") 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); return edgeCardinalityEvaluationHandler.accepts(rule, RuleEvaluationContextBuilder.DomainContexts.edgeCardinality(candidateRoles, edgeId, -1, context.getDirection(), context.getOperation())); } }
ConnectorCardinalityEvaluationHandler implements RuleEvaluationHandler<EdgeOccurrences, ConnectorCardinalityContext> { @Override @SuppressWarnings("unchecked") 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); return edgeCardinalityEvaluationHandler.accepts(rule, RuleEvaluationContextBuilder.DomainContexts.edgeCardinality(candidateRoles, edgeId, -1, context.getDirection(), context.getOperation())); } @Inject  ConnectorCardinalityEvaluationHandler(final DefinitionManager definitionManager,
                                                 final EdgeCardinalityEvaluationHandler edgeCardinalityEvaluationHandler);   ConnectorCardinalityEvaluationHandler(final GraphEvaluationHandlerUtils evalUtils,
                                          final EdgeCardinalityEvaluationHandler edgeCardinalityEvaluationHandler); }
ConnectorCardinalityEvaluationHandler implements RuleEvaluationHandler<EdgeOccurrences, ConnectorCardinalityContext> { @Override @SuppressWarnings("unchecked") 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); return edgeCardinalityEvaluationHandler.accepts(rule, RuleEvaluationContextBuilder.DomainContexts.edgeCardinality(candidateRoles, edgeId, -1, context.getDirection(), context.getOperation())); } @Inject  ConnectorCardinalityEvaluationHandler(final DefinitionManager definitionManager,
                                                 final EdgeCardinalityEvaluationHandler edgeCardinalityEvaluationHandler);   ConnectorCardinalityEvaluationHandler(final GraphEvaluationHandlerUtils evalUtils,
                                          final EdgeCardinalityEvaluationHandler edgeCardinalityEvaluationHandler); @Override Class<EdgeOccurrences> getRuleType(); @Override Class<ConnectorCardinalityContext> getContextType(); @Override @SuppressWarnings("unchecked") boolean accepts(final EdgeOccurrences rule,
                           final ConnectorCardinalityContext context); @Override @SuppressWarnings("unchecked") RuleViolations evaluate(final EdgeOccurrences rule,
                                   final ConnectorCardinalityContext context); }
ConnectorCardinalityEvaluationHandler implements RuleEvaluationHandler<EdgeOccurrences, ConnectorCardinalityContext> { @Override @SuppressWarnings("unchecked") 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); return edgeCardinalityEvaluationHandler.accepts(rule, RuleEvaluationContextBuilder.DomainContexts.edgeCardinality(candidateRoles, edgeId, -1, context.getDirection(), context.getOperation())); } @Inject  ConnectorCardinalityEvaluationHandler(final DefinitionManager definitionManager,
                                                 final EdgeCardinalityEvaluationHandler edgeCardinalityEvaluationHandler);   ConnectorCardinalityEvaluationHandler(final GraphEvaluationHandlerUtils evalUtils,
                                          final EdgeCardinalityEvaluationHandler edgeCardinalityEvaluationHandler); @Override Class<EdgeOccurrences> getRuleType(); @Override Class<ConnectorCardinalityContext> getContextType(); @Override @SuppressWarnings("unchecked") boolean accepts(final EdgeOccurrences rule,
                           final ConnectorCardinalityContext context); @Override @SuppressWarnings("unchecked") RuleViolations evaluate(final EdgeOccurrences rule,
                                   final ConnectorCardinalityContext context);  }