Search in sources :

Example 11 with IdmProcessedTaskItemDto

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

the class HrEnableContractProcessIntegrationTest method testEnableWithEnabledProcessor.

@Test
public void testEnableWithEnabledProcessor() {
    helper.enable(IdentityContractEnableProcessor.class);
    // 
    IdmIdentityContractDto dto = prepareTestData1();
    // identity is enabled by processor
    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);
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test)

Example 12 with IdmProcessedTaskItemDto

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

the class HrEnableContractProcessIntegrationTest method testEnable1.

/**
 * Disabled identity, one contract gets enabled => must enable identity.
 */
@Test
public void testEnable1() {
    IdmIdentityContractDto dto = prepareTestData1();
    assertEquals(true, 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);
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test)

Example 13 with IdmProcessedTaskItemDto

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

the class HrEndContractProcessIntegrationTest method testExclusion1.

@Test
public void testExclusion1() {
    IdmIdentityContractDto dto = prepareTestData1();
    assertNotEquals(0, identityRoleService.findAllByContract(dto.getId()).size());
    // 
    process(lrt, dto);
    // 
    Page<IdmProcessedTaskItemDto> queueItems = itemService.findQueueItems(scheduledTask, null);
    Page<IdmProcessedTaskItemDto> logItems = itemService.findLogItems(lrt, null);
    // 
    assertEquals(true, 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);
    assertEquals(0, identityRoleService.findAllByContract(dto.getId()).size());
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test)

Example 14 with IdmProcessedTaskItemDto

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

the class PasswordExpirationWarningIntegrationTest method testSimpleWarningMessageDry.

@Test
public void testSimpleWarningMessageDry() {
    // prepare date
    IdmIdentityDto identity = helper.createIdentity();
    // 
    try {
        IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
        password.setValidTill(new LocalDate().plusDays(1));
        passwordService.save(password);
        // prepare task
        IdmScheduledTaskDto scheduledTask = scheduledTaskService.save(SchedulerTestUtils.createIdmScheduledTask(UUID.randomUUID().toString()));
        IdmLongRunningTaskDto longRunningTask = longRunningService.save(SchedulerTestUtils.createIdmLongRunningTask(scheduledTask, PasswordExpirationWarningTaskExecutor.class));
        PasswordExpirationWarningTaskExecutor executor = AutowireHelper.autowireBean(new PasswordExpirationWarningTaskExecutor());
        executor.setLongRunningTaskId(longRunningTask.getId());
        executor.init(ImmutableMap.of(PasswordExpirationWarningTaskExecutor.PARAMETER_DAYS_BEFORE, "2"));
        // first process
        Boolean result = executor.process();
        Page<IdmProcessedTaskItemDto> queueItems = itemService.findQueueItems(scheduledTask, null);
        Page<IdmProcessedTaskItemDto> logItems = itemService.findLogItems(longRunningTask, null);
        // first check
        Assert.assertTrue(result);
        Assert.assertTrue(executor.getCount() > 0);
        Assert.assertTrue(queueItems.getTotalElements() > 0);
        Assert.assertTrue(logItems.getTotalElements() > 0);
        Assert.assertTrue(logItems.getContent().stream().map(IdmProcessedTaskItemDto::getReferencedEntityId).anyMatch(password.getId()::equals));
        // second process
        longRunningTask = longRunningService.save(SchedulerTestUtils.createIdmLongRunningTask(scheduledTask, PasswordExpirationWarningTaskExecutor.class));
        executor.setLongRunningTaskId(longRunningTask.getId());
        executor.init(ImmutableMap.of(PasswordExpirationWarningTaskExecutor.PARAMETER_DAYS_BEFORE, "2"));
        result = executor.process();
        itemService.findQueueItems(scheduledTask, null);
        logItems = itemService.findLogItems(longRunningTask, null);
        // second check
        Assert.assertTrue(result);
        Assert.assertEquals(Long.valueOf(0), executor.getCount());
        Assert.assertTrue(queueItems.getTotalElements() > 0);
        Assert.assertEquals(0, logItems.getTotalElements());
    } finally {
        identityService.delete(identity);
    }
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 15 with IdmProcessedTaskItemDto

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

the class PasswordExpiredIntegrationTest method testNotSendWarningMessageToDisabledIdentity.

@Test
public void testNotSendWarningMessageToDisabledIdentity() {
    // prepare date
    IdmIdentityDto identity = helper.createIdentity();
    // 
    try {
        IdmPasswordDto password = passwordService.findOneByIdentity(identity.getId());
        password.setValidTill(new LocalDate().minusDays(1));
        passwordService.save(password);
        // disable identity
        identity.setDisabled(true);
        identityService.save(identity);
        // prepare task
        IdmScheduledTaskDto scheduledTask = scheduledTaskService.save(SchedulerTestUtils.createIdmScheduledTask(UUID.randomUUID().toString()));
        IdmLongRunningTaskDto longRunningTask = longRunningService.save(SchedulerTestUtils.createIdmLongRunningTask(scheduledTask, PasswordExpiredTaskExecutor.class));
        PasswordExpiredTaskExecutor executor = AutowireHelper.autowireBean(new PasswordExpiredTaskExecutor());
        executor.setLongRunningTaskId(longRunningTask.getId());
        executor.init(ImmutableMap.of(PasswordExpirationWarningTaskExecutor.PARAMETER_DAYS_BEFORE, "2"));
        // first process
        Boolean result = executor.process();
        Page<IdmProcessedTaskItemDto> logItems = itemService.findLogItems(longRunningTask, null);
        // check
        Assert.assertTrue(result);
        Assert.assertFalse(logItems.getContent().stream().map(IdmProcessedTaskItemDto::getReferencedEntityId).anyMatch(password.getId()::equals));
    } finally {
        identityService.delete(identity);
    }
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LocalDate(org.joda.time.LocalDate) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmProcessedTaskItemDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto)42 Test (org.junit.Test)32 IdmScheduledTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto)22 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)16 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)13 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)12 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)11 IdmProcessedTaskItemFilter (eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmProcessedTaskItemFilter)9 IdmPasswordDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto)4 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)4 AbstractVerifiableUnitTest (eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest)4 UUID (java.util.UUID)4 LocalDate (org.joda.time.LocalDate)4 AbstractDto (eu.bcvsolutions.idm.core.api.dto.AbstractDto)3 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)2 PageImpl (org.springframework.data.domain.PageImpl)2 PageRequest (org.springframework.data.domain.PageRequest)2 Pageable (org.springframework.data.domain.Pageable)2 Transactional (org.springframework.transaction.annotation.Transactional)2 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)1