use of org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations in project kie-wb-common by kiegroup.
the class RuleExtensionMultiHandlerTest method setup.
@Before
public void setup() throws Exception {
context = RuleContextBuilder.DomainContexts.containment(Collections.singleton("id1"), Collections.emptySet());
violation1 = new RuleViolationImpl("v1");
violations1 = new DefaultRuleViolations().addViolation(violation1);
when(handler1.getRuleType()).thenReturn(RuleExtension.class);
when(handler1.getContextType()).thenReturn(ContainmentContext.class);
when(handler2.getRuleType()).thenReturn(RuleExtension.class);
when(handler2.getContextType()).thenReturn(ContainmentContext.class);
tested = new RuleExtensionMultiHandler();
tested.addHandler(handler1);
tested.addHandler(handler2);
}
use of org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations in project kie-wb-common by kiegroup.
the class SingleConnectorPerTypeGraphRule method evaluate.
@Override
@SuppressWarnings("unchecked")
public RuleViolations evaluate(final RuleExtension rule, final GraphConnectionContext context) {
final Optional<Node<? extends View<?>, ? extends Edge>> oSource = context.getSource();
final Optional<Node<? extends View<?>, ? extends Edge>> oTarget = context.getTarget();
final DefaultRuleViolations result = new DefaultRuleViolations();
// Only validate when source and target nodes are set
if (!(oSource.isPresent() && oTarget.isPresent())) {
return result;
}
final Node<? extends View<?>, ? extends Edge> source = oSource.get();
final Node<? extends View<?>, ? extends Edge> target = oTarget.get();
final Edge<? extends View<?>, ? extends Node> connector = context.getConnector();
if (isConnectionAlreadyFormed(source, target, connector)) {
result.addViolation(new RuleViolationImpl(ERROR_MESSAGE));
}
return result;
}
Aggregations