Java Code Examples for org.flowable.bpmn.model.BpmnModel#addProcess()
The following examples show how to use
org.flowable.bpmn.model.BpmnModel#addProcess() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OneTaskProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
private BpmnModel decorateTestSkeletonAsProcess(List<FlowNode> testFlowNodesSkeleton) { ArrayList<FlowNode> flowNodes = new ArrayList<>(testFlowNodesSkeleton); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); flowNodes.add(0, startEvent); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); flowNodes.add(endEvent); BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = new org.flowable.bpmn.model.Process(); model.addProcess(process); model.setTargetNamespace("pUnit"); process.setId("oneTaskProcessPUnitTest"); process.setName("ProcessUnit test for oneTaskProcess"); for (int i=0; i<flowNodes.size() -1; i++) { process.addFlowElement(flowNodes.get(i)); process.addFlowElement(new SequenceFlow(flowNodes.get(i).getId(), flowNodes.get(i+1).getId())); } process.addFlowElement(flowNodes.get(flowNodes.size()-1)); return model; }
Example 2
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Since the 'one task process' is used everywhere the actual process content doesn't matter, instead of copying around the BPMN 2.0 xml one could use this method which gives a {@link BpmnModel} * version of the same process back. */ public BpmnModel createOneTaskTestProcess() { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = new org.flowable.bpmn.model.Process(); model.addProcess(process); process.setId("oneTaskProcess"); process.setName("The one task process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The Task"); userTask.setId("theTask"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "theTask")); process.addFlowElement(new SequenceFlow("theTask", "theEnd")); return model; }
Example 3
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
public BpmnModel createTwoTasksTestProcess() { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = new org.flowable.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example 4
Source File: TestProcessUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
public static BpmnModel createTwoTasksBpmnModel() { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = new org.flowable.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second org.flowable.task.service.Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example 5
Source File: DefaultProcessValidatorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testAllNonExecutableProcesses() { BpmnModel bpmnModel = new BpmnModel(); for (int i = 0; i < 5; i++) { org.flowable.bpmn.model.Process process = TestProcessUtil.createOneTaskProcess(); process.setExecutable(false); bpmnModel.addProcess(process); } List<ValidationError> errors = processValidator.validate(bpmnModel); Assert.assertEquals(1, errors.size()); }
Example 6
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Since the 'one task process' is used everywhere the actual process content doesn't matter, instead of copying around the BPMN 2.0 xml one could use this method which gives a {@link BpmnModel} * version of the same process back. */ public BpmnModel createOneTaskTestProcess() { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = createOneTaskProcess(); model.addProcess(process); return model; }
Example 7
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
public BpmnModel createOneTaskTestProcessWithCandidateStarterGroup() { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = createOneTaskProcess(); process.getCandidateStarterGroups().add("testGroup"); model.addProcess(process); return model; }
Example 8
Source File: AbstractFlowableTestCase.java From flowable-engine with Apache License 2.0 | 5 votes |
public BpmnModel createTwoTasksTestProcess() { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = new org.flowable.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example 9
Source File: TestProcessUtil.java From flowable-engine with Apache License 2.0 | 5 votes |
public static BpmnModel createTwoTasksBpmnModel() { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = new org.flowable.bpmn.model.Process(); model.addProcess(process); process.setId("twoTasksProcess"); process.setName("The two tasks process"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); UserTask userTask = new UserTask(); userTask.setName("The First org.flowable.task.service.Task"); userTask.setId("task1"); userTask.setAssignee("kermit"); process.addFlowElement(userTask); UserTask userTask2 = new UserTask(); userTask2.setName("The Second org.flowable.task.service.Task"); userTask2.setId("task2"); userTask2.setAssignee("kermit"); process.addFlowElement(userTask2); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "task1")); process.addFlowElement(new SequenceFlow("start", "task2")); process.addFlowElement(new SequenceFlow("task1", "theEnd")); process.addFlowElement(new SequenceFlow("task2", "theEnd")); return model; }
Example 10
Source File: DefaultProcessValidatorTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testAllNonExecutableProcesses() { BpmnModel bpmnModel = new BpmnModel(); for (int i = 0; i < 5; i++) { org.flowable.bpmn.model.Process process = TestProcessUtil.createOneTaskProcess(); process.setExecutable(false); bpmnModel.addProcess(process); } List<ValidationError> errors = processValidator.validate(bpmnModel); assertThat(errors).hasSize(1); }
Example 11
Source File: TestProcessUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
/** * Since the 'one task process' is used everywhere the actual process content doesn't matter, instead of copying around the BPMN 2.0 xml one could use this method which gives a {@link BpmnModel} * version of the same process back. */ public static BpmnModel createOneTaskBpmnModel() { BpmnModel model = new BpmnModel(); model.addProcess(createOneTaskProcess()); return model; }
Example 12
Source File: OneTaskProcessTest.java From flowable-engine with Apache License 2.0 | 4 votes |
private BpmnModel createTestProcessBpmnModel(String processToTestDefinitionKey) { BpmnModel model = new BpmnModel(); org.flowable.bpmn.model.Process process = new org.flowable.bpmn.model.Process(); model.addProcess(process); model.setTargetNamespace("pUnit"); process.setId("oneTaskProcessPUnitTest"); process.setName("ProcessUnit test for oneTaskProcess"); StartEvent startEvent = new StartEvent(); startEvent.setId("start"); process.addFlowElement(startEvent); ScriptTask startProcess = new ScriptTask(); startProcess.setName("Start oneTask process"); startProcess.setId("startProcess"); startProcess.setScriptFormat("groovy"); startProcess.setAsynchronous(true); startProcess.setScript( "import org.flowable.engine.impl.context.Context;\n" + "\n" + "execution.setVariable('processInstanceId', Context.getProcessEngineConfiguration().getRuntimeService().createProcessInstanceBuilder().processDefinitionKey('" + processToTestDefinitionKey + "').start().getId());" ); process.addFlowElement(startProcess); ScriptTask completeTask = new ScriptTask(); completeTask.setName("Complete task"); completeTask.setId("completeTask"); completeTask.setAsynchronous(true); completeTask.setScriptFormat("groovy"); completeTask.setScript( "import org.flowable.engine.impl.context.Context;\n" + "\n" + "taskId = Context.getProcessEngineConfiguration().getTaskService().createTaskQuery().processInstanceId(processInstanceId).singleResult().getId();\n" + "Context.getProcessEngineConfiguration().getTaskService().complete(taskId);" ); process.addFlowElement(completeTask); ScriptTask assertTask = new ScriptTask(); assertTask.setName("Assert task"); assertTask.setId("assertTask"); assertTask.setAsynchronous(true); assertTask.setScriptFormat("groovy"); assertTask.setScript( "import org.flowable.engine.impl.context.Context;\n" + "import static org.hamcrest.core.Is.is;\n" + "import static org.flowable.examples.test.MatcherAssert.assertThat;\n" + "\n" + "assertThat(Context.getProcessEngineConfiguration().getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).count(), is(0L));" ); process.addFlowElement(assertTask); EndEvent endEvent = new EndEvent(); endEvent.setId("theEnd"); process.addFlowElement(endEvent); process.addFlowElement(new SequenceFlow("start", "startProcess")); process.addFlowElement(new SequenceFlow("startProcess", "completeTask")); process.addFlowElement(new SequenceFlow("completeTask", "assertTask")); process.addFlowElement(new SequenceFlow("assertTask", "theEnd")); return model; }
Example 13
Source File: TestProcessUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
/** * Since the 'one task process' is used everywhere the actual process content doesn't matter, instead of copying around the BPMN 2.0 xml one could use this method which gives a {@link BpmnModel} * version of the same process back. */ public static BpmnModel createOneTaskBpmnModel() { BpmnModel model = new BpmnModel(); model.addProcess(createOneTaskProcess()); return model; }
Example 14
Source File: BpmnModelWithDataObjectTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test public void convertModelToXML() throws Exception { BpmnModel bpmnModel = new BpmnModel(); Process process = new Process(); process.setId("myProcess"); bpmnModel.addProcess(process); List<ValuedDataObject> dataObjects = new ArrayList<>(); StringDataObject dataObject = new StringDataObject(); dataObject.setId("dObj1"); dataObject.setName("stringDataObject"); dataObject.setValue("test"); ItemDefinition itemDefinition = new ItemDefinition(); itemDefinition.setStructureRef("xsd:string"); dataObject.setItemSubjectRef(itemDefinition); dataObjects.add(dataObject); process.setDataObjects(dataObjects); process.addFlowElement(dataObject); StartEvent startEvent = new StartEvent(); startEvent.setId("event1"); EndEvent endEvent = new EndEvent(); endEvent.setId("event2"); SequenceFlow flow = new SequenceFlow("event1", "event2"); process.addFlowElement(startEvent); process.addFlowElement(endEvent); process.addFlowElement(flow); BpmnModel parsedModel = exportAndReadXMLFile(bpmnModel); Process mainProcess = parsedModel.getMainProcess(); // verify the main process data objects List<ValuedDataObject> processDataObjects = mainProcess.getDataObjects(); assertThat(processDataObjects).hasSize(1); Map<String, ValuedDataObject> objectMap = new HashMap<>(); for (ValuedDataObject valueObj : dataObjects) { objectMap.put(valueObj.getId(), valueObj); } ValuedDataObject dataObj = objectMap.get("dObj1"); assertThat(dataObj.getId()).isEqualTo("dObj1"); assertThat(dataObj.getName()).isEqualTo("stringDataObject"); assertThat(dataObj.getItemSubjectRef().getStructureRef()).isEqualTo("xsd:string"); assertThat(dataObj.getValue()).isEqualTo("test"); }