Search in sources :

Example 81 with WorkflowTaskInstanceDto

use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.

the class ManualWorkflowTaskDelegationBulkActionTest method testBulkActionByFilter.

@Test
public void testBulkActionByFilter() {
    // Enable approving of a role-request by manager.
    getHelper().setConfigurationValue(ChangeIdentityPermissionTest.APPROVE_BY_MANAGER_ENABLE, true);
    IdmRoleDto roleOne = getHelper().createRole();
    IdmIdentityDto delegator = getHelper().createIdentity();
    IdmIdentityDto subordinate = getHelper().createIdentity();
    IdmIdentityContractDto subordinateContract = getHelper().createContract(subordinate);
    getHelper().createContractGuarantee(subordinateContract, delegator);
    WorkflowFilterDto taskFilter = new WorkflowFilterDto();
    taskFilter.setCandidateOrAssigned(delegator.getUsername());
    List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    assertEquals(0, tasks.size());
    // Assing role -> reuqest will be in progress state.
    IdmRoleRequestDto roleRequest = getHelper().createRoleRequest(subordinateContract, ConceptRoleRequestOperation.ADD, roleOne);
    roleRequest.setExecuteImmediately(false);
    roleRequest = roleRequestService.save(roleRequest);
    roleRequest = getHelper().executeRequest(roleRequest, false, true);
    assertEquals(RoleRequestState.IN_PROGRESS, roleRequest.getState());
    tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
    assertEquals(1, tasks.size());
    List<IdentityLinkDto> identityLinks = tasks.get(0).getIdentityLinks();
    assertEquals(1, identityLinks.size());
    // Task is assigned to the delegator now.
    assertEquals(delegator.getId(), UUID.fromString(identityLinks.get(0).getUserId()));
    IdmBulkActionDto bulkAction = this.findBulkActionForDto(WorkflowTaskInstanceAbstractDto.class, ManualWorkflowTaskDelegationBulkAction.NAME);
    IdmIdentityDto delegate = getHelper().createIdentity();
    bulkAction.setTransformedFilter(taskFilter);
    bulkAction.setFilter(toMap(taskFilter));
    bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.DELEGATE_ATTRIBUTE, delegate.getId());
    bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.CANDIDATE_OR_ASSIGNED_FILTER_FIELD, delegator.getId());
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    WorkflowTaskInstanceDto task = workflowTaskInstanceService.get(tasks.get(0).getId());
    assertNotNull(task);
    identityLinks = task.getIdentityLinks();
    assertEquals(2, identityLinks.size());
    // Check delegator as participant in the task.
    long participantCount = identityLinks.stream().filter(identityLink -> IdentityLinkType.PARTICIPANT.equals(identityLink.getType()) && UUID.fromString(identityLink.getUserId()).equals(delegator.getId())).count();
    assertEquals(1, participantCount);
    // Check delegate as candidat in the task;
    long candidateCount = identityLinks.stream().filter(identityLink -> IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && UUID.fromString(identityLink.getUserId()).equals(delegate.getId())).count();
    assertEquals(1, candidateCount);
}
Also used : AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Autowired(org.springframework.beans.factory.annotation.Autowired) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdentityLinkType(org.activiti.engine.task.IdentityLinkType) IdmRoleRequestService(eu.bcvsolutions.idm.core.api.service.IdmRoleRequestService) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) CoreModuleDescriptor(eu.bcvsolutions.idm.core.CoreModuleDescriptor) WorkflowTaskInstanceService(eu.bcvsolutions.idm.core.workflow.service.WorkflowTaskInstanceService) After(org.junit.After) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) Before(org.junit.Before) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) WorkflowTaskInstanceAbstractDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceAbstractDto) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Set(java.util.Set) RoleRequestState(eu.bcvsolutions.idm.core.api.domain.RoleRequestState) Test(org.junit.Test) ChangeIdentityPermissionTest(eu.bcvsolutions.idm.core.workflow.permissions.ChangeIdentityPermissionTest) UUID(java.util.UUID) Sets(com.google.common.collect.Sets) IdmNotificationLog(eu.bcvsolutions.idm.core.notification.entity.IdmNotificationLog) ManualWorkflowTaskDelegationBulkAction(eu.bcvsolutions.idm.core.bulk.action.impl.delegation.ManualWorkflowTaskDelegationBulkAction) IdmNotificationLogService(eu.bcvsolutions.idm.core.notification.api.service.IdmNotificationLogService) List(java.util.List) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmGroupPermission(eu.bcvsolutions.idm.core.security.api.domain.IdmGroupPermission) ConceptRoleRequestOperation(eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation) Assert.assertEquals(org.junit.Assert.assertEquals) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdentityLinkDto(eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test) ChangeIdentityPermissionTest(eu.bcvsolutions.idm.core.workflow.permissions.ChangeIdentityPermissionTest)

Aggregations

WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)81 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)69 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)63 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)56 Test (org.junit.Test)56 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)55 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)54 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)49 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)48 ZonedDateTime (java.time.ZonedDateTime)43 List (java.util.List)39 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)28 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)28 UUID (java.util.UUID)17 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12 IdentityLinkDto (eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto)12 WorkflowTaskInstanceService (eu.bcvsolutions.idm.core.workflow.service.WorkflowTaskInstanceService)12 Autowired (org.springframework.beans.factory.annotation.Autowired)12 IdentityLinkType (org.activiti.engine.task.IdentityLinkType)11 WorkflowHistoricTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricTaskInstanceDto)9