@Deployment public void testGetBpmnModel() { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); // Some basic assertions BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); assertNotNull(bpmnModel); assertEquals(1, bpmnModel.getProcesses().size()); assertTrue(bpmnModel.getLocationMap().size() > 0); assertTrue(bpmnModel.getFlowLocationMap().size() > 0); // Test the flow org.activiti.bpmn.model.Process process = bpmnModel.getProcesses().get(0); List<StartEvent> startEvents = process.findFlowElementsOfType(StartEvent.class); assertEquals(1, startEvents.size()); StartEvent startEvent = startEvents.get(0); assertEquals(1, startEvent.getOutgoingFlows().size()); assertEquals(0, startEvent.getIncomingFlows().size()); String nextElementId = startEvent.getOutgoingFlows().get(0).getTargetRef(); UserTask userTask = (UserTask) process.getFlowElement(nextElementId); assertEquals("First Task", userTask.getName()); assertEquals(1, userTask.getOutgoingFlows().size()); assertEquals(1, userTask.getIncomingFlows().size()); nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef(); ParallelGateway parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId); assertEquals(2, parallelGateway.getOutgoingFlows().size()); nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef(); assertEquals(1, parallelGateway.getIncomingFlows().size()); userTask = (UserTask) process.getFlowElement(nextElementId); assertEquals(1, userTask.getOutgoingFlows().size()); nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef(); parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId); assertEquals(1, parallelGateway.getOutgoingFlows().size()); assertEquals(2, parallelGateway.getIncomingFlows().size()); nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef(); EndEvent endEvent = (EndEvent) process.getFlowElement(nextElementId); assertEquals(0, endEvent.getOutgoingFlows().size()); assertEquals(1, endEvent.getIncomingFlows().size()); }
private String getActivitiJobXml(String namespace, String jobName) { BpmnModel bpmnModel = new BpmnModel(); Process process = new Process(); process.setId(namespace + '.' + jobName); { StartEvent element = new StartEvent(); element.setId("start"); process.addFlowElement(element); } { EndEvent element = new EndEvent(); element.setId("end"); process.addFlowElement(element); } process.addFlowElement(new SequenceFlow("start", "end")); bpmnModel.addProcess(process); return getActivitiXmlFromBpmnModel(bpmnModel); }