use of org.kie.workbench.common.stunner.core.rule.impl.CanConnect in project kie-wb-common by kiegroup.
the class CommonLookupsTest method checkAllowedTargetDefinitionsWithNotPermittedStartConnectionRules.
@Test
@SuppressWarnings("unchecked")
public void checkAllowedTargetDefinitionsWithNotPermittedStartConnectionRules() {
this.ruleSet = new RuleSetImpl("connection-rules", new ArrayList<Rule>() {
{
add(new CanConnect(MockConnector.class.getName(), MockConnector.class.getName(), new ArrayList<CanConnect.PermittedConnection>() {
{
add(new CanConnect.PermittedConnection("not-permitted", "definition-role"));
}
}));
}
});
when(definitionAdapter.getLabels(any(MockDefinition.class))).thenReturn(Collections.singleton("definition-role"));
when(definitionSetRuleAdapter.getRuleSet(any(MockDefinitionSet.class))).thenReturn(ruleSet);
final Set<Object> targetDefinitions = lookups.getAllowedTargetDefinitions(MockDefinitionSet.class.getName(), graph, node, MockConnector.class.getName(), 0, 10);
assertTrue(targetDefinitions.isEmpty());
}
use of org.kie.workbench.common.stunner.core.rule.impl.CanConnect in project kie-wb-common by kiegroup.
the class CommonLookupsTest method checkAllowedTargetDefinitionsWithPermittedConnectionRules.
@Test
@SuppressWarnings("unchecked")
public void checkAllowedTargetDefinitionsWithPermittedConnectionRules() {
this.ruleSet = new RuleSetImpl("connection-rules", new ArrayList<Rule>() {
{
add(new CanConnect(MockConnector.class.getName(), MockConnector.class.getName(), new ArrayList<CanConnect.PermittedConnection>() {
{
add(new CanConnect.PermittedConnection("definition-role", "definition-role"));
}
}));
}
});
when(definitionAdapter.getLabels(any(MockDefinition.class))).thenReturn(Collections.singleton("definition-role"));
when(definitionSetRuleAdapter.getRuleSet(any(MockDefinitionSet.class))).thenReturn(ruleSet);
final Set<Object> targetDefinitions = lookups.getAllowedTargetDefinitions(MockDefinitionSet.class.getName(), graph, node, MockConnector.class.getName(), 0, 10);
assertEquals(1, targetDefinitions.size());
assertTrue(targetDefinitions.iterator().next() instanceof MockDefinition);
}
use of org.kie.workbench.common.stunner.core.rule.impl.CanConnect in project kie-wb-common by kiegroup.
the class CommonLookupsTest method checkAllowedTargetDefinitionsWithNotPermittedEndConnectionRules.
@Test
@SuppressWarnings("unchecked")
public void checkAllowedTargetDefinitionsWithNotPermittedEndConnectionRules() {
this.ruleSet = new RuleSetImpl("connection-rules", new ArrayList<Rule>() {
{
add(new CanConnect(MockConnector.class.getName(), MockConnector.class.getName(), new ArrayList<CanConnect.PermittedConnection>() {
{
add(new CanConnect.PermittedConnection("definition-role", "not-permitted"));
}
}));
}
});
when(definitionAdapter.getLabels(any(MockDefinition.class))).thenReturn(Collections.singleton("definition-role"));
when(definitionSetRuleAdapter.getRuleSet(any(MockDefinitionSet.class))).thenReturn(ruleSet);
final Set<Object> targetDefinitions = lookups.getAllowedTargetDefinitions(MockDefinitionSet.class.getName(), graph, node, MockConnector.class.getName(), 0, 10);
assertTrue(targetDefinitions.isEmpty());
}
Aggregations