Search in sources :

Example 31 with Process

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

the class BPMNDiagramMarshallerTest method testMarshallProcessVariables.

@Test
public void testMarshallProcessVariables() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
    JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    Definitions definitions = (Definitions) resource.getContents().get(0);
    assertNotNull(definitions);
    List<RootElement> rootElements = definitions.getRootElements();
    assertNotNull(rootElements);
    assertNotNull(getItemDefinition(rootElements, "_employeeItem", "java.lang.String"));
    assertNotNull(getItemDefinition(rootElements, "_reasonItem", "java.lang.String"));
    assertNotNull(getItemDefinition(rootElements, "_performanceItem", "java.lang.String"));
    Process process = getProcess(definitions);
    assertNotNull(process);
    List<Property> properties = process.getProperties();
    assertNotNull(properties);
    assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
    assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
    assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) RootElement(org.eclipse.bpmn2.RootElement) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) Matchers.anyString(org.mockito.Matchers.anyString) Property(org.eclipse.bpmn2.Property) Test(org.junit.Test)

Example 32 with Process

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

the class BPMNDirectDiagramMarshallerTest method testMarshallProcessVariables.

@Test
public void testMarshallProcessVariables() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    Definitions definitions = new DefinitionsConverter(diagram.getGraph()).toDefinitions();
    assertNotNull(definitions);
    List<RootElement> rootElements = definitions.getRootElements();
    assertNotNull(rootElements);
    assertItemExists(rootElements, "_employeeItem", "java.lang.String");
    assertItemExists(rootElements, "_reasonItem", "java.lang.String");
    assertItemExists(rootElements, "_performanceItem", "java.lang.String");
    Process process = getProcess(definitions);
    assertNotNull(process);
    List<Property> properties = process.getProperties();
    assertNotNull(properties);
    assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
    assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
    assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) RootElement(org.eclipse.bpmn2.RootElement) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Property(org.eclipse.bpmn2.Property) Test(org.junit.Test)

Example 33 with Process

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

the class BPMNDirectDiagramMarshallerTest method getProcessExtensionValue.

private String getProcessExtensionValue(Process process, String propertyName) {
    List<ExtensionAttributeValue> extensionValues = process.getExtensionValues();
    for (ExtensionAttributeValue extensionValue : extensionValues) {
        FeatureMap featureMap = extensionValue.getValue();
        for (int i = 0; i < featureMap.size(); i++) {
            EStructuralFeatureImpl.SimpleFeatureMapEntry featureMapEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) featureMap.get(i);
            MetaDataType featureMapValue = (MetaDataType) featureMapEntry.getValue();
            if (propertyName.equals(featureMapValue.getName())) {
                return featureMapValue.getMetaValue();
            }
        }
    }
    return "";
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) MetaDataType(org.jboss.drools.MetaDataType) EStructuralFeatureImpl(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue)

Example 34 with Process

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

the class Bpmn2JsonUnmarshallerTest method testUpdateIDs.

@Test
public void testUpdateIDs() {
    Definitions defs = mock(Definitions.class);
    Process process = mock(Process.class);
    DataObject flowElement = mock(DataObject.class);
    final Value<String> processId = new Value<>("Project:Bad Id");
    final Value<String> flowElementId = new Value<>("Bad Flow Id!");
    when(process.getId()).thenAnswer((m) -> processId.get());
    doAnswer((m) -> {
        processId.set(m.getArgumentAt(0, String.class));
        return null;
    }).when(process).setId(anyString());
    when(flowElement.getId()).thenAnswer((m) -> flowElementId.get());
    when(flowElement.getName()).thenAnswer((m) -> flowElementId.get());
    doAnswer((m) -> {
        flowElementId.set(m.getArgumentAt(0, String.class));
        return null;
    }).when(flowElement).setId(anyString());
    when(process.getFlowElements()).thenReturn(Arrays.asList(flowElement));
    when(defs.getRootElements()).thenReturn(Arrays.asList(process));
    tested.updateIDs(defs);
    assertEquals("Project:BadId", processId.get());
    assertEquals("BadFlowId", flowElementId.get());
}
Also used : DataObject(org.eclipse.bpmn2.DataObject) Definitions(org.eclipse.bpmn2.Definitions) Process(org.eclipse.bpmn2.Process) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 35 with Process

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

the class BPMNDiagramMarshallerTest method testMarshallUserTaskAssignments.

@Test
public void testMarshallUserTaskAssignments() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
    JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    Definitions definitions = (Definitions) resource.getContents().get(0);
    assertNotNull(definitions);
    Process process = getProcess(definitions);
    assertNotNull(process);
    org.eclipse.bpmn2.UserTask userTask = (org.eclipse.bpmn2.UserTask) getNamedFlowElement(process, org.eclipse.bpmn2.UserTask.class, "Self Evaluation");
    assertNotNull(userTask);
    DataInput dataInput = (DataInput) getDataInput(userTask, "reason");
    validateDataInputOrOutput(dataInput, "_reasonInputX", "com.test.Reason", "_reasonInputXItem");
    DataOutput dataOutput = (DataOutput) getDataOutput(userTask, "performance");
    validateDataInputOrOutput(dataOutput, "_performanceOutputX", "Object", "_performanceOutputXItem");
    ItemAwareElement sourceRef = getDataInputAssociationSourceRef(userTask, "reason");
    assertNotNull(sourceRef);
    ItemAwareElement targetRef = getDataInputAssociationTargetRef(userTask, "_reasonInputX");
    assertNotNull(targetRef);
    sourceRef = getDataOutputAssociationSourceRef(userTask, "_performanceOutputX");
    assertNotNull(sourceRef);
    targetRef = getDataOutputAssociationTargetRef(userTask, "performance");
    assertNotNull(targetRef);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) Process(org.eclipse.bpmn2.Process) Matchers.anyString(org.mockito.Matchers.anyString) DataInput(org.eclipse.bpmn2.DataInput) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Test(org.junit.Test)

Aggregations

Process (org.eclipse.bpmn2.Process)46 SubProcess (org.eclipse.bpmn2.SubProcess)33 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)31 RootElement (org.eclipse.bpmn2.RootElement)31 ArrayList (java.util.ArrayList)24 FlowElement (org.eclipse.bpmn2.FlowElement)19 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)15 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)15 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)14 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)14 List (java.util.List)13 Definitions (org.eclipse.bpmn2.Definitions)13 Entry (java.util.Map.Entry)12 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)12 DataInput (org.eclipse.bpmn2.DataInput)11 DataObject (org.eclipse.bpmn2.DataObject)11 DataOutput (org.eclipse.bpmn2.DataOutput)11 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)11 Artifact (org.eclipse.bpmn2.Artifact)10 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)10