Search in sources :

Example 91 with IdmRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.

the class SendNotificationToApplicantAndImplementerTest method requestReturnedByHelpdeskImplementerNotSameTest.

@Test
public void requestReturnedByHelpdeskImplementerNotSameTest() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    configurationService.setValue(SENT_TO_APPLICANT, "false");
    configurationService.setValue(SENT_TO_IMPLEMENTER, "true");
    // 
    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(), "backToApplicant");
    // 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(1, notifications.size());
    assertEquals(CoreModuleDescriptor.TOPIC_RETURN_REQUEST_IDENTITY_ROLES_IMPLEMENTER, notifications.get(0).getTopic());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) ArrayList(java.util.ArrayList) List(java.util.List) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 92 with IdmRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.

the class SendNotificationToApplicantAndImplementerTest method requestRejectedByHelpdeskImplementerSameTest.

@Test
public void requestRejectedByHelpdeskImplementerSameTest() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    configurationService.setValue(SENT_TO_APPLICANT, "false");
    configurationService.setValue(SENT_TO_IMPLEMENTER, "true");
    // 
    IdmIdentityDto test1 = createTestUser();
    IdmRoleDto test_role = createRole("test_role" + System.currentTimeMillis());
    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();
    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
    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_DISAPPROVE_IDENTITY_ROLES_IMPLEMENTER, notifications.get(0).getTopic());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) ArrayList(java.util.ArrayList) List(java.util.List) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 93 with IdmRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.

the class SendNotificationToApplicantAndImplementerTest method createStructure.

/**
 * Creates organization's structure and identity testUser2 as manager
 */
private void createStructure() {
    IdmRoleDto superAdminRole = this.roleService.getByCode(InitApplicationData.ADMIN_ROLE);
    IdmTreeNodeDto rootOrganization = treeNodeService.findRoots((UUID) null, new PageRequest(0, 1)).getContent().get(0);
    IdmRoleDto role2 = new IdmRoleDto();
    role2.setName("TestCustomRole002" + System.currentTimeMillis());
    List<IdmRoleCompositionDto> subRoles = new ArrayList<>();
    subRoles.add(new IdmRoleCompositionDto(role2.getId(), superAdminRole.getId()));
    role2.setSubRoles(subRoles);
    role2 = this.roleService.save(role2);
    testUser2 = new IdmIdentityDto();
    testUser2.setUsername("Test_user_Manager" + System.currentTimeMillis());
    testUser2.setPassword(new GuardedString("heslo"));
    testUser2.setFirstName("Test");
    testUser2.setLastName("Second User");
    testUser2.setEmail("test2@bscsolutions.eu");
    testUser2 = this.identityService.save(testUser2);
    IdmTreeTypeDto type = treeTypeService.get(rootOrganization.getTreeType());
    organization = new IdmTreeNodeDto();
    organization.setCode("test" + System.currentTimeMillis());
    organization.setName("Organization Test Notification");
    organization.setParent(rootOrganization.getId());
    organization.setTreeType(type.getId());
    organization = this.treeNodeService.save(organization);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) PageRequest(org.springframework.data.domain.PageRequest) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) ArrayList(java.util.ArrayList) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Example 94 with IdmRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.

the class SendNotificationToApplicantAndImplementerTest method requestReturnedByHelpdeskApplicantImplementerSameTest.

@Test
public void requestReturnedByHelpdeskApplicantImplementerSameTest() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    configurationService.setValue(SENT_TO_APPLICANT, "true");
    configurationService.setValue(SENT_TO_IMPLEMENTER, "true");
    // 
    IdmIdentityDto test1 = createTestUser();
    IdmRoleDto test_role = createRole("test_role" + System.currentTimeMillis());
    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();
    List<WorkflowTaskInstanceDto> tasks = (List<WorkflowTaskInstanceDto>) workflowTaskInstanceService.search(taskFilter).getResources();
    assertEquals(0, tasks.size());
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // 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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) ArrayList(java.util.ArrayList) List(java.util.List) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Example 95 with IdmRoleDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.

the class SendNotificationToApplicantAndImplementerTest method requestApprovedImplementerNotSameTest.

@Test
public void requestApprovedImplementerNotSameTest() {
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    configurationService.setValue(SENT_TO_APPLICANT, "false");
    configurationService.setValue(SENT_TO_IMPLEMENTER, "true");
    // 
    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(), "approve");
    // MANAGER
    loginAsAdmin(testUser2.getUsername());
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
    // USER MANAGER
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
    // SECURITY
    checkAndCompleteOneTask(taskFilter, test1.getUsername(), "approve");
    // 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(1, notifications.size());
    assertEquals(CoreModuleDescriptor.TOPIC_CHANGE_IDENTITY_ROLES_IMPLEMENTER, notifications.get(0).getTopic());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) WorkflowFilterDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto) WorkflowTaskInstanceDto(eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto) IdmNotificationLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) ArrayList(java.util.ArrayList) List(java.util.List) IdmNotificationFilter(eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) AbstractCoreWorkflowIntegrationTest(eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest) Test(org.junit.Test)

Aggregations

IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)288 Test (org.junit.Test)227 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)209 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)159 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)99 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)74 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)59 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)51 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)50 ArrayList (java.util.ArrayList)50 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)45 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)44 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)44 List (java.util.List)40 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)37 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)36 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)35 UUID (java.util.UUID)35 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)32 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)32