Search in sources :

Example 21 with Element

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallEmbeddedSubprocess.

@Test
public void testUnmarshallEmbeddedSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EMBEDDED_SUBPROCESS);
    EmbeddedSubprocess subprocess = 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 EmbeddedSubprocess) {
                subprocess = (EmbeddedSubprocess) oDefinition;
                break;
            }
        }
    }
    assertNotNull(subprocess);
}
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) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 22 with Element

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallSimulationProperties.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallSimulationProperties() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SIMULATIONPROPERTIES);
    assertDiagram(diagram, 4);
    assertEquals("SimulationProperties", diagram.getMetadata().getTitle());
    SimulationSet simulationSet = 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;
                simulationSet = userTask.getSimulationSet();
                break;
            }
        }
    }
    assertEquals(Double.valueOf(111), simulationSet.getQuantity().getValue());
    assertEquals("poisson", simulationSet.getDistributionType().getValue());
    assertEquals(Double.valueOf(123), simulationSet.getUnitCost().getValue());
    assertEquals(Double.valueOf(999), simulationSet.getWorkingHours().getValue());
    assertEquals(Double.valueOf(321), simulationSet.getMean().getValue());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) 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 23 with Element

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallReusableSubprocess.

@Test
public void testUnmarshallReusableSubprocess() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_REUSABLE_SUBPROCESS);
    ReusableSubprocess reusableSubprocess = 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 ReusableSubprocess) {
                reusableSubprocess = (ReusableSubprocess) oDefinition;
                break;
            }
        }
    }
    assertNotNull(reusableSubprocess);
    assertNotNull(reusableSubprocess.getExecutionSet());
    assertNotNull(reusableSubprocess.getExecutionSet().getCalledElement());
    assertNotNull(reusableSubprocess.getGeneral());
    BPMNGeneralSet generalSet = reusableSubprocess.getGeneral();
    ReusableSubprocessTaskExecutionSet executionSet = reusableSubprocess.getExecutionSet();
    assertNotNull(generalSet);
    assertNotNull(executionSet);
    assertEquals("my subprocess", generalSet.getName().getValue());
    assertEquals("my-called-element", executionSet.getCalledElement().getValue());
    assertEquals(false, executionSet.getIndependent().getValue());
    assertEquals(false, executionSet.getWaitForCompletion().getValue());
    String assignmentsInfo = reusableSubprocess.getDataIOSet().getAssignmentsinfo().getValue();
    assertEquals("|input1:String,input2:Float||output1:String,output2:Float|[din]pv1->input1,[din]pv2->input2,[dout]output1->pv1,[dout]output2->pv2", assignmentsInfo);
    assertEquals("true", reusableSubprocess.getExecutionSet().getIsAsync().getValue().toString());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) 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) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ReusableSubprocessTaskExecutionSet) Test(org.junit.Test)

Example 24 with Element

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallUserTaskAssignees.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallUserTaskAssignees() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNEES);
    assertDiagram(diagram, 6);
    assertEquals("UserGroups", diagram.getMetadata().getTitle());
    UserTaskExecutionSet executionSet = 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;
                executionSet = userTask.getExecutionSet();
                break;
            }
        }
    }
    assertEquals("user,user1", executionSet.getActors().getValue());
    assertEquals("admin,kiemgmt", executionSet.getGroupid().getValue());
}
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 25 with Element

use of org.kie.workbench.common.stunner.core.graph.Element 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

Element (org.kie.workbench.common.stunner.core.graph.Element)85 Test (org.junit.Test)55 View (org.kie.workbench.common.stunner.core.graph.content.view.View)34 Graph (org.kie.workbench.common.stunner.core.graph.Graph)27 FlowElement (org.eclipse.bpmn2.FlowElement)24 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)24 RootElement (org.eclipse.bpmn2.RootElement)24 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)24 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Node (org.kie.workbench.common.stunner.core.graph.Node)11 Map (java.util.Map)7 Optional (java.util.Optional)6 Before (org.junit.Before)6 Collection (java.util.Collection)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)5 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)5 Matchers.anyString (org.mockito.Matchers.anyString)5 Logger (java.util.logging.Logger)4 BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)4