use of org.kie.workbench.common.stunner.core.rule.ext.RuleExtension in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchHandlerTest method testAccept.
@Test(expected = IllegalArgumentException.class)
public void testAccept() {
final RuleExtension ruleExtension = mock(RuleExtension.class);
when(ruleExtension.getArguments()).thenReturn(new String[] { "parentType" });
final RuleEvaluationContext context = mock(RuleEvaluationContext.class);
assertTrue(tested.accepts(ruleExtension, context));
verify(multiHandler, times(1)).accepts(eq(ruleExtension), eq(context));
}
use of org.kie.workbench.common.stunner.core.rule.ext.RuleExtension in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchHandlerTest method testEvaluateNoParentType.
@Test(expected = IllegalArgumentException.class)
public void testEvaluateNoParentType() {
final RuleExtension ruleExtension = mock(RuleExtension.class);
when(ruleExtension.getArguments()).thenReturn(new String[] {});
final RuleEvaluationContext context = mock(RuleEvaluationContext.class);
tested.evaluate(ruleExtension, context);
}
use of org.kie.workbench.common.stunner.core.rule.ext.RuleExtension in project kie-wb-common by kiegroup.
the class RuleManagerImplTest method setup.
@Before
public void setup() throws Exception {
rule1 = new CanContain("r1", "r1-cId", new HashSet<String>(2) {
{
add("role1");
add("role2");
}
});
rule2 = new CanContain("r2", "r2-cId", new HashSet<String>(2) {
{
add("role1");
add("role2");
}
});
ruleEvaluationContext = RuleContextBuilder.DomainContexts.containment(Collections.singleton("r1-cId"), new HashSet<String>(1) {
{
add("r2-cId");
}
});
ruleViolation1 = new RuleViolationImpl("error - v1");
ruleViolation2 = new RuleViolationImpl("error - v2");
ruleViolation3 = new RuleViolationImpl("error - v3");
ruleViolations1 = new DefaultRuleViolations().addViolation(ruleViolation1);
ruleViolations2 = new DefaultRuleViolations().addViolation(ruleViolation2);
ruleViolations3 = new DefaultRuleViolations().addViolation(ruleViolation3);
ruleExtension = new RuleExtension("re1", "cId").setHandlerType(RuleExtensionHandler.class);
ruleSet = new RuleSetImpl("rs1", new ArrayList<Rule>(2) {
{
add(rule1);
add(rule2);
add(ruleExtension);
}
});
handlers.add(handler1);
handlers.add(handler2);
when(registryFactory.newRuleHandlerRegistry()).thenReturn(registry);
when(registry.getHandlersByContext(any(Class.class))).thenReturn(handlers);
when(registry.getExtensionHandler(eq(RuleExtensionHandler.class))).thenReturn(extensionHandler);
when(handler1.getRuleType()).thenReturn(CanContain.class);
when(handler1.getContextType()).thenReturn(ContainmentContext.class);
when(handler2.getRuleType()).thenReturn(CanContain.class);
when(handler2.getContextType()).thenReturn(ContainmentContext.class);
when(extensionHandler.getRuleType()).thenReturn(RuleExtension.class);
when(extensionHandler.getContextType()).thenReturn(ContainmentContext.class);
tested = new RuleManagerImpl(registryFactory);
}
use of org.kie.workbench.common.stunner.core.rule.ext.RuleExtension in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchHandlerTest method testAcceptNoParentType.
@Test(expected = IllegalArgumentException.class)
public void testAcceptNoParentType() {
final RuleExtension ruleExtension = mock(RuleExtension.class);
when(ruleExtension.getArguments()).thenReturn(new String[] {});
final RuleEvaluationContext context = mock(RuleEvaluationContext.class);
tested.accepts(ruleExtension, context);
}
use of org.kie.workbench.common.stunner.core.rule.ext.RuleExtension in project kie-wb-common by kiegroup.
the class ConnectorParentsMatchHandlerTest method testEvaluate.
@Test(expected = IllegalArgumentException.class)
public void testEvaluate() {
final RuleExtension ruleExtension = mock(RuleExtension.class);
when(ruleExtension.getArguments()).thenReturn(new String[] { "parentType" });
final RuleEvaluationContext context = mock(RuleEvaluationContext.class);
assertEquals(ruleViolations, tested.evaluate(ruleExtension, context));
verify(multiHandler, times(1)).evaluate(eq(ruleExtension), eq(context));
}
Aggregations