Search in sources :

Example 46 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallEndMessageEvent.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEndMessageEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ENDMESSAGEEVENT);
    assertDiagram(diagram, 2);
    assertEquals("EndMessageEvent", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> endMessageEventNode = diagram.getGraph().getNode("_4A8A0A9E-D4A5-4B6E-94A6-20817A57B3C6");
    EndMessageEvent endMessageEvent = (EndMessageEvent) endMessageEventNode.getContent().getDefinition();
    assertNotNull(endMessageEvent.getExecutionSet());
    MessageRef messageRef = endMessageEvent.getExecutionSet().getMessageRef();
    assertEquals("msgref", messageRef.getValue());
    DataIOSet dataIOSet = endMessageEvent.getDataIOSet();
    AssignmentsInfo assignmentsInfo = dataIOSet.getAssignmentsinfo();
    assertEquals("EndMessageEventInputVar1:String||||[din]var1->EndMessageEventInputVar1", assignmentsInfo.getValue());
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Graph(org.kie.workbench.common.stunner.core.graph.Graph) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) EndMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.EndMessageEvent) Test(org.junit.Test)

Example 47 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallXorGateway.

@Test
public void testMarshallXorGateway() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_XORGATEWAY);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 6, 5);
    assertTrue(result.contains("<bpmn2:exclusiveGateway id=\"_877EA035-1A14-42E9-8CAA-43E9BF908C70\" drools:dg=\"_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD\" name=\"AgeSplit\" gatewayDirection=\"Diverging\" default=\"_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD\">"));
}
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 48 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallMagnetDockers.

@Test
public void testMarshallMagnetDockers() throws Exception {
    Diagram<Graph, Metadata> diagram1 = unmarshall(BPMN_MAGNETDOCKERS);
    String result = tested.marshall(diagram1);
    assertDiagram(result, 1, 8, 7);
    Diagram<Graph, Metadata> diagram2 = unmarshall(new ByteArrayInputStream(result.getBytes()));
    testMagnetDockers(diagram2);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ByteArrayInputStream(java.io.ByteArrayInputStream) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 49 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallIntermediateTimerEvent.

@Test
public void testMarshallIntermediateTimerEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_TIMER_EVENT);
    IntermediateTimerEvent timerEvent = 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 IntermediateTimerEvent) {
                timerEvent = (IntermediateTimerEvent) oDefinition;
                break;
            }
        }
    }
    assertNotNull(timerEvent);
    assertNotNull(timerEvent.getGeneral());
    assertNotNull(timerEvent.getExecutionSet());
    assertEquals("myTimeDateValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeDate());
    assertEquals("MyTimeDurationValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeDuration());
    assertEquals("myTimeCycleValue", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeCycle());
    assertEquals("cron", timerEvent.getExecutionSet().getTimerSettings().getValue().getTimeCycleLanguage());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) 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) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 50 with Graph

use of org.kie.workbench.common.stunner.core.graph.Graph in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallScriptTask.

@Test
public void testMarshallScriptTask() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SCRIPTTASK);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 4, 3);
    assertTrue(result.contains("name=\"Javascript Script Task\" scriptFormat=\"http://www.javascript.com/javascript\""));
    assertTrue(result.contains("name=\"Java Script Task\" scriptFormat=\"http://www.java.com/java\""));
    assertTrue(result.contains("<bpmn2:script><![CDATA[var str = FirstName + LastName;]]></bpmn2:script>"));
    assertTrue(result.contains("<bpmn2:script><![CDATA[if (name.toString().equals(\"Jay\")) {" + NEW_LINE + NEW_LINE + "      System.out.println(\"Hello\\n\" + name.toString() + \"\\n\");" + NEW_LINE + NEW_LINE + "} else {" + NEW_LINE + NEW_LINE + NEW_LINE + "  System.out.println(\"Hi\\n\" + name.toString() + \"\\n\");" + NEW_LINE + NEW_LINE + NEW_LINE + "}" + NEW_LINE + "]]></bpmn2:script>"));
    String flatResult = result.replace(NEW_LINE, " ").replaceAll("( )+", " ");
    assertTrue(flatResult.contains("<drools:metaData name=\"customAsync\"> <drools:metaValue><![CDATA[true]]></drools:metaValue>"));
}
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

Graph (org.kie.workbench.common.stunner.core.graph.Graph)190 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)162 Test (org.junit.Test)152 Matchers.anyString (org.mockito.Matchers.anyString)54 View (org.kie.workbench.common.stunner.core.graph.content.view.View)45 Element (org.kie.workbench.common.stunner.core.graph.Element)31 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)30 Node (org.kie.workbench.common.stunner.core.graph.Node)30 Edge (org.kie.workbench.common.stunner.core.graph.Edge)29 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)28 RootElement (org.eclipse.bpmn2.RootElement)28 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)28 FlowElement (org.eclipse.bpmn2.FlowElement)26 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)17 ArrayList (java.util.ArrayList)14 List (java.util.List)13 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)13 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)10 Optional (java.util.Optional)9 Definitions (org.eclipse.bpmn2.Definitions)9