use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class BPMNProcessVariableDeleteHandler method isVariableBoundToNode.
private boolean isVariableBoundToNode(Node node, String propertyId) {
Object content = node.getContent();
if (content instanceof Definition) {
Object nodeDefinition = ((Definition) content).getDefinition();
Collection<String> variablesName = new ArrayList();
if (nodeDefinition instanceof UserTask) {
UserTask userTask = (UserTask) nodeDefinition;
final String userTaskAssignmentsinfo = userTask.getExecutionSet().getAssignmentsinfo().getValue();
variablesName.addAll(getVariablesName(userTaskAssignmentsinfo, PROPERTY_IN_PREFIX, PROPERTY_OUT_PREFIX));
variablesName.addAll(getVariablesName(userTaskAssignmentsinfo, PROPERTY_OUT_PREFIX));
}
if ((nodeDefinition instanceof BusinessRuleTask)) {
BusinessRuleTask businessRuleTaskTask = (BusinessRuleTask) nodeDefinition;
final String businessRuleTaskAssignmentsinfo = businessRuleTaskTask.getDataIOSet().getAssignmentsinfo().getValue();
variablesName.addAll(getVariablesName(businessRuleTaskAssignmentsinfo, PROPERTY_IN_PREFIX, PROPERTY_OUT_PREFIX));
variablesName.addAll(getVariablesName(businessRuleTaskAssignmentsinfo, PROPERTY_OUT_PREFIX));
}
return variablesName.stream().filter(id -> propertyId.equals(id)).findAny().isPresent();
}
return false;
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNCommonActionsToolboxFactoryTest method testIsAllowedWhenIsNotDecisionService.
@Test
public void testIsAllowedWhenIsNotDecisionService() {
final Node node = mock(Node.class);
final Definition content = mock(Definition.class);
final Object def = mock(Object.class);
when(node.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(def);
doReturn(false).when(tested).superIsAllowed(canvasHandler, node);
final boolean actual = tested.isAllowed(canvasHandler, node);
assertFalse(actual);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNCommonActionsToolboxFactoryTest method testIsAllowed.
@Test
public void testIsAllowed() {
final Node node = mock(Node.class);
final Definition content = mock(Definition.class);
final DecisionService decisionService = mock(DecisionService.class);
when(node.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(decisionService);
final boolean actual = tested.isAllowed(canvasHandler, node);
assertTrue(actual);
verify(tested, never()).superIsAllowed(canvasHandler, node);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNCommonActionsToolboxFactoryTest method testAddEditBusinessKnowledgeModelAction.
@Test
public void testAddEditBusinessKnowledgeModelAction() {
final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>();
final Element element = mock(Element.class);
final Node node = mock(Node.class);
final Definition definition = mock(Definition.class);
final BusinessKnowledgeModel bkm = mock(BusinessKnowledgeModel.class);
when(element.asNode()).thenReturn(node);
when(element.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(bkm);
tested.addEditAction(element, actions);
assertEquals(1, actions.size());
assertTrue(DMNEditBusinessKnowledgeModelToolboxAction.class.isInstance(actions.get(0)));
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNCommonActionsToolboxFactoryTest method testAddEditDecisionAction.
@Test
public void testAddEditDecisionAction() {
final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>();
final Element element = mock(Element.class);
final Node node = mock(Node.class);
final Definition definition = mock(Definition.class);
final Decision decision = mock(Decision.class);
when(element.asNode()).thenReturn(node);
when(element.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(decision);
tested.addEditAction(element, actions);
assertEquals(1, actions.size());
assertTrue(DMNEditDecisionToolboxAction.class.isInstance(actions.get(0)));
}
Aggregations