@Test public void testDataObjectUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("dataObject.json"), "").getContents().get(0)); assertTrue(definitions.getRootElements().size() == 2); Process process = getRootProcess(definitions); assertTrue(process.getFlowElements().iterator().next() instanceof DataObject); DataObject da = (DataObject) process.getFlowElements().iterator().next(); assertEquals("data object", da.getName()); definitions.eResource().save(System.out, Collections.emptyMap()); }
@Test @DiagramResource("org/camunda/bpm/modeler/test/ui/change/ChangeSupportTest.testBase.bpmn") public void testListElementRemove() { final Process process1 = findBusinessObjectById(diagram, "Process_1", Process.class); final ServiceTask serviceTask1 = findBusinessObjectById(diagram, "ServiceTask_1", ServiceTask.class); FeatureChangeFilter filter = new FeatureChangeFilter(process1, FLOW_ELEMENTS_FEATURE); CustomResourceSetListener listener = new CustomResourceSetListener(process1, filter); listener.register(); // assert that task is member of collection assertThat(process1.getFlowElements()).contains(serviceTask1); transactionalExecute( new RecordingCommand(editingDomain) { @Override protected void doExecute() { process1.getFlowElements().remove(serviceTask1); } }); assertThat(listener.getCapturedEvents()).hasSize(1); }
@Test public void testSequenceFlowUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("sequenceFlow.json"), "").getContents().get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); assertTrue(process.getFlowElements().get(0) instanceof Task); Task task = (Task) process.getFlowElements().get(0); assertEquals("task1", task.getName()); Task task2 = (Task) process.getFlowElements().get(1); assertEquals("task2", task2.getName()); SequenceFlow flow = (SequenceFlow) process.getFlowElements().get(2); assertEquals("seqFlow", flow.getName()); assertEquals(task, flow.getSourceRef()); assertEquals(task2, flow.getTargetRef()); definitions.eResource().save(System.out, Collections.emptyMap()); }
@Test public void testEndEventUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("endEvent.json"), "").getContents().get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); EndEvent g = (EndEvent) process.getFlowElements().get(0); assertEquals("end event", g.getName()); definitions.eResource().save(System.out, Collections.emptyMap()); }
@Test public void testIntermediateThrowSignalUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller .unmarshall(getTestJsonFile("intermediateThrowSignalEvent.json"), "") .getContents() .get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); ThrowEvent g = (ThrowEvent) process.getFlowElements().get(0); assertEquals("throw signal event", g.getName()); assertTrue(g.getEventDefinitions().iterator().next() instanceof SignalEventDefinition); definitions.eResource().save(System.out, Collections.emptyMap()); }
@Test public void testSimpleChainUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller .unmarshall(getTestJsonFile("startEvent-task-endEvent.json"), "") .getContents() .get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); assertTrue(process.getFlowElements().size() == 5); assertTrue(process.getLaneSets().size() == 1); assertTrue(process.getLaneSets().get(0).getLanes().size() == 1); definitions.eResource().save(System.out, Collections.emptyMap()); }
@Test public void testStartParallelMultipleEventUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller .unmarshall(getTestJsonFile("startParallelMultipleEvent.json"), "") .getContents() .get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); StartEvent g = (StartEvent) process.getFlowElements().get(0); assertEquals("start parallel multiple event", g.getName()); // TODO multiple event definitions ??? definitions.eResource().save(System.out, Collections.emptyMap()); }
@Test public void testAssociationUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("association.json"), "").getContents().get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); Task g = (Task) process.getFlowElements().get(0); assertEquals("task", g.getName()); TextAnnotation textA = (TextAnnotation) process.getArtifacts().get(0); Association association = (Association) process.getArtifacts().get(1); assertEquals(g, association.getSourceRef()); assertEquals(textA, association.getTargetRef()); assertEquals(AssociationDirection.NONE, association.getAssociationDirection()); definitions.eResource().save(System.out, Collections.emptyMap()); }
@Override protected void findGL(Definitions diagram) { StringBuilder temp = new StringBuilder(); int num = 0; for (RootElement rootElement : diagram.getRootElements()) { if (rootElement instanceof Process) { Process process = (Process) rootElement; // System.out.format("Found a process: %s\n", process.getName()); IDProcess = process.getId(); for (FlowElement fe : process.getFlowElements()) { if (fe instanceof SubProcess) { SubProcess sub = (SubProcess) fe; // System.out.format("Found a SubProcess: %s\n", sub.getName()); this.searchSubProcess(sub); } else if (fe instanceof IntermediateCatchEvent) { IntermediateCatchEvent a = (IntermediateCatchEvent) fe; if (a.getName() == null || (a.getName().length() == 0)) { num++; elementsBPMN.add(fe); String name = fe.getName() != null ? fe.getName() : Messages.getString("Generic.LabelEmpty", l); // $NON-NLS-1$ setElements(fe.getId(), IDProcess, name); temp.append( "* name=" + name + " ID=" + fe.getId() // $NON-NLS-1$ //$NON-NLS-2$ + "\n"); //$NON-NLS-1$ } } else if (fe instanceof IntermediateThrowEvent) { IntermediateThrowEvent a = (IntermediateThrowEvent) fe; if (a.getName() == null || (a.getName().length() == 0)) { num++; elementsBPMN.add(fe); String name = fe.getName() != null ? fe.getName() : Messages.getString("Generic.LabelEmpty", l); // $NON-NLS-1$ setElements(fe.getId(), IDProcess, name); temp.append( "* name=" + name + " ID=" + fe.getId() // $NON-NLS-1$ //$NON-NLS-2$ + "\n"); //$NON-NLS-1$ } } } } } if (num > 0) { this.Suggestion += Messages.getString("LabelingEvents.SuggestionKO", l); // $NON-NLS-1$ this.status = false; } else { this.status = true; this.Suggestion += Messages.getString("LabelingEvents.SuggestionOK", l); // $NON-NLS-1$ } }