Search in sources :

Example 6 with AdHocSubProcess

use of org.eclipse.bpmn2.AdHocSubProcess in project kie-wb-common by kiegroup.

the class AdHocSubProcessPropertyReaderTest method testIsAdHocAutostart_false.

@Test
public void testIsAdHocAutostart_false() {
    String id = UUID.randomUUID().toString();
    AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess();
    adHocSubProcess.setId(id);
    CustomElement.autoStart.of(adHocSubProcess).set(Boolean.FALSE);
    tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal);
    assertFalse(tested.isAdHocAutostart());
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) Test(org.junit.Test)

Example 7 with AdHocSubProcess

use of org.eclipse.bpmn2.AdHocSubProcess in project kie-wb-common by kiegroup.

the class AdHocSubProcessPropertyReaderTest method testIsAsync.

@Test
public void testIsAsync() {
    AdHocSubProcess adHocSubProcess = bpmn2.createAdHocSubProcess();
    CustomElement.async.of(adHocSubProcess).set(Boolean.TRUE);
    tested = new AdHocSubProcessPropertyReader(adHocSubProcess, definitionResolverReal.getDiagram(), definitionResolverReal);
    assertTrue(tested.isAsync());
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) Test(org.junit.Test)

Example 8 with AdHocSubProcess

use of org.eclipse.bpmn2.AdHocSubProcess in project kie-wb-common by kiegroup.

the class AdHocSubProcessPropertyWriterTest method testSetAdHocCompletionCondition.

@Test
public void testSetAdHocCompletionCondition() {
    AdHocCompletionCondition condition = new AdHocCompletionCondition(new ScriptTypeValue("java", "some code"));
    tested.setAdHocCompletionCondition(condition);
    FormalExpression expression = (FormalExpression) ((AdHocSubProcess) tested.getFlowElement()).getCompletionCondition();
    assertEquals(condition.getValue().getLanguage(), Scripts.scriptLanguageFromUri(expression.getLanguage()));
    assertEquals(asCData(condition.getValue().getScript()), expression.getBody());
}
Also used : FormalExpression(org.eclipse.bpmn2.FormalExpression) AdHocCompletionCondition(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocCompletionCondition) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue) Test(org.junit.Test)

Example 9 with AdHocSubProcess

use of org.eclipse.bpmn2.AdHocSubProcess in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertAdhocSubprocess.

@Test
public void testConvertAdhocSubprocess() {
    AdHocSubprocess definition = new AdHocSubprocess();
    String adHocOrdering = "Parallel";
    boolean adHocAutostart = true;
    String processVariables = "processVar1:Object,processVar2:Integer";
    definition.getGeneral().getName().setValue(NAME);
    definition.getGeneral().getDocumentation().setValue(DOCUMENTATION);
    definition.getProcessData().getProcessVariables().setValue(processVariables);
    definition.getExecutionSet().getAdHocOrdering().setValue(adHocOrdering);
    definition.getExecutionSet().getAdHocAutostart().setValue(adHocAutostart);
    definition.getExecutionSet().getAdHocActivationCondition().setValue(ACTIVATION_CONDITION);
    definition.getExecutionSet().getAdHocCompletionCondition().setValue(COMPLETION_CONDITION);
    definition.getExecutionSet().getOnEntryAction().getValue().addValue(ON_ENTRY_ACTION);
    definition.getExecutionSet().getOnExitAction().getValue().addValue(ON_EXIT_ACTION);
    setBaseSubprocessExecutionSetValues(definition.getExecutionSet());
    double nodeX1 = 10;
    double nodeY1 = 20;
    double nodeX2 = 40;
    double nodeY2 = 60;
    View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create(nodeX1, nodeY1, nodeX2, nodeY2));
    Node<View<? extends BPMNViewDefinition>, Edge> node = new NodeImpl<>(ELEMENT_ID);
    node.setContent(view);
    double parentX1 = 30;
    double parentY1 = 40;
    double parentX2 = 60;
    double parentY2 = 100;
    Node<View<? extends BPMNViewDefinition>, ?> parent = new NodeImpl<>("parentId");
    View<? extends BPMNViewDefinition> parentView = new ViewImpl<>(null, Bounds.create(parentX1, parentY1, parentX2, parentY2));
    parent.setContent(parentView);
    Edge<Child, Node> edge = new EdgeImpl("edgeId");
    edge.setContent(mock(Child.class));
    node.getInEdges().add(edge);
    edge.setSourceNode(parent);
    edge.setTargetNode(node);
    Result<SubProcessPropertyWriter> result = tested.convertSubProcess(node);
    assertTrue(result.isSuccess());
    AdHocSubProcess adHocSubProcess = (AdHocSubProcess) result.value().getElement();
    assertEquals(ELEMENT_ID, adHocSubProcess.getId());
    assertEquals(NAME, adHocSubProcess.getName());
    assertEquals(asCData(NAME), CustomElement.name.of(adHocSubProcess).get());
    assertEquals(asCData(DOCUMENTATION), adHocSubProcess.getDocumentation().get(0).getText());
    assertEquals(adHocOrdering, adHocSubProcess.getOrdering().getName());
    assertEquals(adHocAutostart, CustomElement.autoStart.of(adHocSubProcess).get());
    assertEquals(asCData(ACTIVATION_CONDITION), CustomElement.customActivationCondition.of(adHocSubProcess).get());
    assertEquals(Scripts.LANGUAGE.valueOf(COMPLETION_CONDITION.getLanguage().toUpperCase()).format(), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getLanguage());
    assertEquals(asCData(COMPLETION_CONDITION.getScript()), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getBody());
    assertEquals(ON_ENTRY_ACTION.getLanguage(), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_ENTRY_ACTION.getScript()), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertEquals(ON_EXIT_ACTION.getLanguage(), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_EXIT_ACTION.getScript()), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertVariables(Arrays.asList(new Pair<>("processVar1", "Object"), new Pair<>("processVar2", "Integer")), adHocSubProcess.getProperties());
    BPMNShape shape = result.value().getShape();
    assertEquals(parentX1 + nodeX1, shape.getBounds().getX(), 0);
    assertEquals(parentY1 + nodeY1, shape.getBounds().getY(), 0);
    assertEquals(nodeX2 - nodeX1, shape.getBounds().getWidth(), 0);
    assertEquals(nodeY2 - nodeY1, shape.getBounds().getHeight(), 0);
    assertBaseSubprocessExecutionSet(result.value());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Pair(org.uberfire.commons.data.Pair) Test(org.junit.Test)

