Now we will test the business process that we created. For this, we will have to perform the following steps:
SimpleLeaveProcess.bpmn
file and browse to Activiti | Generate unit test, as shown in the following screenshot:src/test/java package
, as shown in the following screenshot:ProcessTestMyProcess.java
file, replace the code with the following:@Test public void startProcess() throws Exception { RepositoryService repositoryService = activitiRule.getRepositoryService(); repositoryService.createDeployment().addInputStream("SimpleLeaveProcess.bpmn20.xml", new FileInputStream(filename)).deploy(); RuntimeService runtimeService = activitiRule.getRuntimeService(); Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("Empname", "Irshad"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("leaveProcess", variableMap); assertNotNull(processInstance.getId()); System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId()); }
ProcessTestMyProcess
class file and browse to Run As | JUnit Test, as shown in the following screenshot: