Search in sources :

Example 26 with IdmIdentityContractDto

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

the class IdentityRoleValidRequestSchedulerTest method createNonValidRoleAndValid.

@Test
public void createNonValidRoleAndValid() throws InterruptedException, ExecutionException {
    IdmIdentityDto identity = createAndSaveIdentity();
    IdmRoleDto role = createAndSaveRole();
    createAndSaveRoleSystem(role, system);
    IdmTreeTypeDto treeType = createAndSaveTreeType();
    IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
    IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
    LocalDate validFrom = new LocalDate();
    // set plus days
    validFrom = validFrom.plusDays(5);
    // provisioning is not executed, role isn't valid from now
    createAndSaveIdentityRole(identityContract, role, null, validFrom);
    AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
    filter.setIdentityId(identity.getId());
    List<AccIdentityAccountDto> list = identityAccountService.find(filter, null).getContent();
    // it must not exists
    assertEquals(true, list.isEmpty());
    // 
    IdentityRoleValidRequestTaskExecutor taskExecutor1 = new IdentityRoleValidRequestTaskExecutor();
    LongRunningFutureTask<Boolean> futureTask1 = longRunningTaskManager.execute(taskExecutor1);
    assertEquals(true, futureTask1.getFutureTask().get());
    IdmLongRunningTaskDto longRunningTask1 = longRunningTaskService.get(taskExecutor1.getLongRunningTaskId());
    assertEquals(OperationState.EXECUTED, longRunningTask1.getResult().getState());
    list = identityAccountService.find(filter, null).getContent();
    // still empty, role isn't valid
    assertEquals(true, list.isEmpty());
    List<IdmIdentityRole> roles = identityRoleRepository.findAllByIdentityContract_Identity_Id(identity.getId(), null);
    assertEquals(1, roles.size());
    IdmIdentityRole identityRole = roles.get(0);
    validFrom = new LocalDate();
    validFrom = validFrom.minusDays(5);
    identityRole.setValidFrom(validFrom);
    identityRoleRepository.save(identityRole);
    // execute again
    IdentityRoleValidRequestTaskExecutor taskExecutor2 = new IdentityRoleValidRequestTaskExecutor();
    LongRunningFutureTask<Boolean> futureTask2 = longRunningTaskManager.execute(taskExecutor2);
    assertEquals(true, futureTask2.getFutureTask().get());
    IdmLongRunningTaskDto longRunningTask2 = longRunningTaskService.get(taskExecutor2.getLongRunningTaskId());
    assertEquals(OperationState.EXECUTED, longRunningTask2.getResult().getState());
    list = identityAccountService.find(filter, null).getContent();
    assertEquals(false, list.isEmpty());
    assertEquals(1, list.size());
    // newly created accounts
    assertNotNull(list.get(0));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) LocalDate(org.joda.time.LocalDate) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdentityRoleValidRequestTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.IdentityRoleValidRequestTaskExecutor) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmIdentityRole(eu.bcvsolutions.idm.core.model.entity.IdmIdentityRole) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 27 with IdmIdentityContractDto

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

the class IdentityRoleValidRequestSchedulerTest method createAndSaveIdentityContract.

private IdmIdentityContractDto createAndSaveIdentityContract(IdmIdentityDto user, IdmTreeNodeDto node) {
    IdmIdentityContractDto entity = new IdmIdentityContractDto();
    entity.setIdentity(user.getId());
    entity.setWorkPosition(node == null ? null : node.getId());
    return saveInTransaction(entity, identityContractService);
}
Also used : IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 28 with IdmIdentityContractDto

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

the class IdentityRoleValidRequestSchedulerTest method createLotsOfValidRequests.

