use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallProcessVariables.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
assertDiagram(diagram, 8);
assertEquals("ProcessVariables", diagram.getMetadata().getTitle());
ProcessVariables variables = 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;
variables = bpmnDiagram.getProcessData().getProcessVariables();
break;
}
}
}
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
Node<? extends Definition, ?> diagramNode = diagram.getGraph().getNode("_luRBMdEjEeWXpsZ1tNStKQ");
assertTrue(diagramNode.getContent().getDefinition() instanceof BPMNDiagram);
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) diagramNode.getContent().getDefinition();
assertTrue(bpmnDiagram.getProcessData() != null);
assertTrue(bpmnDiagram.getProcessData().getProcessVariables() != null);
variables = bpmnDiagram.getProcessData().getProcessVariables();
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallInclusiveGateway.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallInclusiveGateway() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INCLUSIVE_GATEWAY);
assertDiagram(diagram, 7);
assertEquals(diagram.getMetadata().getTitle(), "TestInclusiveGateway");
Graph graph = diagram.getGraph();
Node<? extends Definition, ?> gatewayNode = graph.getNode("_526EE472-FE8B-4E9A-A951-CFBA86C3691F");
assertTrue(gatewayNode.getContent().getDefinition() instanceof InclusiveGateway);
InclusiveGateway inclusiveGateway = (InclusiveGateway) gatewayNode.getContent().getDefinition();
assertEquals("InclusiveGatewayName", inclusiveGateway.getGeneral().getName().getValue());
assertEquals("_3D5701E9-CFD3-4218-9200-897B6D4FF041", inclusiveGateway.getExecutionSet().getDefaultRoute().getValue());
SequenceFlow sequenceFlow1 = null;
SequenceFlow sequenceFlow2 = null;
List<Edge> outEdges = (List<Edge>) gatewayNode.getOutEdges();
if (outEdges != null) {
for (Edge edge : outEdges) {
if ("_3D5701E9-CFD3-4218-9200-897B6D4FF041".equals(edge.getUUID())) {
sequenceFlow1 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
} else if ("_A414F16D-90BB-4742-A4E7-EBF7EA1ECD7E".equals(edge.getUUID())) {
sequenceFlow2 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
}
}
}
assertNotNull(sequenceFlow1);
assertEquals("OutSequence1", sequenceFlow1.getGeneral().getName().getValue());
assertNotNull(sequenceFlow2);
assertEquals("OutSequence2", sequenceFlow2.getGeneral().getName().getValue());
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata 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());
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata 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);
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallEvaluation.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEvaluation() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVALUATION);
assertDiagram(diagram, 8);
assertEquals("Evaluation", diagram.getMetadata().getTitle());
Node<? extends View, ?> task1 = diagram.getGraph().getNode("_88233779-B395-4B8C-A086-9EF43698426C");
Node<? extends View, ?> task2 = diagram.getGraph().getNode("_AE5BF0DC-B720-4FDE-9499-5ED89D41FB1A");
Node<? extends View, ?> task3 = diagram.getGraph().getNode("_6063D302-9D81-4C86-920B-E808A45377C2");
assertTrue(task1.getContent().getDefinition() instanceof UserTask);
assertTrue(task2.getContent().getDefinition() instanceof UserTask);
assertTrue(task3.getContent().getDefinition() instanceof UserTask);
// Assert bounds.
Bounds task1Bounds = task1.getContent().getBounds();
Bounds.Bound task1ULBound = task1Bounds.getUpperLeft();
Bounds.Bound task1LRBound = task1Bounds.getLowerRight();
assertEquals(648d, task1ULBound.getX(), 0);
assertEquals(149d, task1ULBound.getY(), 0);
assertEquals(784d, task1LRBound.getX(), 0);
assertEquals(197d, task1LRBound.getY(), 0);
}
Aggregations