Search in sources :

Example 96 with View

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallProcessProperties.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessProperties() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSPROPERTIES);
    assertDiagram(diagram, 4);
    assertEquals("BPSimple", diagram.getMetadata().getTitle());
    DiagramSet diagramProperties = 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 BPMNDiagram) {
                BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
                diagramProperties = bpmnDiagram.getDiagramSet();
                break;
            }
        }
    }
    assertEquals("BPSimple", diagramProperties.getName().getValue());
    assertEquals("This is a\n" + "simple\n" + "process", diagramProperties.getDocumentation().getValue());
    assertEquals("JDLProj.BPSimple", diagramProperties.getId().getValue());
    assertEquals("org.jbpm", diagramProperties.getPackageProperty().getValue());
    assertEquals(Boolean.TRUE, diagramProperties.getExecutable().getValue());
    assertEquals(Boolean.TRUE, diagramProperties.getAdHoc().getValue());
    assertEquals("This is the\n" + "Process\n" + "Instance\n" + "Description", diagramProperties.getProcessInstanceDescription().getValue());
}
Also used : BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) 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) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 97 with View

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallNotBoundaryEvents.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallNotBoundaryEvents() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_NOT_BOUNDARY_EVENTS);
    assertEquals("Not Boundary Event", diagram.getMetadata().getTitle());
    assertDiagram(diagram, 6);
    // Assert than the intermediate event is connected using a view connector,
    // so not boundary to the task ( not docked ).
    Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
    List<Edge> inEdges = event.getInEdges();
    boolean foundViewConnector = false;
    for (Edge e : inEdges) {
        if (e.getContent() instanceof ViewConnector) {
            foundViewConnector = true;
        }
    }
    assertTrue(foundViewConnector);
    // Assert absolute position as the node is not docked.
    Bounds bounds = ((View) event.getContent()).getBounds();
    Bounds.Bound ul = bounds.getUpperLeft();
    Bounds.Bound lr = bounds.getLowerRight();
    assertEquals(305, ul.getX(), 0);
    assertEquals(300, ul.getY(), 0);
    assertEquals(335, lr.getX(), 0);
    assertEquals(330, lr.getY(), 0);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 98 with View

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallScriptTask.

@Test
public void testUnmarshallScriptTask() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SCRIPTTASK);
    ScriptTask javascriptScriptTask = null;
    ScriptTask javaScriptTask = 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 ScriptTask) {
                ScriptTask task = (ScriptTask) oDefinition;
                if ("Javascript Script Task".equals(task.getGeneral().getName().getValue())) {
                    javascriptScriptTask = task;
                } else if ("Java Script Task".equals(task.getGeneral().getName().getValue())) {
                    javaScriptTask = task;
                }
            }
        }
    }
    assertNotNull(javascriptScriptTask);
    assertNotNull(javascriptScriptTask.getExecutionSet());
    assertNotNull(javascriptScriptTask.getExecutionSet().getScript());
    assertEquals(javascriptScriptTask.getTaskType().getValue(), TaskTypes.SCRIPT);
    assertEquals("Javascript Script Task", javascriptScriptTask.getGeneral().getName().getValue());
    assertEquals("var str = FirstName + LastName;", javascriptScriptTask.getExecutionSet().getScript().getValue().getScript());
    assertEquals("javascript", javascriptScriptTask.getExecutionSet().getScript().getValue().getLanguage());
    assertEquals("true", javascriptScriptTask.getExecutionSet().getIsAsync().getValue().toString());
    assertEquals("true", javascriptScriptTask.getExecutionSet().getIsAsync().getValue().toString());
    assertNotNull(javaScriptTask);
    assertNotNull(javaScriptTask.getExecutionSet());
    assertNotNull(javaScriptTask.getExecutionSet().getScript());
    assertEquals(javaScriptTask.getTaskType().getValue(), TaskTypes.SCRIPT);
    assertEquals("Java Script Task", javaScriptTask.getGeneral().getName().getValue());
    assertEquals("if (name.toString().equals(\"Jay\")) {\n" + "\n" + "      System.out.println(\"Hello\\n\" + name.toString() + \"\\n\");\n" + "\n" + "} else {\n" + "\n" + "\n" + "  System.out.println(\"Hi\\n\" + name.toString() + \"\\n\");\n" + "\n" + "\n" + "}\n", javaScriptTask.getExecutionSet().getScript().getValue().getScript());
    assertEquals("java", javaScriptTask.getExecutionSet().getScript().getValue().getLanguage());
    assertEquals("true", javaScriptTask.getExecutionSet().getIsAsync().getValue().toString());
    assertEquals("true", javaScriptTask.getExecutionSet().getIsAsync().getValue().toString());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) 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 99 with View

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallBoundaryEvents.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallBoundaryEvents() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BOUNDARY_EVENTS);
    // Basic assertions.
    assertEquals("Boundary Event", diagram.getMetadata().getTitle());
    assertDiagram(diagram, 6);
    // Assert than the intermediate event is connected using a dock connector,
    // so boundary to the task.
    Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
    List<Edge> inEdges = event.getInEdges();
    boolean foundDockConector = false;
    for (Edge e : inEdges) {
        if (e.getContent() instanceof Dock) {
            foundDockConector = true;
        }
    }
    assertTrue(foundDockConector);
    // Assert relative position for the docked node.
    Bounds bounds = ((View) event.getContent()).getBounds();
    Bounds.Bound ul = bounds.getUpperLeft();
    Bounds.Bound lr = bounds.getLowerRight();
    assertEquals(57, ul.getX(), 0);
    assertEquals(70, ul.getY(), 0);
    assertEquals(87, lr.getX(), 0);
    assertEquals(100, lr.getY(), 0);
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Dock(org.kie.workbench.common.stunner.core.graph.content.relationship.Dock) Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 100 with View

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

the class BPMNDirectDiagramMarshallerTest 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)

Aggregations

View (org.kie.workbench.common.stunner.core.graph.content.view.View)144 Edge (org.kie.workbench.common.stunner.core.graph.Edge)100 Node (org.kie.workbench.common.stunner.core.graph.Node)57 Test (org.junit.Test)49 Graph (org.kie.workbench.common.stunner.core.graph.Graph)45 Element (org.kie.workbench.common.stunner.core.graph.Element)36 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)32 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)31 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)31 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)31 FlowElement (org.eclipse.bpmn2.FlowElement)26 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)26 RootElement (org.eclipse.bpmn2.RootElement)26 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)21 EventPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader)16 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)16 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)14 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 ProcessVariables (org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables)10