@Test public void findById_noSuchTask() throws Exception { Long taskId = 500L; expect(mockTaskService.createTaskQuery()).andReturn(mockTaskQuery); expect(mockTaskQuery.taskId(String.valueOf(taskId))).andReturn(mockTaskQuery); expect(mockTaskQuery.includeProcessVariables()).andReturn(mockTaskQuery); expect(mockTaskQuery.includeTaskLocalVariables()).andReturn(mockTaskQuery); expect(mockTaskQuery.singleResult()).andReturn(null); expect(mockHistoryService.createHistoricTaskInstanceQuery()).andReturn(mockHistoricTaskInstanceQuery); expect(mockHistoricTaskInstanceQuery.taskId(String.valueOf(taskId))).andReturn(mockHistoricTaskInstanceQuery); expect(mockHistoricTaskInstanceQuery.includeProcessVariables()).andReturn(mockHistoricTaskInstanceQuery); expect(mockHistoricTaskInstanceQuery.includeTaskLocalVariables()).andReturn(mockHistoricTaskInstanceQuery); expect(mockHistoricTaskInstanceQuery.singleResult()).andReturn(null); replayAll(); try { unit.findById(taskId); fail("Should have exception since task was not found"); } catch (AcmTaskException ate) { } verifyAll(); }
@Override public AcmTask findById(Long taskId) throws AcmTaskException { log.info("Finding task with ID '{}'", taskId); AcmTask retval; Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(String.valueOf(taskId)).includeProcessVariables() .includeTaskLocalVariables().singleResult(); if (activitiTask != null) { retval = acmTaskFromActivitiTask(activitiTask); return retval; } else { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(String.valueOf(taskId)) .includeProcessVariables().includeTaskLocalVariables().singleResult(); if (hti != null) { retval = acmTaskFromHistoricActivitiTask(hti); return retval; } } throw new AcmTaskException("Task with ID '" + taskId + "' does not exist."); }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public AcmTask findById(Long taskId) throws AcmTaskException { log.info("Finding task with ID '{}'", taskId); AcmTask retval; Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(String.valueOf(taskId)).includeProcessVariables() .includeTaskLocalVariables().singleResult(); if (activitiTask != null) { retval = acmTaskFromActivitiTask(activitiTask); return retval; } else { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(String.valueOf(taskId)) .includeProcessVariables().includeTaskLocalVariables().singleResult(); if (hti != null) { retval = acmTaskFromHistoricActivitiTask(hti); return retval; } } throw new AcmTaskException("Task with ID '" + taskId + "' does not exist."); } }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public AcmTask findById(Long taskId) throws AcmTaskException { log.info("Finding task with ID '{}'", taskId); AcmTask retval; Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(String.valueOf(taskId)).includeProcessVariables() .includeTaskLocalVariables().singleResult(); if (activitiTask != null) { retval = acmTaskFromActivitiTask(activitiTask); return retval; } else { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(String.valueOf(taskId)) .includeProcessVariables().includeTaskLocalVariables().singleResult(); if (hti != null) { retval = acmTaskFromHistoricActivitiTask(hti); return retval; } } throw new AcmTaskException("Task with ID '" + taskId + "' does not exist."); }  }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public AcmTask findById(Long taskId) throws AcmTaskException { log.info("Finding task with ID '{}'", taskId); AcmTask retval; Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(String.valueOf(taskId)).includeProcessVariables() .includeTaskLocalVariables().singleResult(); if (activitiTask != null) { retval = acmTaskFromActivitiTask(activitiTask); return retval; } else { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(String.valueOf(taskId)) .includeProcessVariables().includeTaskLocalVariables().singleResult(); if (hti != null) { retval = acmTaskFromHistoricActivitiTask(hti); return retval; } } throw new AcmTaskException("Task with ID '" + taskId + "' does not exist."); }  @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 findById(Long taskId) throws AcmTaskException { log.info("Finding task with ID '{}'", taskId); AcmTask retval; Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(String.valueOf(taskId)).includeProcessVariables() .includeTaskLocalVariables().singleResult(); if (activitiTask != null) { retval = acmTaskFromActivitiTask(activitiTask); return retval; } else { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(String.valueOf(taskId)) .includeProcessVariables().includeTaskLocalVariables().singleResult(); if (hti != null) { retval = acmTaskFromHistoricActivitiTask(hti); return retval; } } throw new AcmTaskException("Task with ID '" + taskId + "' does not exist."); }  @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);  }