CaseRuntimeDataServiceImpl implements CaseRuntimeDataService, DeploymentEventListener { @Override public List<TaskSummary> getCaseTasksAssignedAsBusinessAdmin(String caseId, String userId, List<Status> status, QueryContext queryContext) { Map<String, Object> params = new HashMap<String, Object>(); params.put("caseId", caseId + "%"); params.put("userId", userId); params.put("status", adoptList(status, allActiveStatus)); params.put("groupIds", getAuthenticatedUserRoles(identityProvider)); applyQueryContext(params, queryContext); List<TaskSummary> tasks = commandService.execute(new QueryNameCommand<List<TaskSummary>>("getCaseTasksAsBusinessAdmin", params)); return tasks; } CaseRuntimeDataServiceImpl(); CaseIdGenerator getCaseIdGenerator(); void setCaseIdGenerator(CaseIdGenerator caseIdGenerator); void setRuntimeDataService(RuntimeDataService runtimeDataService); void setCaseService(CaseService caseService); void setCommandService(TransactionalCommandService commandService); void setIdentityProvider(IdentityProvider identityProvider); void setDeploymentRolesManager(DeploymentRolesManager deploymentRolesManager); @Override void onDeploy(DeploymentEvent event); @Override void onUnDeploy(DeploymentEvent event); @Override void onActivate(DeploymentEvent event); @Override void onDeactivate(DeploymentEvent event); @Override CaseDefinition getCase(String deploymentId, String caseDefinitionId); @Override Collection<CaseDefinition> getCases(QueryContext queryContext); @Override Collection<CaseDefinition> getCases(String filter, QueryContext queryContext); @Override Collection<CaseDefinition> getCasesByDeployment(String deploymentId, QueryContext queryContext); @Override Collection<ProcessDefinition> getProcessDefinitions(QueryContext queryContext); @Override Collection<ProcessDefinition> getProcessDefinitions(String filter, QueryContext queryContext); @Override Collection<ProcessDefinition> getProcessDefinitionsByDeployment(String deploymentId, QueryContext queryContext); @Override Collection<ProcessInstanceDesc> getProcessInstancesForCase(String caseId, QueryContext queryContext); @Override Collection<ProcessInstanceDesc> getProcessInstancesForCase(String caseId, List<Integer> processStates, QueryContext queryContext); @Override Collection<CaseMilestoneInstance> getCaseInstanceMilestones(String caseId, boolean achievedOnly, QueryContext queryContext); @Override Collection<CaseStageInstance> getCaseInstanceStages(String caseId, boolean activeOnly, QueryContext queryContext); @Override Collection<org.jbpm.services.api.model.NodeInstanceDesc> getActiveNodesForCase(String caseId, QueryContext queryContext); @Override Collection<org.jbpm.services.api.model.NodeInstanceDesc> getCompletedNodesForCase(String caseId, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstances(QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstances(boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstances(List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstances(List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getSubCaseInstancesByParentCaseId(String parentCaseId, List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getAllDescendantSubCaseInstancesByParentCaseId(String parentCaseId, List<CaseStatus> statuses); @Override Collection<CaseInstance> getCaseInstancesByDeployment(String deploymentId, List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByDeployment(String deploymentId, List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByDefinition(String definitionId, List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByDefinition(String definitionId, List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesOwnedBy(String owner, List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesOwnedBy(String owner, List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByRole(String roleName, List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByRole(String roleName, List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesAnyRole(List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesAnyRole(List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByDataItem(String dataItemName, List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByDataItem(String dataItemName, List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByDataItemAndValue(String dataItemName, String dataItemValue, List<CaseStatus> statuses, QueryContext queryContext); @Override Collection<CaseInstance> getCaseInstancesByDataItemAndValue(String dataItemName, String dataItemValue, List<CaseStatus> statuses, boolean withData, QueryContext queryContext); @Override CaseInstance getCaseInstanceById(String caseId); @Override Collection<AdHocFragment> getAdHocFragmentsForCase(String caseId); @Override List<TaskSummary> getCaseTasksAssignedAsPotentialOwner(String caseId, String userId, List<Status> status, QueryContext queryContext); @Override List<TaskSummary> getCaseTasksAssignedAsBusinessAdmin(String caseId, String userId, List<Status> status, QueryContext queryContext); @Override List<TaskSummary> getCaseTasksAssignedAsStakeholder(String caseId, String userId, List<Status> status, QueryContext queryContext); List<CaseStageInstance> internalGetCaseStages(CaseDefinition caseDef, String caseId, boolean activeOnly, QueryContext queryContext); @Override Collection<CaseFileItem> getCaseInstanceDataItems(String caseId, QueryContext queryContext); @Override Collection<CaseFileItem> getCaseInstanceDataItemsByName(String caseId, List<String> names, QueryContext queryContext); @Override Collection<CaseFileItem> getCaseInstanceDataItemsByType(String caseId, List<String> types, QueryContext queryContext);  }
@Test public void testUserTasksInCaseAdBusinessAdmin() { Map<String, OrganizationalEntity> roleAssignments = new HashMap<>(); roleAssignments.put("owner", new UserImpl(USER)); Map<String, Object> data = new HashMap<>(); CaseFileInstance caseFile = caseService.newCaseFileInstance(deploymentUnit.getIdentifier(), USER_TASK_CASE_P_ID, data, roleAssignments); String caseId2 = null; String caseId = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_STAGE_CASE_P_ID, caseFile); assertNotNull(caseId); assertEquals(FIRST_CASE_ID, caseId); try { CaseInstance cInstance = caseService.getCaseInstance(caseId); assertNotNull(cInstance); assertEquals(FIRST_CASE_ID, cInstance.getCaseId()); assertEquals(deploymentUnit.getIdentifier(), cInstance.getDeploymentId()); List<TaskSummary> tasks = caseRuntimeDataService.getCaseTasksAssignedAsBusinessAdmin(caseId, "Administrator", null, new QueryContext()); assertNotNull(tasks); assertEquals(0, tasks.size()); Map<String, Object> taskInput = new HashMap<>(); taskInput.put("ActorId", "john"); caseService.triggerAdHocFragment(caseId, "Missing data", taskInput); tasks = caseRuntimeDataService.getCaseTasksAssignedAsBusinessAdmin(caseId, "Administrator", null, new QueryContext()); assertNotNull(tasks); assertEquals(1, tasks.size()); TaskSummary task = tasks.get(0); assertEquals("Missing data", task.getName()); caseId2 = caseService.startCase(deploymentUnit.getIdentifier(), USER_TASK_STAGE_CASE_P_ID, caseFile); assertNotNull(caseId2); assertEquals("CASE-0000000002", caseId2); caseService.triggerAdHocFragment(caseId2, "Missing data", taskInput); tasks = caseRuntimeDataService.getCaseTasksAssignedAsBusinessAdmin(caseId2, "Administrator", null, new QueryContext()); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals("Missing data", task.getName()); tasks = caseRuntimeDataService.getCaseTasksAssignedAsBusinessAdmin(caseId, "Administrator", null, new QueryContext()); assertNotNull(tasks); assertEquals(1, tasks.size()); task = tasks.get(0); assertEquals("Missing data", task.getName()); } catch (Exception e) { logger.error("Unexpected error {}", e.getMessage(), e); fail("Unexpected exception " + e.getMessage()); } finally { if (caseId != null) { caseService.cancelCase(caseId); } if (caseId2 != null) { caseService.cancelCase(caseId2); } } }