Search in sources :

Example 66 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallWorkItems.

@Test
public void testMarshallWorkItems() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SERVICE_TASKS);
    String result = tested.marshall(diagram);
    System.out.println(result);
    assertDiagram(result, 1, 4, 3);
    assertTrue(result.contains("drools:taskName=\"Email\""));
    assertTrue(result.contains("drools:taskName=\"Log\""));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 67 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallEventSubprocess.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEventSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVENT_SUBPROCESS);
    assertDiagram(diagram, 2);
    assertEquals("EventSubProcess", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> eventSubprocessNode = diagram.getGraph().getNode("_DF031493-5F1C-4D2B-9916-2FEABB1FADFF");
    EventSubprocess eventSubprocess = (EventSubprocess) eventSubprocessNode.getContent().getDefinition();
    assertTrue(eventSubprocess.getIsAsync().getValue());
    assertEquals("Var1:String", eventSubprocess.getProcessData().getProcessVariables().getValue());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 68 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata 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)

Example 69 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallInclusiveGateway.

@Test
public void testMarshallInclusiveGateway() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INCLUSIVE_GATEWAY);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 6, 6);
    assertTrue(result.contains("<bpmn2:inclusiveGateway id=\"_526EE472-FE8B-4E9A-A951-CFBA86C3691F\" drools:dg=\"_3D5701E9-CFD3-4218-9200-897B6D4FF041\" name=\"InclusiveGatewayName\" gatewayDirection=\"Diverging\" default=\"_3D5701E9-CFD3-4218-9200-897B6D4FF041\">"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 70 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallEndTerminateEvent.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEndTerminateEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ENDTERMINATEEVENT);
    assertDiagram(diagram, 3);
    assertEquals("endTerminateEvent", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> endNoneEventNode = diagram.getGraph().getNode("_1B379E3E-E4ED-4BD2-AEE8-CD85374CEC78");
    EndTerminateEvent endTerminateEvent = (EndTerminateEvent) endNoneEventNode.getContent().getDefinition();
    assertNotNull(endTerminateEvent.getGeneral());
    assertEquals("MyEndTerminateEvent", endTerminateEvent.getGeneral().getName().getValue());
    assertEquals("MyEndTerminateEventDocumentation", endTerminateEvent.getGeneral().getDocumentation().getValue());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) EndTerminateEvent(org.kie.workbench.common.stunner.bpmn.definition.EndTerminateEvent) Test(org.junit.Test)

Aggregations

Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)175 Graph (org.kie.workbench.common.stunner.core.graph.Graph)158 Test (org.junit.Test)156 Matchers.anyString (org.mockito.Matchers.anyString)53 View (org.kie.workbench.common.stunner.core.graph.content.view.View)32 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)30 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)28 RootElement (org.eclipse.bpmn2.RootElement)28 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)28 Element (org.kie.workbench.common.stunner.core.graph.Element)27 FlowElement (org.eclipse.bpmn2.FlowElement)26 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)16 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)14 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)11 StartErrorEvent (org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent)10 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)10 StartSignalEvent (org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent)9 StartTimerEvent (org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent)9 Node (org.kie.workbench.common.stunner.core.graph.Node)9