Search in sources :

Example 31 with Graph

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallEventDefinitionRef.

@Test
public void testUnmarshallEventDefinitionRef() {
    try {
        Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVENT_DEFINITION_REF);
        Node<? extends Definition<IntermediateTimerEvent>, ?> intermediateTimerEvent = diagram.getGraph().getNode("FLOWNODE_9e71d692-986c-11e7-40d3-005056844bde");
        IntermediateTimerEvent definition = intermediateTimerEvent.getContent().getDefinition();
        CancellingTimerEventExecutionSet executionSet = definition.getExecutionSet();
        TimerSettings timerSettings = executionSet.getTimerSettings();
    } catch (Exception ex) {
        fail(ex.getMessage());
    }
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) CancellingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.CancellingTimerEventExecutionSet) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 32 with Graph

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallIntermediateErrorEventCatching.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallIntermediateErrorEventCatching() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_ERROR_EVENTCATCHING);
    assertDiagram(diagram, 2);
    assertEquals("intermediateErrorCatching", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> intermediateEventNode = diagram.getGraph().getNode("80A2A7A9-7C68-408C-BE3B-467562A2C139");
    IntermediateErrorEventCatching intermediateErrorEventCatching = (IntermediateErrorEventCatching) intermediateEventNode.getContent().getDefinition();
    assertNotNull(intermediateErrorEventCatching.getGeneral());
    assertEquals("MyErrorCatchingEvent", intermediateErrorEventCatching.getGeneral().getName().getValue());
    assertEquals("MyErrorCatchingEventDocumentation", intermediateErrorEventCatching.getGeneral().getDocumentation().getValue());
    assertNotNull(intermediateErrorEventCatching.getExecutionSet());
    assertEquals(true, intermediateErrorEventCatching.getExecutionSet().getCancelActivity().getValue());
    assertEquals("MyError", intermediateErrorEventCatching.getExecutionSet().getErrorRef().getValue());
    DataIOSet dataIOSet = intermediateErrorEventCatching.getDataIOSet();
    AssignmentsInfo assignmentsInfo = dataIOSet.getAssignmentsinfo();
    assertEquals("||theErrorEventOutput:String||[dout]theErrorEventOutput->errorVar", assignmentsInfo.getValue());
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Graph(org.kie.workbench.common.stunner.core.graph.Graph) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 33 with Graph

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallXorGateway.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallXorGateway() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_XORGATEWAY);
    assertDiagram(diagram, 7);
    assertEquals(diagram.getMetadata().getTitle(), "XORGateway");
    Graph graph = diagram.getGraph();
    Node<? extends Definition, ?> gatewayNode = graph.getNode("_877EA035-1A14-42E9-8CAA-43E9BF908C70");
    ExclusiveGateway xorGateway = (ExclusiveGateway) gatewayNode.getContent().getDefinition();
    assertEquals("AgeSplit", xorGateway.getGeneral().getName().getValue());
    assertEquals("_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD", xorGateway.getExecutionSet().getDefaultRoute().getValue());
    SequenceFlow sequenceFlow1 = null;
    SequenceFlow sequenceFlow2 = null;
    List<Edge> outEdges = (List<Edge>) gatewayNode.getOutEdges();
    if (outEdges != null) {
        for (Edge edge : outEdges) {
            if ("_C72E00C3-70DC-4BC9-A08E-761B4263A239".equals(edge.getUUID())) {
                sequenceFlow1 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
            } else if ("_5110D608-BDAD-47BF-A3F9-E1DBE43ED7CD".equals(edge.getUUID())) {
                sequenceFlow2 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
            }
        }
    }
    assertNotNull(sequenceFlow1);
    assertEquals("10 and over", sequenceFlow1.getGeneral().getName().getValue());
    assertNotNull(sequenceFlow2);
    assertEquals("under 10", sequenceFlow2.getGeneral().getName().getValue());
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ArrayList(java.util.ArrayList) List(java.util.List) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 34 with Graph

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallEndNoneEvent.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEndNoneEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ENDNONEEVENT);
    assertDiagram(diagram, 3);
    assertEquals("endNoneEvent", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> endNoneEventNode = diagram.getGraph().getNode("_9DF2C9D3-15DF-4436-B6C6-85B58B8696B6");
    EndNoneEvent endNoneEvent = (EndNoneEvent) endNoneEventNode.getContent().getDefinition();
    assertNotNull(endNoneEvent.getGeneral());
    assertEquals("MyEndNoneEvent", endNoneEvent.getGeneral().getName().getValue());
    assertEquals("MyEndNoneEventDocumentation", endNoneEvent.getGeneral().getDocumentation().getValue());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) Test(org.junit.Test)

Example 35 with Graph

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallAddHocSubprocess.

@Test
public void testUnmarshallAddHocSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_ADHOC_SUBPROCESS);
    AdHocSubprocess adHocSubprocess = 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 AdHocSubprocess) {
                adHocSubprocess = (AdHocSubprocess) oDefinition;
                break;
            }
        }
    }
    assertNotNull(adHocSubprocess);
    BPMNGeneralSet generalSet = adHocSubprocess.getGeneral();
    AdHocSubprocessTaskExecutionSet executionSet = adHocSubprocess.getExecutionSet();
    ProcessData processData = adHocSubprocess.getProcessData();
    assertNotNull(generalSet);
    assertNotNull(executionSet);
    assertNotNull(processData);
    assertEquals("AdHocSubprocess1", generalSet.getName().getValue());
    assertEquals("AdHocSubprocess1Documentation", generalSet.getDocumentation().getValue());
    assertNotNull(executionSet.getAdHocCompletionCondition());
    assertNotNull(executionSet.getAdHocCompletionCondition().getValue());
    assertNotNull(executionSet.getAdHocOrdering());
    assertNotNull(executionSet.getOnEntryAction());
    assertNotNull(executionSet.getOnExitAction());
    assertEquals("autocomplete", executionSet.getAdHocCompletionCondition().getValue().getScript());
    assertEquals("drools", executionSet.getAdHocCompletionCondition().getValue().getLanguage());
    assertEquals("Sequential", executionSet.getAdHocOrdering().getValue());
    assertEquals(1, executionSet.getOnEntryAction().getValue().getValues().size());
    assertEquals("System.out.println(\"onEntryAction\");", executionSet.getOnEntryAction().getValue().getValues().get(0).getScript());
    assertEquals("mvel", executionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage());
    assertEquals(1, executionSet.getOnExitAction().getValue().getValues().size());
    assertEquals("System.out.println(\"onExitAction\");", executionSet.getOnExitAction().getValue().getValues().get(0).getScript());
    assertEquals("java", executionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
    assertEquals("subProcessVar1:String,subProcessVar2:String", processData.getProcessVariables().getValue());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) 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) AdHocSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocSubprocessTaskExecutionSet) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) 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