use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method addSuperAdminRoleWithSubprocessRemoveTest.
@Test
@Transactional
public void addSuperAdminRoleWithSubprocessRemoveTest() {
IdmIdentityDto test1 = helper.createIdentity("TestUser" + System.currentTimeMillis());
IdmIdentityDto test2 = identityService.getByUsername(InitTestData.TEST_USER_2);
loginAsAdmin(InitTestData.TEST_USER_2);
IdmIdentityContractDto contract = identityContractService.getPrimeContract(test1.getId());
IdmRoleDto adminRole = helper.createRole("testRole" + System.currentTimeMillis());
adminRole.setApproveRemove(true);
roleService.save(adminRole);
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.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// HELPDESK
taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// MANAGER
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// USER MANAGER
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
// SECURITY
taskFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.EXECUTED, request.getState());
assertNotNull(request.getWfProcessId());
concept = conceptRoleRequestService.get(concept.getId());
assertNotNull(concept.getWfProcessId());
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setIdentityId(test1.getId());
Page<IdmIdentityRoleDto> page = identityRoleService.find(filter, null);
assertEquals(1, page.getContent().size());
loginAsAdmin(InitTestData.TEST_USER_2);
// Guarantee
int priority = 500;
adminRole.setPriority(priority);
IdmRoleGuaranteeDto guarantee = new IdmRoleGuaranteeDto();
guarantee.setRole(adminRole.getId());
guarantee.setGuarantee(test2.getId());
adminRole.getGuarantees().add(guarantee);
adminRole = roleService.save(adminRole);
configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + (priority + priority), APPROVE_REMOVE_ROLE_BY_MANAGER_KEY);
IdmRoleRequestDto requestRemove = createRoleRequest(test1);
requestRemove = roleRequestService.save(requestRemove);
IdmConceptRoleRequestDto conceptRemove = createRoleRemoveConcept(page.getContent().get(0).getId(), adminRole, contract, requestRemove);
conceptRemove = conceptRoleRequestService.save(conceptRemove);
roleRequestService.startRequestInternal(requestRemove.getId(), true);
requestRemove = roleRequestService.get(requestRemove.getId());
assertEquals(RoleRequestState.IN_PROGRESS, requestRemove.getState());
WorkflowFilterDto taskRemoveFilter = new WorkflowFilterDto();
// HELPDESK
requestRemove = roleRequestService.get(requestRemove.getId());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
// MANAGER
requestRemove = roleRequestService.get(requestRemove.getId());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
// USER MANAGER
requestRemove = roleRequestService.get(requestRemove.getId());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
// Subprocess - approve by GUARANTEE
requestRemove = roleRequestService.get(requestRemove.getId());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
// SECURITY
requestRemove = roleRequestService.get(requestRemove.getId());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
taskRemoveFilter.setCandidateOrAssigned(InitTestData.TEST_ADMIN_USERNAME);
checkAndCompleteOneTask(taskRemoveFilter, test1.getUsername(), "approve");
requestRemove = roleRequestService.get(requestRemove.getId());
assertEquals(RoleRequestState.EXECUTED, requestRemove.getState());
assertNotNull(requestRemove.getWfProcessId());
conceptRemove = conceptRoleRequestService.get(conceptRemove.getId());
assertNotNull(conceptRemove.getWfProcessId());
IdmIdentityRoleFilter filterRemove = new IdmIdentityRoleFilter();
filterRemove.setIdentityId(test1.getId());
Page<IdmIdentityRoleDto> pageRemove = identityRoleService.find(filterRemove, null);
assertEquals(0, pageRemove.getContent().size());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class ChangeIdentityPermissionTest method addSuperAdminRoleApproveBySecurityTest.
@Test
@Transactional
public void addSuperAdminRoleApproveBySecurityTest() {
configurationService.setValue(APPROVE_BY_SECURITY_ENABLE, "true");
configurationService.setValue(APPROVE_BY_MANAGER_ENABLE, "false");
configurationService.setValue(APPROVE_BY_HELPDESK_ENABLE, "false");
configurationService.setValue(APPROVE_BY_USERMANAGER_ENABLE, "false");
// Set security role test
configurationService.setValue(APPROVE_BY_SECURITY_ROLE, SECURITY_ROLE_TEST);
// Create test role for load candidates on security department (TEST_USER_1)
IdmRoleDto role = new IdmRoleDto();
role.setName(SECURITY_ROLE_TEST);
role = roleService.save(role);
helper.createIdentityRole(identityService.getByUsername(InitTestData.TEST_USER_1), role);
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
IdmIdentityDto test1 = identityService.getByUsername(InitTestData.TEST_USER_1);
IdmRoleDto adminRole = roleService.getByCode(InitTestData.TEST_ADMIN_ROLE);
IdmIdentityContractDto contract = identityContractService.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.setCandidateOrAssigned(securityService.getCurrentUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// HELPDESK turn off
// MANAGER turn off
// USER MANAGER turn off
// SECURITY
loginAsAdmin(InitTestData.TEST_USER_1);
taskFilter.setCandidateOrAssigned(InitTestData.TEST_USER_1);
checkAndCompleteOneTask(taskFilter, InitTestData.TEST_USER_1, "approve");
request = roleRequestService.get(request.getId());
assertEquals(RoleRequestState.EXECUTED, request.getState());
assertNotNull(request.getWfProcessId());
concept = conceptRoleRequestService.get(concept.getId());
assertNotNull(concept.getWfProcessId());
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method completeTasksFromUsers.
/**
* Complete all tasks from user given in parameters. Complete will be done by
* currently logged user.
*
* @param approverUser
* @param decision
*/
private void completeTasksFromUsers(String approverUser, String decision) {
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(approverUser);
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
//
for (WorkflowTaskInstanceDto task : tasks) {
workflowTaskInstanceService.completeTask(task.getId(), decision);
}
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowTaskInstanceService method toResource.
private WorkflowTaskInstanceDto toResource(Task task) {
if (task == null) {
return null;
}
WorkflowTaskInstanceDto dto = new WorkflowTaskInstanceDto();
dto.setId(task.getId());
dto.setCreated(task.getCreateTime());
dto.setFormKey(task.getFormKey());
dto.setAssignee(task.getAssignee());
dto.setName(task.getName());
dto.setDescription(task.getDescription());
dto.setProcessInstanceId(task.getProcessInstanceId());
Map<String, Object> taksVariables = task.getTaskLocalVariables();
Map<String, Object> processVariables = task.getProcessVariables();
// Add applicant username to task dto (for easier work)
if (processVariables != null && processVariables.containsKey(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER)) {
dto.setApplicant((String) processVariables.get(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER).toString());
}
dto.setVariables(processVariables);
convertToDtoVariables(dto, taksVariables);
dto.setDefinition(workflowTaskDefinitionService.searchTaskDefinitionById(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
if (!Strings.isNullOrEmpty(task.getProcessDefinitionId())) {
WorkflowProcessDefinitionDto processDefinition = workflowProcessDefinitionService.get(task.getProcessDefinitionId());
if (processDefinition != null) {
dto.setProcessDefinitionKey(processDefinition.getKey());
}
}
TaskFormData taskFormData = formService.getTaskFormData(task.getId());
// Add form data (it means form properties and value from WF)
List<FormProperty> formProperties = taskFormData.getFormProperties();
// Search and add identity links to dto (It means all user
// (assigned/candidates/group) for this task)
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
if (identityLinks != null) {
List<IdentityLinkDto> identityLinksDtos = new ArrayList<>();
for (IdentityLink il : identityLinks) {
identityLinksDtos.add(toResource(il));
}
dto.getIdentityLinks().addAll(identityLinksDtos);
}
// Check if the logged user can complete this task
boolean canExecute = this.canExecute(dto);
if (formProperties != null && !formProperties.isEmpty()) {
for (FormProperty property : formProperties) {
resovleFormProperty(property, dto, canExecute);
}
}
return dto;
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto in project CzechIdMng by bcvsolutions.
the class SendNotificationToApplicantAndImplementerTest method requestRejectedByHelpdeskNotSameTest.
@Test
public void requestRejectedByHelpdeskNotSameTest() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
configurationService.setValue(SENT_TO_APPLICANT, "false");
configurationService.setValue(SENT_TO_IMPLEMENTER, "false");
//
IdmIdentityDto testUser3 = createTestUser();
loginAsAdmin(testUser3.getUsername());
IdmIdentityDto test1 = createTestUser();
IdmRoleDto test_role = createRole("test_role" + System.currentTimeMillis());
//
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();
List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.search(taskFilter).getResources();
assertEquals(0, tasks.size());
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// HELPDESK
checkAndCompleteOneTask(taskFilter, test1.getUsername(), "disapprove");
// test notification to applicant
IdmNotificationFilter filter = new IdmNotificationFilter();
filter.setRecipient(test1.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
List<IdmNotificationLogDto> notifications = notificationLogService.find(filter, null).getContent();
assertEquals(0, notifications.size());
// test notification to implementer
filter = new IdmNotificationFilter();
filter.setRecipient(testUser3.getUsername());
filter.setNotificationType(IdmNotificationLog.class);
notifications = notificationLogService.find(filter, null).getContent();
assertEquals(0, notifications.size());
}
Aggregations