@Test public void tasksForUser() throws Exception { String user = "user"; Long taskId = 500L; Date dueDate = new Date(); String acmPriority = "Medium"; int activitiPriority = 50; String title = "task Title"; String processId = "processId"; String processName = "processName"; String objectTypeTask = "TASK"; Long objectId = 250L; String objectType = "objectType"; String objectName = "objectName"; Map<String, Object> pvars = new HashMap<>(); pvars.put("OBJECT_ID", objectId); pvars.put("OBJECT_TYPE", objectType); pvars.put("OBJECT_NAME", objectName); Map<String, Object> taskLocalVars = new HashMap<>(); taskLocalVars.put("START_DATE", new Date()); taskLocalVars.put("PERCENT_COMPLETE", 25); taskLocalVars.put("DETAILS", "details"); List<AcmParticipant> partList = new ArrayList<>(); partList.add(new AcmParticipant()); expect(mockTaskService.createTaskQuery()).andReturn(mockTaskQuery); expect(mockTaskQuery.taskAssignee(user)).andReturn(mockTaskQuery); expect(mockTaskQuery.includeProcessVariables()).andReturn(mockTaskQuery); expect(mockTaskQuery.includeTaskLocalVariables()).andReturn(mockTaskQuery); expect(mockTaskQuery.orderByDueDate()).andReturn(mockTaskQuery); expect(mockTaskQuery.desc()).andReturn(mockTaskQuery); expect(mockTaskQuery.list()).andReturn(Arrays.asList(mockTask)); expect(mockTaskService.getIdentityLinksForTask(String.valueOf(taskId))).andReturn(null); expect(mockTask.getId()).andReturn(taskId.toString()).atLeastOnce(); expect(mockTask.getDueDate()).andReturn(dueDate); expect(mockTask.getPriority()).andReturn(activitiPriority); expect(mockTask.getName()).andReturn(title); expect(mockTask.getProcessVariables()).andReturn(pvars).atLeastOnce(); expect(mockTask.getTaskLocalVariables()).andReturn(taskLocalVars).atLeastOnce(); expect(mockTask.getAssignee()).andReturn(user).times(2); expect(mockTask.getProcessDefinitionId()).andReturn(processId); expect(mockTask.getCreateTime()).andReturn(null); expect(mockTask.getOwner()).andReturn(user); expect(mockTask.getProcessInstanceId()).andReturn("250").atLeastOnce(); expect(mockAcmContainerDao.findByObjectTypeAndIdOrCreate(objectTypeTask, taskId, null, title)).andReturn(mockAcmContainer); expect(mockRepositoryService.createProcessDefinitionQuery()).andReturn(mockProcessDefinitionQuery); expect(mockProcessDefinitionQuery.processDefinitionId(processId)).andReturn(mockProcessDefinitionQuery); expect(mockProcessDefinitionQuery.singleResult()).andReturn(mockProcessDefinition); expect(mockProcessDefinition.getName()).andReturn(processName); String taskDefKey = "taskDefinitionKey"; expect(mockTask.getTaskDefinitionKey()).andReturn(taskDefKey); 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(mockParticipantDao.findParticipantsForObject("TASK", taskId)).andReturn(partList); replayAll(); List<AcmTask> tasks = unit.tasksForUser(user); verifyAll(); assertEquals(1, tasks.size()); AcmTask found = tasks.get(0); assertEquals(taskId, found.getTaskId()); assertEquals(dueDate, found.getDueDate()); assertEquals(acmPriority, found.getPriority()); assertEquals(title, found.getTitle()); assertEquals(objectId, found.getAttachedToObjectId()); assertEquals(objectType, found.getAttachedToObjectType()); assertEquals(objectName, found.getAttachedToObjectName()); assertEquals(user, found.getAssignee()); assertEquals(processName, found.getBusinessProcessName()); assertFalse(found.isAdhocTask()); assertFalse(found.isCompleted()); assertNotNull(found.getTaskStartDate()); assertEquals(TaskConstants.STATE_ACTIVE, found.getStatus()); assertEquals("details", found.getDetails()); assertEquals(Integer.valueOf(25), found.getPercentComplete()); assertEquals(1, found.getAvailableOutcomes().size()); assertEquals("TestOutcome", found.getOutcomeName()); TaskOutcome taskOutcome = found.getAvailableOutcomes().get(0); assertEquals("formValueId", taskOutcome.getName()); assertEquals("formValueName", taskOutcome.getDescription()); assertEquals(partList, found.getParticipants()); }
@Override public List<AcmTask> tasksForUser(String user) { log.info("Finding all tasks for user '{}'", user); List<AcmTask> retval = new ArrayList<>(); List<Task> activitiTasks = getActivitiTaskService().createTaskQuery().taskAssignee(user).includeProcessVariables() .includeTaskLocalVariables().orderByDueDate().desc().list(); if (activitiTasks != null) { log.debug("Found '{}' tasks for user '{}'", activitiTasks.size(), user); for (Task activitiTask : activitiTasks) { AcmTask acmTask = acmTaskFromActivitiTask(activitiTask); retval.add(acmTask); } } return retval; }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public List<AcmTask> tasksForUser(String user) { log.info("Finding all tasks for user '{}'", user); List<AcmTask> retval = new ArrayList<>(); List<Task> activitiTasks = getActivitiTaskService().createTaskQuery().taskAssignee(user).includeProcessVariables() .includeTaskLocalVariables().orderByDueDate().desc().list(); if (activitiTasks != null) { log.debug("Found '{}' tasks for user '{}'", activitiTasks.size(), user); for (Task activitiTask : activitiTasks) { AcmTask acmTask = acmTaskFromActivitiTask(activitiTask); retval.add(acmTask); } } return retval; } }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public List<AcmTask> tasksForUser(String user) { log.info("Finding all tasks for user '{}'", user); List<AcmTask> retval = new ArrayList<>(); List<Task> activitiTasks = getActivitiTaskService().createTaskQuery().taskAssignee(user).includeProcessVariables() .includeTaskLocalVariables().orderByDueDate().desc().list(); if (activitiTasks != null) { log.debug("Found '{}' tasks for user '{}'", activitiTasks.size(), user); for (Task activitiTask : activitiTasks) { AcmTask acmTask = acmTaskFromActivitiTask(activitiTask); retval.add(acmTask); } } return retval; }  }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override public List<AcmTask> tasksForUser(String user) { log.info("Finding all tasks for user '{}'", user); List<AcmTask> retval = new ArrayList<>(); List<Task> activitiTasks = getActivitiTaskService().createTaskQuery().taskAssignee(user).includeProcessVariables() .includeTaskLocalVariables().orderByDueDate().desc().list(); if (activitiTasks != null) { log.debug("Found '{}' tasks for user '{}'", activitiTasks.size(), user); for (Task activitiTask : activitiTasks) { AcmTask acmTask = acmTaskFromActivitiTask(activitiTask); retval.add(acmTask); } } return retval; }  @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 List<AcmTask> tasksForUser(String user) { log.info("Finding all tasks for user '{}'", user); List<AcmTask> retval = new ArrayList<>(); List<Task> activitiTasks = getActivitiTaskService().createTaskQuery().taskAssignee(user).includeProcessVariables() .includeTaskLocalVariables().orderByDueDate().desc().list(); if (activitiTasks != null) { log.debug("Found '{}' tasks for user '{}'", activitiTasks.size(), user); for (Task activitiTask : activitiTasks) { AcmTask acmTask = acmTaskFromActivitiTask(activitiTask); retval.add(acmTask); } } return retval; }  @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);  }