Search in sources :

Example 56 with Metadata

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

the class BPMNDiagramMarshallerTest method testMarshallIntermediateSignalEventCatching.

@Test
public void testMarshallIntermediateSignalEventCatching() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_SIGNAL_EVENTCATCHING);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 1, 0);
    assertTrue(result.contains("<bpmn2:intermediateCatchEvent"));
    assertTrue(result.contains(" name=\"MySignalCatchingEvent\""));
    assertTrue(result.contains("<bpmn2:signalEventDefinition"));
    assertTrue(result.contains(" signalRef=\"_3b677877-9be0-3fe7-bfc4-94a862fdc919\""));
    assertTrue(result.contains("<bpmn2:signal"));
    assertTrue(result.contains("name=\"MySignal\""));
}
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 57 with Metadata

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

the class BPMNDiagramMarshallerTest method testUnmarshallUserTaskProperties.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallUserTaskProperties() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKPROPERTIES);
    assertDiagram(diagram, 4);
    assertEquals("MyBP", diagram.getMetadata().getTitle());
    UserTaskExecutionSet userTaskExecutionSet = 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 UserTask) {
                UserTask userTask = (UserTask) oDefinition;
                userTaskExecutionSet = userTask.getExecutionSet();
                break;
            }
        }
    }
    assertEquals("MyUserTask", userTaskExecutionSet.getTaskName().getValue());
    assertEquals("true", userTaskExecutionSet.getIsAsync().getValue().toString());
    assertEquals("false", userTaskExecutionSet.getSkippable().getValue().toString());
    assertEquals("my subject", userTaskExecutionSet.getSubject().getValue());
    assertEquals("admin", userTaskExecutionSet.getCreatedBy().getValue());
    assertEquals("my description", userTaskExecutionSet.getDescription().getValue());
    assertEquals("3", userTaskExecutionSet.getPriority().getValue());
    assertEquals("true", userTaskExecutionSet.getAdHocAutostart().getValue().toString());
    assertEquals("System.out.println(\"Hello\");", userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getScript());
    assertEquals("java", userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage());
    assertEquals("System.out.println(\"Bye\");", userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getScript());
    assertEquals("java", userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) UserTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.UserTaskExecutionSet) 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) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 58 with Metadata

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

the class BPMNDiagramMarshallerTest method testUnmarshallSequenceFlow.

@Test
public void testUnmarshallSequenceFlow() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
    SequenceFlow sequenceFlow1 = null;
    SequenceFlow sequenceFlow2 = 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 ExclusiveGateway) {
                List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
                for (Edge edge : outEdges) {
                    SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) ((EdgeImpl) edge).getContent()).getDefinition();
                    if ("route1".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow1 = flow;
                    }
                    if ("route2".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow2 = flow;
                    }
                }
            }
        }
    }
    assertNotNull(sequenceFlow1);
    assertNotNull(sequenceFlow1.getExecutionSet());
    assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow1.getGeneral());
    assertNotNull(sequenceFlow1.getGeneral().getName());
    assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
    assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
    assertNotNull(sequenceFlow2);
    assertNotNull(sequenceFlow2.getExecutionSet());
    assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow2.getGeneral());
    assertNotNull(sequenceFlow2.getGeneral().getName());
    assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
    assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) 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) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 59 with Metadata

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

the class BPMNDiagramMarshallerTest method testUnmarshallIntermediateSignalEventThrowing.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallIntermediateSignalEventThrowing() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_SIGNAL_EVENTTHROWING);
    assertDiagram(diagram, 2);
    assertEquals("intermediateSignalThrowing", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> intermediateEventNode = diagram.getGraph().getNode("_A45EC77D-5414-4348-BA8F-05C4FFD660EE");
    IntermediateSignalEventThrowing intermediateSignalEventThrowing = (IntermediateSignalEventThrowing) intermediateEventNode.getContent().getDefinition();
    assertNotNull(intermediateSignalEventThrowing.getGeneral());
    assertEquals("MySignalThrowingEvent", intermediateSignalEventThrowing.getGeneral().getName().getValue());
    assertEquals("MySignalThrowingEventDocumentation", intermediateSignalEventThrowing.getGeneral().getDocumentation().getValue());
    assertNotNull(intermediateSignalEventThrowing.getExecutionSet());
    assertEquals("processInstance", intermediateSignalEventThrowing.getExecutionSet().getSignalScope().getValue());
    assertEquals("MySignal", intermediateSignalEventThrowing.getExecutionSet().getSignalRef().getValue());
    DataIOSet dataIOSet = intermediateSignalEventThrowing.getDataIOSet();
    AssignmentsInfo assignmentsInfo = dataIOSet.getAssignmentsinfo();
    assertEquals("_input1:String||||[din]var1->_input1", assignmentsInfo.getValue());
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Graph(org.kie.workbench.common.stunner.core.graph.Graph) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) Test(org.junit.Test)

Example 60 with Metadata

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

the class BPMNDiagramMarshallerTest method testMarshallEndTerminateEvent.

@Test
public void testMarshallEndTerminateEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ENDTERMINATEEVENT);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 2, 1);
    assertTrue(result.contains("<bpmn2:endEvent"));
    assertTrue(result.contains(" id=\"_1B379E3E-E4ED-4BD2-AEE8-CD85374CEC78\""));
    assertTrue(result.contains("name=\"MyEndTerminateEvent\""));
    assertTrue(result.contains("<drools:metaValue><![CDATA[MyEndTerminateEvent]]></drools:metaValue>"));
    assertTrue(result.contains("<![CDATA[MyEndTerminateEventDocumentation]]></bpmn2:documentation>"));
    assertTrue(result.contains("<bpmn2:terminateEventDefinition"));
    assertTrue(result.contains("</bpmn2:endEvent>"));
}
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)

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