@Test public void save() throws Exception { Long taskId = 500L; String assignee = "assignee"; String priority = "Low"; Date due = new Date(); String title = "title"; String objectType = "objectType"; String objectName = "objectName"; Long objectId = 400L; Date start = new Date(); String status = "status"; Integer percentComplete = 25; String details = "details"; String owner = "owner"; String candidateGroup = "candidateGroup"; String nextAssignee = "nextAssignee"; String processId = "500"; AcmTask in = new AcmTask(); in.setTaskId(taskId); in.setAssignee(assignee); in.setTaskStartDate(start); in.setStatus(status); in.setDetails(details); in.setDueDate(due); in.setPriority(priority); in.setTitle(title); in.setAttachedToObjectId(objectId); in.setAttachedToObjectType(objectType); in.setAttachedToObjectName(objectName); in.setPercentComplete(percentComplete); in.setOwner(owner); in.setCreateDate(start); in.setReworkInstructions("rework instructions"); in.setParentObjectId(2500L); in.setParentObjectType("parent object type"); in.setParentObjectName("parent object name"); in.setNextAssignee(nextAssignee); in.setWorkflowRequestType("REQUEST_TYPE"); in.setCandidateGroups(Arrays.asList(candidateGroup)); TaskOutcome selected = new TaskOutcome(); selected.setName("outcome name"); in.setTaskOutcome(selected); expect(mockTaskService.createTaskQuery()).andReturn(mockTaskQuery); expect(mockTaskQuery.taskId(taskId.toString())).andReturn(mockTaskQuery); expect(mockTaskQuery.singleResult()).andReturn(mockTask); expect(mockTaskService.getIdentityLinksForTask(String.valueOf(taskId))).andReturn(Arrays.asList(mockCandidateGroup)); expect(mockCandidateGroup.getType()).andReturn(TaskConstants.IDENTITY_LINK_TYPE_CANDIDATE); expect(mockCandidateGroup.getGroupId()).andReturn(candidateGroup).atLeastOnce(); mockTask.setAssignee(assignee); mockTask.setPriority(30); mockTask.setDueDate(due); mockTask.setName(title); mockTask.setOwner(owner); expect(mockTask.getProcessInstanceId()).andReturn(processId); expect(mockTask.getCreateTime()).andReturn(start); mockTaskService.saveTask(mockTask); mockRuntimeService.setVariable(processId, "REWORK_INSTRUCTIONS", null); expect(mockTask.getId()).andReturn(taskId.toString()).atLeastOnce(); mockTaskService.setVariableLocal(taskId.toString(), "OBJECT_TYPE", objectType); mockTaskService.setVariableLocal(taskId.toString(), "OBJECT_ID", objectId); mockTaskService.setVariableLocal(taskId.toString(), objectType, objectId); mockTaskService.setVariableLocal(taskId.toString(), "OBJECT_NAME", objectName); mockTaskService.setVariableLocal(taskId.toString(), "START_DATE", start); mockTaskService.setVariableLocal(taskId.toString(), "PERCENT_COMPLETE", percentComplete); mockTaskService.setVariableLocal(taskId.toString(), "DETAILS", details); mockTaskService.setVariableLocal(taskId.toString(), "REWORK_INSTRUCTIONS", in.getReworkInstructions()); mockTaskService.setVariableLocal(taskId.toString(), "outcome", in.getTaskOutcome().getName()); mockTaskService.setVariableLocal(taskId.toString(), "PARENT_OBJECT_ID", 2500L); mockTaskService.setVariableLocal(taskId.toString(), "PARENT_OBJECT_TYPE", "parent object type"); mockTaskService.setVariableLocal(taskId.toString(), "PARENT_OBJECT_NAME", "parent object name"); mockTaskService.setVariable(taskId.toString(), TaskConstants.VARIABLE_NAME_NEXT_ASSIGNEE, in.getNextAssignee()); mockTaskService.setVariable(taskId.toString(), TaskConstants.VARIABLE_NAME_REQUEST_TYPE, in.getWorkflowRequestType()); mockTaskService.setVariableLocal(taskId.toString(), TaskConstants.VARIABLE_NAME_PARENT_OBJECT_TITLE, null); mockTaskService.setVariableLocal(taskId.toString(), TaskConstants.VARIABLE_NAME_LEGACY_SYSTEM_ID, null); mockDataAccessPrivilegeListener.applyAssignmentAndAccessRules(in); Capture<List<AcmParticipant>> keepThese = new Capture<>(); Capture<List<AcmParticipant>> saved = new Capture<>(); List<AcmParticipant> merged = new ArrayList<>(); merged.add(new AcmParticipant()); expect(mockParticipantDao.removeAllOtherParticipantsForObject(eq("TASK"), eq(in.getTaskId()), capture(keepThese))).andReturn(0); expect(mockParticipantDao.saveParticipants(capture(saved))).andReturn(merged); replayAll(); unit.save(in); verifyAll(); assertEquals(1, keepThese.getValue().size()); assertEquals(1, saved.getValue().size()); }
@Override @Transactional public AcmTask save(AcmTask in) throws AcmTaskException { Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(in.getTaskId().toString()).singleResult(); if (activitiTask != null) { AcmTask acmTask = updateExistingActivitiTask(in, activitiTask); return acmTask; } { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(in.getTaskId().toString()) .singleResult(); if (hti == null) { throw new AcmTaskException("No such task with id '" + in.getTaskId() + "'"); } else { getParticipantDao().saveParticipants(in.getParticipants()); throw new AcmTaskException( "Task with id '" + in.getTaskId() + "' has already been completed and so " + "it cannot be updated."); } } }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override @Transactional public AcmTask save(AcmTask in) throws AcmTaskException { Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(in.getTaskId().toString()).singleResult(); if (activitiTask != null) { AcmTask acmTask = updateExistingActivitiTask(in, activitiTask); return acmTask; } { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(in.getTaskId().toString()) .singleResult(); if (hti == null) { throw new AcmTaskException("No such task with id '" + in.getTaskId() + "'"); } else { getParticipantDao().saveParticipants(in.getParticipants()); throw new AcmTaskException( "Task with id '" + in.getTaskId() + "' has already been completed and so " + "it cannot be updated."); } } } }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override @Transactional public AcmTask save(AcmTask in) throws AcmTaskException { Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(in.getTaskId().toString()).singleResult(); if (activitiTask != null) { AcmTask acmTask = updateExistingActivitiTask(in, activitiTask); return acmTask; } { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(in.getTaskId().toString()) .singleResult(); if (hti == null) { throw new AcmTaskException("No such task with id '" + in.getTaskId() + "'"); } else { getParticipantDao().saveParticipants(in.getParticipants()); throw new AcmTaskException( "Task with id '" + in.getTaskId() + "' has already been completed and so " + "it cannot be updated."); } } }  }
ActivitiTaskDao extends AcmAbstractDao<AcmTask> implements TaskDao, AcmNotificationDao { @Override @Transactional public AcmTask save(AcmTask in) throws AcmTaskException { Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(in.getTaskId().toString()).singleResult(); if (activitiTask != null) { AcmTask acmTask = updateExistingActivitiTask(in, activitiTask); return acmTask; } { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(in.getTaskId().toString()) .singleResult(); if (hti == null) { throw new AcmTaskException("No such task with id '" + in.getTaskId() + "'"); } else { getParticipantDao().saveParticipants(in.getParticipants()); throw new AcmTaskException( "Task with id '" + in.getTaskId() + "' has already been completed and so " + "it cannot be updated."); } } }  @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 @Transactional public AcmTask save(AcmTask in) throws AcmTaskException { Task activitiTask = getActivitiTaskService().createTaskQuery().taskId(in.getTaskId().toString()).singleResult(); if (activitiTask != null) { AcmTask acmTask = updateExistingActivitiTask(in, activitiTask); return acmTask; } { HistoricTaskInstance hti = getActivitiHistoryService().createHistoricTaskInstanceQuery().taskId(in.getTaskId().toString()) .singleResult(); if (hti == null) { throw new AcmTaskException("No such task with id '" + in.getTaskId() + "'"); } else { getParticipantDao().saveParticipants(in.getParticipants()); throw new AcmTaskException( "Task with id '" + in.getTaskId() + "' has already been completed and so " + "it cannot be updated."); } } }  @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);  }