Search in sources :

Example 21 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions in project kie-wb-common by kiegroup.

the class JBPMBpmn2ResourceFactoryImpl method createAndInitResource.

/*
     *
     * Creates a new BpmnResourceImpl and initializes it.
     *
     * The method creates a DocumentRoot and a Definitions element, as both are
     * mandatory.
     */
public Definitions createAndInitResource(URI uri) {
    DroolsFactoryImpl.init();
    BpsimFactoryImpl.init();
    Resource resource = createResource(uri);
    Bpmn2Factory factory = Bpmn2Factory.eINSTANCE;
    Definitions definitions = factory.createDefinitions();
    DocumentRoot docummentRoot = factory.createDocumentRoot();
    docummentRoot.setDefinitions(definitions);
    resource.getContents().add(docummentRoot);
    return definitions;
}
Also used : Bpmn2Factory(org.eclipse.bpmn2.Bpmn2Factory) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) Definitions(org.eclipse.bpmn2.Definitions) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 22 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions 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 23 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions 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 24 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions 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 25 with Definitions

use of org.kie.workbench.common.dmn.api.definition.v1_1.Definitions 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

Definitions (org.eclipse.bpmn2.Definitions)25 Definitions (org.kie.dmn.model.v1_1.Definitions)22 Test (org.junit.Test)20 Process (org.eclipse.bpmn2.Process)13 IOException (java.io.IOException)9 InputStreamReader (java.io.InputStreamReader)9 DMNMarshaller (org.kie.dmn.api.marshalling.v1_1.DMNMarshaller)8 Graph (org.kie.workbench.common.stunner.core.graph.Graph)8 InputStream (java.io.InputStream)7 DMNModel (org.kie.dmn.api.core.DMNModel)7 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)7 Path (org.uberfire.backend.vfs.Path)7 List (java.util.List)6 RootElement (org.eclipse.bpmn2.RootElement)6 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)6 HashMap (java.util.HashMap)5 Optional (java.util.Optional)5 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)5 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)5 Matchers.anyString (org.mockito.Matchers.anyString)5