Search in sources :

Example 31 with Metadata

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

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

Example 33 with Metadata

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallStartErrorEvent.

@Test
public void testUnmarshallStartErrorEvent() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_STARTERROREVENT);
    assertDiagram(diagram, 3);
    assertEquals("startErrorEventProcess", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> startEventNode = diagram.getGraph().getNode("3BD5BBC8-F1C7-45DE-8BDF-A06D8464A61B");
    StartErrorEvent startErrorEvent = (StartErrorEvent) startEventNode.getContent().getDefinition();
    assertNotNull(startErrorEvent.getGeneral());
    assertEquals("MyStartErrorEvent", startErrorEvent.getGeneral().getName().getValue());
    assertEquals("MyStartErrorEventDocumentation", startErrorEvent.getGeneral().getDocumentation().getValue());
    assertNotNull(startErrorEvent.getExecutionSet());
    assertNotNull(startErrorEvent.getExecutionSet().getErrorRef());
    assertEquals("MyError", startErrorEvent.getExecutionSet().getErrorRef().getValue());
    DataIOSet dataIOSet = startErrorEvent.getDataIOSet();
    AssignmentsInfo assignmentsInfo = dataIOSet.getAssignmentsinfo();
    assertEquals("||errorOutput_:String||[dout]errorOutput_->var1", 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) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) Test(org.junit.Test)

Example 34 with Metadata

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

the class MigrationDiagramMarshallerTest method testUnmarshallOldStuff.

@Test
public void testUnmarshallOldStuff() throws Exception {
    String[] oldStuff = { BPMN_BASIC, BPMN_EVALUATION, BPMN_LANES, BPMN_BOUNDARY_EVENTS, BPMN_NOT_BOUNDARY_EVENTS, BPMN_PROCESSVARIABLES, BPMN_USERTASKASSIGNMENTS, BPMN_BUSINESSRULETASKASSIGNMENTS, BPMN_STARTNONEEVENT, BPMN_STARTTIMEREVENT, BPMN_STARTSIGNALEVENT, BPMN_STARTMESSAGEEVENT, BPMN_STARTERROREVENT, BPMN_INTERMEDIATE_SIGNAL_EVENTCATCHING, BPMN_INTERMEDIATE_ERROR_EVENTCATCHING, BPMN_INTERMEDIATE_SIGNAL_EVENTTHROWING, BPMN_INTERMEDIATE_MESSAGE_EVENTCATCHING, BPMN_INTERMEDIATE_MESSAGE_EVENTTHROWING, BPMN_INTERMEDIATE_TIMER_EVENT, BPMN_ENDSIGNALEVENT, BPMN_ENDMESSAGEEVENT, BPMN_ENDNONEEVENT, BPMN_ENDTERMINATEEVENT, BPMN_PROCESSPROPERTIES, BPMN_BUSINESSRULETASKRULEFLOWGROUP, BPMN_REUSABLE_SUBPROCESS, BPMN_SCRIPTTASK, BPMN_USERTASKASSIGNEES, BPMN_USERTASKPROPERTIES, BPMN_SEQUENCEFLOW, BPMN_XORGATEWAY, BPMN_TIMER_EVENT, BPMN_SIMULATIONPROPERTIES, BPMN_MAGNETDOCKERS, BPMN_MAGNETSINLANE, BPMN_ENDERROR_EVENT };
    Diagram<Graph, Metadata> oldDiagram;
    Diagram<Graph, Metadata> newDiagram;
    for (String fileName : oldStuff) {
        oldDiagram = Unmarshalling.unmarshall(oldMarshaller, fileName);
        newDiagram = Unmarshalling.unmarshall(newMarshaller, fileName);
        // Doesn't work, due to old Marshaller and new Marshaller have different BPMNDefinitionSet uuids
        // assertEquals(oldDiagram.getGraph(), newDiagram.getGraph());
        // Let's check nodes only.
        assertDiagramEquals(oldDiagram, newDiagram, fileName);
    }
}
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 35 with Metadata

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

the class Unmarshalling method unmarshall.

public static Diagram<Graph, Metadata> unmarshall(DiagramMarshaller tested, InputStream is) throws Exception {
    Metadata metadata = new MetadataImpl.MetadataImplBuilder(BindableAdapterUtils.getDefinitionSetId(BPMNDefinitionSet.class)).build();
    DiagramImpl diagram = new DiagramImpl(UUID.uuid(), metadata);
    Graph<DefinitionSet, Node> graph = tested.unmarshall(metadata, is);
    diagram.setGraph(graph);
    return diagram;
}
Also used : MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)

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