Search in sources :

Example 1 with RuleSetImpl

use of org.kie.workbench.common.stunner.core.rule.RuleSetImpl 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());
}
Also used : ArrayList(java.util.ArrayList) RuleSetImpl(org.kie.workbench.common.stunner.core.rule.RuleSetImpl) CanConnect(org.kie.workbench.common.stunner.core.rule.impl.CanConnect) Test(org.junit.Test)

Example 2 with RuleSetImpl

use of org.kie.workbench.common.stunner.core.rule.RuleSetImpl 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);
}
Also used : ArrayList(java.util.ArrayList) RuleSetImpl(org.kie.workbench.common.stunner.core.rule.RuleSetImpl) CanConnect(org.kie.workbench.common.stunner.core.rule.impl.CanConnect) Test(org.junit.Test)

Example 3 with RuleSetImpl

use of org.kie.workbench.common.stunner.core.rule.RuleSetImpl 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());
}
Also used : ArrayList(java.util.ArrayList) RuleSetImpl(org.kie.workbench.common.stunner.core.rule.RuleSetImpl) CanConnect(org.kie.workbench.common.stunner.core.rule.impl.CanConnect) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 RuleSetImpl (org.kie.workbench.common.stunner.core.rule.RuleSetImpl)3 CanConnect (org.kie.workbench.common.stunner.core.rule.impl.CanConnect)3