Example 10 with AdHocSubProcess

use of org.eclipse.bpmn2.AdHocSubProcess in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallAddHocSubprocess.

@Test
public void testUnmarshallAddHocSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ADHOC_SUBPROCESS);
    AdHocSubprocess adHocSubprocess = null;
    Iterator<Element> it = nodesIterator(diagram);
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof AdHocSubprocess) {
                adHocSubprocess = (AdHocSubprocess) oDefinition;
                break;
            }
        }
    }
    assertNotNull(adHocSubprocess);
    BPMNGeneralSet generalSet = adHocSubprocess.getGeneral();
    AdHocSubprocessTaskExecutionSet executionSet = adHocSubprocess.getExecutionSet();
    ProcessData processData = adHocSubprocess.getProcessData();
    assertNotNull(generalSet);
    assertNotNull(executionSet);
    assertNotNull(processData);
    assertEquals("AdHocSubprocess1", generalSet.getName().getValue());
    assertEquals("AdHocSubprocess1Documentation", generalSet.getDocumentation().getValue());
    assertNotNull(executionSet.getAdHocCompletionCondition());
    assertNotNull(executionSet.getAdHocCompletionCondition().getValue());
    assertNotNull(executionSet.getAdHocOrdering());
    assertNotNull(executionSet.getOnEntryAction());
    assertNotNull(executionSet.getOnExitAction());
    assertEquals("autocomplete", executionSet.getAdHocCompletionCondition().getValue().getScript());
    assertEquals("drools", executionSet.getAdHocCompletionCondition().getValue().getLanguage());
    assertEquals("Sequential", executionSet.getAdHocOrdering().getValue());
    assertEquals(1, executionSet.getOnEntryAction().getValue().getValues().size());
    assertEquals("System.out.println(\"onEntryAction\");", executionSet.getOnEntryAction().getValue().getValues().get(0).getScript());
    assertEquals("mvel", executionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage());
    assertEquals(1, executionSet.getOnExitAction().getValue().getValues().size());
    assertEquals("System.out.println(\"onExitAction\");", executionSet.getOnExitAction().getValue().getValues().get(0).getScript());
    assertEquals("java", executionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
    assertEquals("subProcessVar1:String:[],subProcessVar2:String:[]", processData.getProcessVariables().getValue());
    assertTrue(executionSet.getIsAsync().getValue());
    final String SLA_DUE_DATE = "12/25/1983";
    assertEquals(SLA_DUE_DATE, executionSet.getSlaDueDate().getValue());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) AdHocSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocSubprocessTaskExecutionSet) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)9 FormalExpression (org.eclipse.bpmn2.FormalExpression)5 AdHocSubprocess (org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess)5 FlowElement (org.eclipse.bpmn2.FlowElement)3 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)3 AdHocSubprocessTaskExecutionSet (org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocSubprocessTaskExecutionSet)3 RootElement (org.eclipse.bpmn2.RootElement)2 SubProcess (org.eclipse.bpmn2.SubProcess)2 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)2 BpmnNode (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)2 ScriptTypeTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeTypeSerializer)2 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)2 ScriptTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)2 View (org.kie.workbench.common.stunner.core.graph.content.view.View)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Artifact (org.eclipse.bpmn2.Artifact)1 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)1 DataInput (org.eclipse.bpmn2.DataInput)1