use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class SendNotificationToApplicantAndImplementerTest method requestReturnedByHelpdeskApplicantSameTest.
@Test
public void requestReturnedByHelpdeskApplicantSameTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
configurationService.setValue(SENT_TO_APPLICANT, "true");
configurationService.setValue(SENT_TO_IMPLEMENTER, "false");
//
IdmIdentityDto test1 = createTestUser();
IdmRoleDto test_role = createRole();
loginAsAdmin(test1.getUsername());
IdmIdentityContractDto contract = identityContractService.getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(test_role, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
taskFilter.setCreatedAfter(now);
List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.find(taskFilter, null, IdmBasePermission.READ).getContent();
assertEquals(0, tasks.size());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
// HELPDESK
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "backToApplicant");
// test notification
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(test1.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
assertEquals(1, notifications.size());
assertEquals(CoreModuleDescriptor.TOPIC_RETURN_REQUEST_IDENTITY_ROLES_IMPLEMENTER, notifications.get(0).getTopic());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class SendNotificationToApplicantAndImplementerTest method requestApprovedSameTest.
@Test
public void requestApprovedSameTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
configurationService.setValue(SENT_TO_APPLICANT, "false");
configurationService.setValue(SENT_TO_IMPLEMENTER, "false");
//
IdmIdentityDto test1 = createTestUser();
IdmRoleDto test_role = createRole();
loginAsAdmin(test1.getUsername());
IdmIdentityContractDto contract = identityContractService.getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(test_role, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
taskFilter.setCreatedAfter(now);
List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.find(taskFilter, null, IdmBasePermission.READ).getContent();
assertEquals(0, tasks.size());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
// HELPDESK
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// MANAGER
loginAsAdmin(testUser2.getUsername());
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// USER MANAGER
loginAsAdmin();
taskFilter.setCandidateOrAssigned(securityService.getCurrentId().toString());
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// SECURITY
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// test notification
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(test1.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
assertEquals(0, notifications.size());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method testGetTaskByUserInvolvedInProcess.
@Test
public void testGetTaskByUserInvolvedInProcess() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
getHelper().waitForResult(null, 1, 1);
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
IdmIdentityDto test1 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_1);
IdmIdentityDto test2 = identityService.getByUsername(InitTestDataProcessor.TEST_USER_2);
// Guarantee
int priority = 500;
IdmRoleDto adminRole = roleConfiguration.getAdminRole();
adminRole.setPriority(priority);
getHelper().createRoleGuarantee(adminRole, test2);
adminRole = roleService.save(adminRole);
configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + priority, APPROVE_ROLE_BY_SECURITY_KEY);
getHelper().setConfigurationValue(APPROVE_BY_SECURITY_ENABLE, true);
IdmIdentityContractDto contract = getHelper().getPrimeContract(test1.getId());
IdmRoleRequestDto request = createRoleRequest(test1);
request = roleRequestService.save(request);
IdmConceptRoleRequestDto concept = createRoleConcept(adminRole, contract, request);
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCreatedAfter(now);
taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// Help Desk
request = roleRequestService.get(request.getId());
loginAsAdmin();
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, InitTestDataProcessor.TEST_USER_1, "approve");
// Manager
request = roleRequestService.get(request.getId());
loginAsAdmin(InitTestDataProcessor.TEST_USER_2);
taskFilter.setCandidateOrAssigned(InitTestDataProcessor.TEST_USER_2);
tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(1, tasks.size());
WorkflowTaskInstanceDto notApprovedTask = tasks.get(0);
// Approver of this task has permission to read this task.
loginWithout(InitTestDataProcessor.TEST_USER_2, IdmGroupPermission.APP_ADMIN, CoreGroupPermission.WORKFLOW_TASK_ADMIN);
WorkflowTaskInstanceDto task = workflowTaskInstanceService.get(UUID.fromString(notApprovedTask.getId()));
assertNotNull(task);
// This task isn't resolved yet.
assertFalse(task instanceof WorkflowHistoricTaskInstanceDto);
// Login as applicant.
loginWithout(test1.getUsername(), IdmGroupPermission.APP_ADMIN, CoreGroupPermission.WORKFLOW_TASK_ADMIN);
// Applicant can read a process -> but cannot read all tasks of a process.
task = workflowTaskInstanceService.get(UUID.fromString(notApprovedTask.getId()));
assertNull(task);
// Login as random user.
IdmIdentityDto randomUser = getHelper().createIdentity();
loginWithout(randomUser.getUsername(), IdmGroupPermission.APP_ADMIN, CoreGroupPermission.WORKFLOW_TASK_ADMIN);
// Random user doesn't have read permission on the task and process.
task = workflowTaskInstanceService.get(UUID.fromString(notApprovedTask.getId()));
assertNull(task);
// Random user can read the task if filter has set OnlyInvolved to FALSE.
WorkflowFilterDto taskFilterApproved = new WorkflowFilterDto();
taskFilterApproved.setOnlyInvolved(Boolean.FALSE);
task = workflowTaskInstanceService.get(UUID.fromString(notApprovedTask.getId()), taskFilterApproved);
assertNotNull(task);
// This task isn't resolved yet.
assertFalse(task instanceof WorkflowHistoricTaskInstanceDto);
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method testSwitchUserAuditVariablesModify.
@Test
public void testSwitchUserAuditVariablesModify() {
IdmIdentityDto adminOriginal = getHelper().createIdentity();
IdmIdentityDto adminSwitched = getHelper().createIdentity();
IdmIdentityDto adminHelpdesk = getHelper().createIdentity();
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmRoleDto adminRole = roleConfiguration.getAdminRole();
getHelper().createIdentityRole(adminOriginal, adminRole);
getHelper().createIdentityRole(adminSwitched, adminRole);
IdmRoleDto helpdeskRole = getHelper().createRole();
configurationService.setValue(APPROVE_BY_HELPDESK_ROLE, helpdeskRole.getCode());
getHelper().setConfigurationValue(APPROVE_BY_SECURITY_ENABLE, false);
getHelper().setConfigurationValue(APPROVE_BY_MANAGER_ENABLE, false);
getHelper().setConfigurationValue(APPROVE_BY_HELPDESK_ENABLE, true);
getHelper().setConfigurationValue(APPROVE_BY_USERMANAGER_ENABLE, false);
getHelper().createIdentityRole(adminHelpdesk, helpdeskRole);
IdmRoleRequestDto request = createRoleRequest(identity);
IdmConceptRoleRequestDto concept = null;
getHelper().createIdentityRole(identity, adminRole);
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertEquals(1, assignedRoles.size());
IdmIdentityRoleDto assignedRole = assignedRoles.get(0);
//
try {
getHelper().login(adminOriginal);
loginService.switchUser(adminSwitched);
//
IdmIdentityContractDto contract = getHelper().getPrimeContract(identity);
request = roleRequestService.save(request);
concept = createRoleConcept(adminRole, contract, request);
concept.setIdentityRole(assignedRole.getId());
concept.setOperation(ConceptRoleRequestOperation.UPDATE);
concept.setValidFrom(LocalDate.now().minusDays(20));
concept = conceptRoleRequestService.save(concept);
roleRequestService.startRequestInternal(request.getId(), true);
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.IN_PROGRESS, request.getState());
//
// check original identity is filled in process variables
WorkflowProcessInstanceDto workflowProcessInstanceDto = workflowProcessInstanceService.get(request.getWfProcessId());
Assert.assertEquals(adminSwitched.getId().toString(), workflowProcessInstanceDto.getProcessVariables().get(WorkflowProcessInstanceService.IMPLEMENTER_IDENTIFIER));
Assert.assertEquals(adminOriginal.getId().toString(), workflowProcessInstanceDto.getProcessVariables().get(WorkflowProcessInstanceService.ORIGINAL_IMPLEMENTER_IDENTIFIER));
} finally {
logout();
}
//
try {
getHelper().login(adminOriginal);
loginService.switchUser(adminHelpdesk);
//
// change concept - modify dates
concept.setValidFrom(LocalDate.now().minusDays(10));
concept = conceptRoleRequestService.save(concept);
Assert.assertEquals(adminHelpdesk.getId(), concept.getModifierId());
Assert.assertEquals(adminOriginal.getId(), concept.getOriginalModifierId());
//
// complete the first task (~helpdesk)
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
Assert.assertEquals(1, tasks.size());
Assert.assertEquals(identity.getId().toString(), tasks.get(0).getApplicant());
workflowTaskInstanceService.completeTask(tasks.get(0).getId(), "approve");
//
// check original identity is filled in task variables
WorkflowHistoricTaskInstanceDto workflowHistoricTaskInstanceDto = workflowHistoricTaskInstanceService.get(tasks.get(0).getId());
Assert.assertEquals(adminHelpdesk.getId().toString(), workflowHistoricTaskInstanceDto.getAssignee());
Assert.assertEquals(adminOriginal.getId(), workflowHistoricTaskInstanceDto.getVariables().get(WorkflowProcessInstanceService.ORIGINAL_IMPLEMENTER_IDENTIFIER));
} finally {
logout();
}
//
// request has to be approved
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.EXECUTED, request.getState());
//
// check created identity role audit fields
assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
//
Assert.assertEquals(1, assignedRoles.size());
assignedRole = assignedRoles.get(0);
Assert.assertEquals(adminHelpdesk.getId(), assignedRole.getModifierId());
Assert.assertEquals(adminOriginal.getId(), assignedRole.getOriginalModifierId());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method checkAndCompleteOneTask.
private WorkflowTaskInstanceDto checkAndCompleteOneTask(WorkflowFilterDto taskFilter, String user, String decision, String userTaskId) {
IdmIdentityDto identity = identityService.getByUsername(user);
List<WorkflowTaskInstanceDto> tasks;
tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(1, tasks.size());
if (userTaskId != null) {
assertEquals(userTaskId, tasks.get(0).getDefinition().getId());
}
assertEquals(identity.getId().toString(), tasks.get(0).getApplicant());
workflowTaskInstanceService.completeTask(tasks.get(0).getId(), decision);
return tasks.get(0);
}
Aggregations