@Test @Deployment(resources = {PROCESS_RESOURCE}) public void processRejected() throws InterruptedException { Map<String, Object> procVars = createStartFormVariables(); ProcessInstance pi = activitiRule .getProcessEngine() .getRuntimeService() .startProcessInstanceByKey(PROCESS_KEY, procVars); // assertNotNull(pi); Task task = activitiRule.getTaskService().createTaskQuery().singleResult(); // assertNotNull(task); Map<String, Object> taskVars = new HashMap<String, Object>(); taskVars.put("decide", "reject"); activitiRule.getProcessEngine().getTaskService().complete(task.getId(), taskVars); HistoryService historyService = activitiRule.getHistoryService(); HistoricProcessInstance historicProcessInstance = historyService .createHistoricProcessInstanceQuery() .processInstanceId(pi.getProcessInstanceId()) .singleResult(); // assertNotNull(historicProcessInstance); // check that only one process running // assertEquals(pi.getProcessInstanceId(), historicProcessInstance.getId()); List<HistoricActivityInstance> activityList = historyService .createHistoricActivityInstanceQuery() .processInstanceId(pi.getProcessInstanceId()) .list(); JobQuery jquery = activitiRule.getManagementService().createJobQuery(); // check how many tasks must be done // assertEquals("done task count", 6, activityList.size()); // and the job is done // assertEquals("job is done", 0, jquery.count()); // assertEquals(0, activitiRule.getProcessEngine().getRuntimeService() // .createProcessInstanceQuery().count()); }
@Test @Deployment(resources = {PROCESS_RESOURCE}) public void startProcessInstance() throws InterruptedException { Map<String, Object> procVars = createStartFormVariables(); ProcessInstance pi = activitiRule .getProcessEngine() .getRuntimeService() .startProcessInstanceByKey(PROCESS_KEY, procVars); // assertNotNull(pi); activitiRule .getProcessEngine() .getRuntimeService() .deleteProcessInstance(pi.getProcessInstanceId(), "not needed, created only for test"); }
@Before public void injectDependencies() throws Exception { MockitoAnnotations.initMocks(this); Mockitos.register(this); new TestContextManager(getClass()).prepareTestInstance(this); processEngine = TestHelper.getProcessEngine(activitiRule.getConfigurationResource()); activitiRule.setProcessEngine(processEngine); ActivitiFluentTestHelper.setUpEngineAndServices( activitiRule.getProcessEngine(), activitiRule.getProcessEngine().getRepositoryService(), activitiRule.getProcessEngine().getRuntimeService(), activitiRule.getProcessEngine().getTaskService(), activitiRule.getProcessEngine().getHistoryService(), activitiRule.getProcessEngine().getIdentityService(), activitiRule.getProcessEngine().getManagementService(), activitiRule.getProcessEngine().getFormService()); }