@Test public void testEvaluateSuccess1() { final RuleViolations violations = tested.evaluate(RULE, context); assertNotNull(violations); assertFalse(violations.violations(RuleViolation.Type.ERROR).iterator().hasNext()); }
@Override @SuppressWarnings("unchecked") public RuleViolations evaluate(final CanConnect rule, final GraphConnectionContext context) { final GraphEvaluationState.ConnectionState connectionState = context.getState().getConnectionState(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); final Node<? extends View<?>, ? extends Edge> source = (Node<? extends View<?>, ? extends Edge>) context.getSource() .orElse(connectionState.getSource(connector)); final Node<? extends View<?>, ? extends Edge> target = (Node<? extends View<?>, ? extends Edge>) context.getTarget() .orElse(connectionState.getTarget(connector)); if (source == null || target == null) { return new DefaultRuleViolations(); } final Set<String> edgeLabels = evalUtils.getLabels(connector); final Optional<Set<String>> sourceLabels = Optional.of(evalUtils.getLabels(source)); final Optional<Set<String>> targetLabels = Optional.of(evalUtils.getLabels(target)); final DefaultRuleViolations result = new DefaultRuleViolations(); edgeLabels.stream() .filter(pr -> rule.getRole().equals(pr)) .forEach(pr -> result.addViolations(connectionEvaluationHandler .evaluate(rule, RuleEvaluationContextBuilder.DomainContexts.connection(pr, sourceLabels, targetLabels)))); return GraphEvaluationHandlerUtils.addViolationsSourceUUID(connector.getUUID(), result); }
GraphConnectionEvaluationHandler implements RuleEvaluationHandler<CanConnect, GraphConnectionContext> { @Override @SuppressWarnings("unchecked") public RuleViolations evaluate(final CanConnect rule, final GraphConnectionContext context) { final GraphEvaluationState.ConnectionState connectionState = context.getState().getConnectionState(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); final Node<? extends View<?>, ? extends Edge> source = (Node<? extends View<?>, ? extends Edge>) context.getSource() .orElse(connectionState.getSource(connector)); final Node<? extends View<?>, ? extends Edge> target = (Node<? extends View<?>, ? extends Edge>) context.getTarget() .orElse(connectionState.getTarget(connector)); if (source == null || target == null) { return new DefaultRuleViolations(); } final Set<String> edgeLabels = evalUtils.getLabels(connector); final Optional<Set<String>> sourceLabels = Optional.of(evalUtils.getLabels(source)); final Optional<Set<String>> targetLabels = Optional.of(evalUtils.getLabels(target)); final DefaultRuleViolations result = new DefaultRuleViolations(); edgeLabels.stream() .filter(pr -> rule.getRole().equals(pr)) .forEach(pr -> result.addViolations(connectionEvaluationHandler .evaluate(rule, RuleEvaluationContextBuilder.DomainContexts.connection(pr, sourceLabels, targetLabels)))); return GraphEvaluationHandlerUtils.addViolationsSourceUUID(connector.getUUID(), result); } }
GraphConnectionEvaluationHandler implements RuleEvaluationHandler<CanConnect, GraphConnectionContext> { @Override @SuppressWarnings("unchecked") public RuleViolations evaluate(final CanConnect rule, final GraphConnectionContext context) { final GraphEvaluationState.ConnectionState connectionState = context.getState().getConnectionState(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); final Node<? extends View<?>, ? extends Edge> source = (Node<? extends View<?>, ? extends Edge>) context.getSource() .orElse(connectionState.getSource(connector)); final Node<? extends View<?>, ? extends Edge> target = (Node<? extends View<?>, ? extends Edge>) context.getTarget() .orElse(connectionState.getTarget(connector)); if (source == null || target == null) { return new DefaultRuleViolations(); } final Set<String> edgeLabels = evalUtils.getLabels(connector); final Optional<Set<String>> sourceLabels = Optional.of(evalUtils.getLabels(source)); final Optional<Set<String>> targetLabels = Optional.of(evalUtils.getLabels(target)); final DefaultRuleViolations result = new DefaultRuleViolations(); edgeLabels.stream() .filter(pr -> rule.getRole().equals(pr)) .forEach(pr -> result.addViolations(connectionEvaluationHandler .evaluate(rule, RuleEvaluationContextBuilder.DomainContexts.connection(pr, sourceLabels, targetLabels)))); return GraphEvaluationHandlerUtils.addViolationsSourceUUID(connector.getUUID(), result); } protected  GraphConnectionEvaluationHandler(); @Inject  GraphConnectionEvaluationHandler(final DefinitionManager definitionManager,
                                            final ConnectionEvaluationHandler connectionEvaluationHandler); }
GraphConnectionEvaluationHandler implements RuleEvaluationHandler<CanConnect, GraphConnectionContext> { @Override @SuppressWarnings("unchecked") public RuleViolations evaluate(final CanConnect rule, final GraphConnectionContext context) { final GraphEvaluationState.ConnectionState connectionState = context.getState().getConnectionState(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); final Node<? extends View<?>, ? extends Edge> source = (Node<? extends View<?>, ? extends Edge>) context.getSource() .orElse(connectionState.getSource(connector)); final Node<? extends View<?>, ? extends Edge> target = (Node<? extends View<?>, ? extends Edge>) context.getTarget() .orElse(connectionState.getTarget(connector)); if (source == null || target == null) { return new DefaultRuleViolations(); } final Set<String> edgeLabels = evalUtils.getLabels(connector); final Optional<Set<String>> sourceLabels = Optional.of(evalUtils.getLabels(source)); final Optional<Set<String>> targetLabels = Optional.of(evalUtils.getLabels(target)); final DefaultRuleViolations result = new DefaultRuleViolations(); edgeLabels.stream() .filter(pr -> rule.getRole().equals(pr)) .forEach(pr -> result.addViolations(connectionEvaluationHandler .evaluate(rule, RuleEvaluationContextBuilder.DomainContexts.connection(pr, sourceLabels, targetLabels)))); return GraphEvaluationHandlerUtils.addViolationsSourceUUID(connector.getUUID(), result); } protected  GraphConnectionEvaluationHandler(); @Inject  GraphConnectionEvaluationHandler(final DefinitionManager definitionManager,
                                            final ConnectionEvaluationHandler connectionEvaluationHandler); @Override Class<CanConnect> getRuleType(); @Override Class<GraphConnectionContext> getContextType(); @Override @SuppressWarnings("unchecked") boolean accepts(final CanConnect rule,
                           final GraphConnectionContext context); @Override @SuppressWarnings("unchecked") RuleViolations evaluate(final CanConnect rule,
                                   final GraphConnectionContext context); }
GraphConnectionEvaluationHandler implements RuleEvaluationHandler<CanConnect, GraphConnectionContext> { @Override @SuppressWarnings("unchecked") public RuleViolations evaluate(final CanConnect rule, final GraphConnectionContext context) { final GraphEvaluationState.ConnectionState connectionState = context.getState().getConnectionState(); final Edge<? extends View<?>, ? extends Node> connector = context.getConnector(); final Node<? extends View<?>, ? extends Edge> source = (Node<? extends View<?>, ? extends Edge>) context.getSource() .orElse(connectionState.getSource(connector)); final Node<? extends View<?>, ? extends Edge> target = (Node<? extends View<?>, ? extends Edge>) context.getTarget() .orElse(connectionState.getTarget(connector)); if (source == null || target == null) { return new DefaultRuleViolations(); } final Set<String> edgeLabels = evalUtils.getLabels(connector); final Optional<Set<String>> sourceLabels = Optional.of(evalUtils.getLabels(source)); final Optional<Set<String>> targetLabels = Optional.of(evalUtils.getLabels(target)); final DefaultRuleViolations result = new DefaultRuleViolations(); edgeLabels.stream() .filter(pr -> rule.getRole().equals(pr)) .forEach(pr -> result.addViolations(connectionEvaluationHandler .evaluate(rule, RuleEvaluationContextBuilder.DomainContexts.connection(pr, sourceLabels, targetLabels)))); return GraphEvaluationHandlerUtils.addViolationsSourceUUID(connector.getUUID(), result); } protected  GraphConnectionEvaluationHandler(); @Inject  GraphConnectionEvaluationHandler(final DefinitionManager definitionManager,
                                            final ConnectionEvaluationHandler connectionEvaluationHandler); @Override Class<CanConnect> getRuleType(); @Override Class<GraphConnectionContext> getContextType(); @Override @SuppressWarnings("unchecked") boolean accepts(final CanConnect rule,
                           final GraphConnectionContext context); @Override @SuppressWarnings("unchecked") RuleViolations evaluate(final CanConnect rule,
                                   final GraphConnectionContext context);  }