@Test public void startBusinessProcess() throws Exception { Long taskId = 500L; String testTitle = "Test title"; String processId = "500"; String businessProcessName = "acmDocumentWorkflow"; List<AcmParticipant> partList = new ArrayList<>(); partList.add(new AcmParticipant()); String taskDefKey = "taskDefinitionKey"; Map<String, Object> pVars = new HashMap<>(); Map<String, Object> taskLocalVars = new HashMap<>(); String objectTypeTask = "TASK"; String title = "Test title"; Task task = new TaskEntity(taskId.toString()); pVars.put("reviewers", Arrays.asList("jerry", "bob", "mickey")); pVars.put("taskName", testTitle); pVars.put("documentAuthor", "DOCUMENT_AUTHOR"); pVars.put("formXmlId", null); pVars.put("candidateGroups", "TEST_GROUP"); pVars.put("OBJECT_TYPE", "FILE"); pVars.put("OBJECT_ID", 500L); pVars.put("OBJECT_NAME", "DOCUMENT_NAME"); pVars.put("PARENT_OBJECT_TYPE", "CASE_FILE"); pVars.put("PARENT_OBJECT_ID", 500L); expect(mockRuntimeService.startProcessInstanceByKey(businessProcessName, pVars)).andReturn(mockProcessInstance); expect(mockProcessInstance.getProcessInstanceId()).andReturn(processId); expect(mockTaskService.createTaskQuery()).andReturn(mockTaskQuery); expect(mockTaskQuery.processInstanceId(processId)).andReturn(mockTaskQuery); expect(mockTaskQuery.singleResult()).andReturn(mockTask); expect(mockTask.getId()).andReturn(taskId.toString()).atLeastOnce(); expect(mockTask.getDueDate()).andReturn(new Date()); expect(mockTask.getPriority()).andReturn(50); expect(mockTask.getName()).andReturn(testTitle); expect(mockTask.getProcessVariables()).andReturn(pVars).atLeastOnce(); expect(mockTask.getTaskLocalVariables()).andReturn(taskLocalVars).atLeastOnce(); expect(mockTask.getAssignee()).andReturn("test").times(2); expect(mockTask.getProcessDefinitionId()).andReturn(processId); expect(mockTask.getCreateTime()).andReturn(new Date()).times(2); expect(mockTask.getOwner()).andReturn("test"); expect(mockTask.getProcessInstanceId()).andReturn(processId).atLeastOnce(); expect(mockTask.getTaskDefinitionKey()).andReturn(taskDefKey); expect(mockRepositoryService.createProcessDefinitionQuery()).andReturn(mockProcessDefinitionQuery); expect(mockProcessDefinitionQuery.processDefinitionId(processId)).andReturn(mockProcessDefinitionQuery); expect(mockProcessDefinitionQuery.singleResult()).andReturn(mockProcessDefinition); expect(mockProcessDefinition.getName()).andReturn("processName"); expect(mockRepositoryService.getBpmnModel(processId)).andReturn(mockBpmnModel); expect(mockBpmnModel.getProcesses()).andReturn(Arrays.asList(mockProcess)); expect(mockProcess.getFlowElementRecursive(taskDefKey)).andReturn(mockFlowElement); expect(mockFlowElement.getFormProperties()).andReturn(Arrays.asList(mockFormProperty)); expect(mockFormProperty.getName()).andReturn("Test Outcome").atLeastOnce(); expect(mockFormProperty.getId()).andReturn("TestOutcome").atLeastOnce(); expect(mockFormProperty.getFormValues()).andReturn(Arrays.asList(mockFormValue)); expect(mockFormValue.getId()).andReturn("formValueId").atLeastOnce(); expect(mockFormValue.getName()).andReturn("formValueName").atLeastOnce(); expect(mockTaskService.getIdentityLinksForTask(task.getId())).andReturn(new ArrayList<>()); expect(mockParticipantDao.findParticipantsForObject("TASK", taskId)).andReturn(partList); expect(mockAcmContainerDao.findByObjectTypeAndIdOrCreate(objectTypeTask, taskId, null, title)).andReturn(mockAcmContainer); replayAll(); AcmTask createdAcmTask = unit.startBusinessProcess(pVars, businessProcessName); verifyAll(); assertNotNull(createdAcmTask); assertEquals(createdAcmTask.getTaskId(), taskId); assertEquals(createdAcmTask.getTitle(), testTitle); }
@Override public AcmTask startBusinessProcess(Map<String, Object> pVars, String businessProcessName) throws AcmTaskException { ProcessInstance pi = getActivitiRuntimeService().startProcessInstanceByKey(businessProcessName, pVars); Task activitiTask = getActivitiTaskService().createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult(); AcmTask createdAcmTask = acmTaskFromActivitiTask(activitiTask, activitiTask.getProcessVariables(), activitiTask.getTaskLocalVariables()); return createdAcmTask; }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public AcmTask startBusinessProcess(Map<String, Object> pVars, String businessProcessName) throws AcmTaskException { ProcessInstance pi = getActivitiRuntimeService().startProcessInstanceByKey(businessProcessName, pVars); Task activitiTask = getActivitiTaskService().createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult(); AcmTask createdAcmTask = acmTaskFromActivitiTask(activitiTask, activitiTask.getProcessVariables(), activitiTask.getTaskLocalVariables()); return createdAcmTask; } }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public AcmTask startBusinessProcess(Map<String, Object> pVars, String businessProcessName) throws AcmTaskException { ProcessInstance pi = getActivitiRuntimeService().startProcessInstanceByKey(businessProcessName, pVars); Task activitiTask = getActivitiTaskService().createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult(); AcmTask createdAcmTask = acmTaskFromActivitiTask(activitiTask, activitiTask.getProcessVariables(), activitiTask.getTaskLocalVariables()); return createdAcmTask; }  }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public AcmTask startBusinessProcess(Map<String, Object> pVars, String businessProcessName) throws AcmTaskException { ProcessInstance pi = getActivitiRuntimeService().startProcessInstanceByKey(businessProcessName, pVars); Task activitiTask = getActivitiTaskService().createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult(); AcmTask createdAcmTask = acmTaskFromActivitiTask(activitiTask, activitiTask.getProcessVariables(), activitiTask.getTaskLocalVariables()); return createdAcmTask; }  @Override List<ProcessInstance> findProcessesByProcessVariables(Map<String, Object> matchProcessVariables); @Override boolean isProcessActive(String businessProcessId); @Override boolean isWaitingOnReceiveTask(String businessProcessId, String receiveTaskId); @Override T readProcessVariable(String businessProcessId, String processVariableKey, boolean readFromHistory); @Override void writeProcessVariable(String businessProcessId, String processVariableKey, Object processVariableValue); @Override void signalTask(String processInstanceId, String receiveTaskId); @Override void messageTask(String taskId, String messageName); @Override @Transactional AcmTask createAdHocTask(AcmTask in); @Override @Transactional AcmTask save(AcmTask in); @Override void ensureCorrectAssigneeInParticipants(AcmTask in); @Override @Transactional AcmTask completeTask(Principal userThatCompletedTheTask, Long taskId); @Override AcmTask completeTask(Principal userThatCompletedTheTask, Long taskId, String outcomePropertyName, String outcomeId); @Override @Transactional AcmTask deleteTask(Principal userThatCompletedTheTask, Long taskId); @Override List<AcmTask> tasksForUser(String user); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) List<Long> findTasksIdsForParentObjectIdAndParentObjectType(String parentObjectType, Long parentObjectId); List<AcmTask> findByVariableForObjectTypeAndId(String name, String value, String objectType, Long objectId); @Override List<AcmTask> allTasks(); @Override List<AcmTask> pastDueTasks(); @Override @Transactional void claimTask(Long taskId, String userId); @Override @Transactional void unclaimTask(Long taskId); @Override @Transactional void deleteProcessInstance(String parentId, String processId, String deleteReason, Authentication authentication,
            String ipAddress); @Override List<AcmTask> dueSpecificDateTasks(NumberOfDays numberOfDaysFromToday); @Override AcmTask findById(Long taskId); @Override List<WorkflowHistoryInstance> getWorkflowHistory(String id, boolean adhoc); @Override List<AcmTask> getTasksModifiedSince(Date lastModified, int start, int pageSize); @Override void createFolderForTaskEvent(AcmTask task); @Override AcmTask acmTaskFromActivitiTask(Task activitiTask); @Override AcmTask acmTaskFromActivitiTask(Task activitiTask, Map<String, Object> processVariables, Map<String, Object> localVariables); @Override AcmTask acmTaskFromActivitiTask(Task activitiTask, Map<String, Object> processVariables, Map<String, Object> localVariables,
            String taskEventName); @Override byte[] getDiagram(Long id); @Override byte[] getDiagram(String processId); @Override AcmTask startBusinessProcess(Map<String, Object> pVars, String businessProcessName); RuntimeService getActivitiRuntimeService(); void setActivitiRuntimeService(RuntimeService activitiRuntimeService); TaskService getActivitiTaskService(); void setActivitiTaskService(TaskService activitiTaskService); RepositoryService getActivitiRepositoryService(); void setActivitiRepositoryService(RepositoryService activitiRepositoryService); HistoryService getActivitiHistoryService(); void setActivitiHistoryService(HistoryService activitiHistoryService); Map<String, Integer> getPriorityLevelToNumberMap(); void setPriorityLevelToNumberMap(Map<String, Integer> priorityLevelToNumberMap); Map<String, List<String>> getRequiredFieldsPerOutcomeMap(); void setRequiredFieldsPerOutcomeMap(Map<String, List<String>> requiredFieldsPerOutcomeMap); UserDao getUserDao(); void setUserDao(UserDao userDao); AcmParticipantDao getParticipantDao(); void setParticipantDao(AcmParticipantDao participantDao); DataAccessPrivilegeListener getDataAccessPrivilegeListener(); void setDataAccessPrivilegeListener(DataAccessPrivilegeListener dataAccessPrivilegeListener); TaskBusinessRule getTaskBusinessRule(); void setTaskBusinessRule(TaskBusinessRule taskBusinessRule); EcmFileService getFileService(); void setFileService(EcmFileService fileService); AcmContainerDao getContainerFolderDao(); void setContainerFolderDao(AcmContainerDao containerFolderDao); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); AuditPropertyEntityAdapter getAuditPropertyEntityAdapter(); void setAuditPropertyEntityAdapter(AuditPropertyEntityAdapter auditPropertyEntityAdapter); TaskEventPublisher getTaskEventPublisher(); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); @Override AcmNotifiableEntity findEntity(Long id); @Override String getSupportedNotifiableObjectType(); EcmFileParticipantService getFileParticipantService(); void setFileParticipantService(EcmFileParticipantService fileParticipantService); @Override String getSupportedObjectType(); @Override AcmTask find(Long id); @Override List<AcmTask> findAll(); @Override List<AcmTask> findAllOrderBy(String column); @Override List<AcmTask> findModifiedSince(Date lastModified, int startRow, int pageSize); @Override TypedQuery<AcmTask> getSortedQuery(String sort); }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public AcmTask startBusinessProcess(Map<String, Object> pVars, String businessProcessName) throws AcmTaskException { ProcessInstance pi = getActivitiRuntimeService().startProcessInstanceByKey(businessProcessName, pVars); Task activitiTask = getActivitiTaskService().createTaskQuery().processInstanceId(pi.getProcessInstanceId()).singleResult(); AcmTask createdAcmTask = acmTaskFromActivitiTask(activitiTask, activitiTask.getProcessVariables(), activitiTask.getTaskLocalVariables()); return createdAcmTask; }  @Override List<ProcessInstance> findProcessesByProcessVariables(Map<String, Object> matchProcessVariables); @Override boolean isProcessActive(String businessProcessId); @Override boolean isWaitingOnReceiveTask(String businessProcessId, String receiveTaskId); @Override T readProcessVariable(String businessProcessId, String processVariableKey, boolean readFromHistory); @Override void writeProcessVariable(String businessProcessId, String processVariableKey, Object processVariableValue); @Override void signalTask(String processInstanceId, String receiveTaskId); @Override void messageTask(String taskId, String messageName); @Override @Transactional AcmTask createAdHocTask(AcmTask in); @Override @Transactional AcmTask save(AcmTask in); @Override void ensureCorrectAssigneeInParticipants(AcmTask in); @Override @Transactional AcmTask completeTask(Principal userThatCompletedTheTask, Long taskId); @Override AcmTask completeTask(Principal userThatCompletedTheTask, Long taskId, String outcomePropertyName, String outcomeId); @Override @Transactional AcmTask deleteTask(Principal userThatCompletedTheTask, Long taskId); @Override List<AcmTask> tasksForUser(String user); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) List<Long> findTasksIdsForParentObjectIdAndParentObjectType(String parentObjectType, Long parentObjectId); List<AcmTask> findByVariableForObjectTypeAndId(String name, String value, String objectType, Long objectId); @Override List<AcmTask> allTasks(); @Override List<AcmTask> pastDueTasks(); @Override @Transactional void claimTask(Long taskId, String userId); @Override @Transactional void unclaimTask(Long taskId); @Override @Transactional void deleteProcessInstance(String parentId, String processId, String deleteReason, Authentication authentication,
            String ipAddress); @Override List<AcmTask> dueSpecificDateTasks(NumberOfDays numberOfDaysFromToday); @Override AcmTask findById(Long taskId); @Override List<WorkflowHistoryInstance> getWorkflowHistory(String id, boolean adhoc); @Override List<AcmTask> getTasksModifiedSince(Date lastModified, int start, int pageSize); @Override void createFolderForTaskEvent(AcmTask task); @Override AcmTask acmTaskFromActivitiTask(Task activitiTask); @Override AcmTask acmTaskFromActivitiTask(Task activitiTask, Map<String, Object> processVariables, Map<String, Object> localVariables); @Override AcmTask acmTaskFromActivitiTask(Task activitiTask, Map<String, Object> processVariables, Map<String, Object> localVariables,
            String taskEventName); @Override byte[] getDiagram(Long id); @Override byte[] getDiagram(String processId); @Override AcmTask startBusinessProcess(Map<String, Object> pVars, String businessProcessName); RuntimeService getActivitiRuntimeService(); void setActivitiRuntimeService(RuntimeService activitiRuntimeService); TaskService getActivitiTaskService(); void setActivitiTaskService(TaskService activitiTaskService); RepositoryService getActivitiRepositoryService(); void setActivitiRepositoryService(RepositoryService activitiRepositoryService); HistoryService getActivitiHistoryService(); void setActivitiHistoryService(HistoryService activitiHistoryService); Map<String, Integer> getPriorityLevelToNumberMap(); void setPriorityLevelToNumberMap(Map<String, Integer> priorityLevelToNumberMap); Map<String, List<String>> getRequiredFieldsPerOutcomeMap(); void setRequiredFieldsPerOutcomeMap(Map<String, List<String>> requiredFieldsPerOutcomeMap); UserDao getUserDao(); void setUserDao(UserDao userDao); AcmParticipantDao getParticipantDao(); void setParticipantDao(AcmParticipantDao participantDao); DataAccessPrivilegeListener getDataAccessPrivilegeListener(); void setDataAccessPrivilegeListener(DataAccessPrivilegeListener dataAccessPrivilegeListener); TaskBusinessRule getTaskBusinessRule(); void setTaskBusinessRule(TaskBusinessRule taskBusinessRule); EcmFileService getFileService(); void setFileService(EcmFileService fileService); AcmContainerDao getContainerFolderDao(); void setContainerFolderDao(AcmContainerDao containerFolderDao); EcmFileDao getFileDao(); void setFileDao(EcmFileDao fileDao); AuditPropertyEntityAdapter getAuditPropertyEntityAdapter(); void setAuditPropertyEntityAdapter(AuditPropertyEntityAdapter auditPropertyEntityAdapter); TaskEventPublisher getTaskEventPublisher(); void setTaskEventPublisher(TaskEventPublisher taskEventPublisher); ObjectConverter getObjectConverter(); void setObjectConverter(ObjectConverter objectConverter); @Override AcmNotifiableEntity findEntity(Long id); @Override String getSupportedNotifiableObjectType(); EcmFileParticipantService getFileParticipantService(); void setFileParticipantService(EcmFileParticipantService fileParticipantService); @Override String getSupportedObjectType(); @Override AcmTask find(Long id); @Override List<AcmTask> findAll(); @Override List<AcmTask> findAllOrderBy(String column); @Override List<AcmTask> findModifiedSince(Date lastModified, int startRow, int pageSize); @Override TypedQuery<AcmTask> getSortedQuery(String sort);  }