@Test
public void createLotsOfValidRequests() throws InterruptedException, ExecutionException {
    IdmRoleDto role = createAndSaveRole();
    createAndSaveRoleSystem(role, system);
    IdmTreeTypeDto treeType = createAndSaveTreeType();
    IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
    LocalDate validFrom = new LocalDate();
    // set plus days
    validFrom = validFrom.plusDays(5);
    // clear request, if any
    List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.findAllValid();
    for (IdmIdentityRoleValidRequestDto request : list) {
        identityRoleValidRequestService.delete(request);
    }
    List<IdmIdentityDto> identities = new ArrayList<>();
    for (int index = 0; index < MAX_CREATE; index++) {
        IdmIdentityDto identity = createAndSaveIdentity();
        IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
        // provisioning is not executed, role isn't valid from now
        createAndSaveIdentityRole(identityContract, role, null, validFrom);
        identities.add(identity);
    }
    list = identityRoleValidRequestService.findAllValid();
    assertEquals(0, list.size());
    validFrom = validFrom.minusDays(15);
    for (IdmIdentityDto identity : identities) {
        List<IdmIdentityRole> roles = identityRoleRepository.findAllByIdentityContract_Identity_Id(identity.getId(), null);
        assertEquals(1, roles.size());
        IdmIdentityRole identityRole = roles.get(0);
        identityRole.setValidFrom(validFrom);
        identityRoleRepository.save(identityRole);
    }
    list = identityRoleValidRequestService.findAllValid();
    assertEquals(MAX_CREATE, list.size());
    IdentityRoleValidRequestTaskExecutor taskExecutor = new IdentityRoleValidRequestTaskExecutor();
    LongRunningFutureTask<Boolean> futureTask = longRunningTaskManager.execute(taskExecutor);
    assertEquals(true, futureTask.getFutureTask().get());
    IdmLongRunningTaskDto longRunningTask = longRunningTaskService.get(taskExecutor.getLongRunningTaskId());
    assertEquals(OperationState.EXECUTED, longRunningTask.getResult().getState());
    list = identityRoleValidRequestService.findAllValid();
    assertEquals(0, list.size());
    for (IdmIdentityDto identity : identities) {
        AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
        filter.setIdentityId(identity.getId());
        List<AccIdentityAccountDto> accountsList = identityAccountService.find(filter, null).getContent();
        assertEquals(false, accountsList.isEmpty());
        assertEquals(1, accountsList.size());
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) ArrayList(java.util.ArrayList) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) LocalDate(org.joda.time.LocalDate) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) IdentityRoleValidRequestTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.IdentityRoleValidRequestTaskExecutor) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmIdentityRole(eu.bcvsolutions.idm.core.model.entity.IdmIdentityRole) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with IdmIdentityContractDto

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

the class AbstractHrProcessIntegrationTest method getTestContract.

protected IdmIdentityContractDto getTestContract(IdmIdentityDto identity, boolean excluded) {
    IdmIdentityContractDto contract = new IdmIdentityContractDto();
    contract.setIdentity(identity.getId());
    contract.setMain(false);
    contract.setState(excluded ? ContractState.EXCLUDED : null);
    return contract;
}
Also used : IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 30 with IdmIdentityContractDto

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

the class HrContractExclusionProcessIntegrationTest method testExclusion2.

@Test
public void testExclusion2() {
    IdmIdentityContractDto dto = prepareTestData2();
    assertEquals(false, identityService.get(dto.getIdentity()).isDisabled());
    // 
    process(lrt, dto);
    // 
    Page<IdmProcessedTaskItemDto> queueItems = itemService.findQueueItems(scheduledTask, null);
    Page<IdmProcessedTaskItemDto> logItems = itemService.findLogItems(lrt, null);
    // 
    assertEquals(false, identityService.get(dto.getIdentity()).isDisabled());
    assertEquals(1, queueItems.getTotalElements());
    assertEquals(1, logItems.getTotalElements());
    SchedulerTestUtils.checkLogItems(lrt, IdmIdentityContractDto.class, logItems);
    SchedulerTestUtils.checkQueueItems(scheduledTask, IdmIdentityContractDto.class, queueItems);
    identityRoleService.findAllByContract(dto.getId()).forEach(r -> assertTrue(r.isAutomaticRole()));
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test)

Aggregations

IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)220 Test (org.junit.Test)170 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)156 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)92 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)91 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)53 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)48 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)45 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)44 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)36 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)35 LocalDate (org.joda.time.LocalDate)34 ArrayList (java.util.ArrayList)31 List (java.util.List)29 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)28 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)24 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)24 Transactional (org.springframework.transaction.annotation.Transactional)24 UUID (java.util.UUID)19 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)18