use of org.kie.workbench.common.stunner.core.diagram.Metadata 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());
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMarshallUserTaskAssignments.
@Test
public void testMarshallUserTaskAssignments() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
// JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
String result = tested.marshall(diagram);
assertDiagram(result, 1, 7, 7);
DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
Definitions definitions = definitionsConverter.toDefinitions();
assertNotNull(definitions);
Process process = getProcess(definitions);
assertNotNull(process);
org.eclipse.bpmn2.UserTask userTask = (org.eclipse.bpmn2.UserTask) getNamedFlowElement(process, org.eclipse.bpmn2.UserTask.class, "Self Evaluation");
assertNotNull(userTask);
DataInput dataInput = (DataInput) getDataInput(userTask, "reason");
// this fails because of type
validateDataInputOrOutput(dataInput, "_reasonInputX", "com.test.Reason", "_reasonInputXItem");
DataOutput dataOutput = (DataOutput) getDataOutput(userTask, "performance");
validateDataInputOrOutput(dataOutput, "_performanceOutputX", "Object", "_performanceOutputXItem");
ItemAwareElement sourceRef = getDataInputAssociationSourceRef(userTask, "reason");
assertNotNull(sourceRef);
ItemAwareElement targetRef = getDataInputAssociationTargetRef(userTask, "_reasonInputX");
assertNotNull(targetRef);
sourceRef = getDataOutputAssociationSourceRef(userTask, "_performanceOutputX");
assertNotNull(sourceRef);
targetRef = getDataOutputAssociationTargetRef(userTask, "performance");
assertNotNull(targetRef);
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallIntermediateSignalEventThrowing.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallIntermediateSignalEventThrowing() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_SIGNAL_EVENTTHROWING);
assertDiagram(diagram, 2);
assertEquals("intermediateSignalThrowing", diagram.getMetadata().getTitle());
Node<? extends Definition, ?> intermediateEventNode = diagram.getGraph().getNode("_A45EC77D-5414-4348-BA8F-05C4FFD660EE");
IntermediateSignalEventThrowing intermediateSignalEventThrowing = (IntermediateSignalEventThrowing) intermediateEventNode.getContent().getDefinition();
assertNotNull(intermediateSignalEventThrowing.getGeneral());
assertEquals("MySignalThrowingEvent", intermediateSignalEventThrowing.getGeneral().getName().getValue());
assertEquals("MySignalThrowingEventDocumentation", intermediateSignalEventThrowing.getGeneral().getDocumentation().getValue());
assertNotNull(intermediateSignalEventThrowing.getExecutionSet());
assertEquals("processInstance", intermediateSignalEventThrowing.getExecutionSet().getSignalScope().getValue());
assertEquals("MySignal", intermediateSignalEventThrowing.getExecutionSet().getSignalRef().getValue());
DataIOSet dataIOSet = intermediateSignalEventThrowing.getDataIOSet();
AssignmentsInfo assignmentsInfo = dataIOSet.getAssignmentsinfo();
assertEquals("_input1:String||||[din]var1->_input1", assignmentsInfo.getValue());
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata 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);
}
use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallStartNoneEvent.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallStartNoneEvent() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_STARTNONEEVENT);
assertDiagram(diagram, 4);
assertEquals("startNoneEvent", diagram.getMetadata().getTitle());
Node<? extends Definition, ?> startNoneEventNode = diagram.getGraph().getNode("processStartEvent");
StartNoneEvent startNoneEvent = (StartNoneEvent) startNoneEventNode.getContent().getDefinition();
assertNotNull(startNoneEvent.getGeneral());
assertEquals("MyStartNoneEvent", startNoneEvent.getGeneral().getName().getValue());
assertEquals("MyStartNoneEventDocumentation", startNoneEvent.getGeneral().getDocumentation().getValue());
}
Aggregations