Search in sources :

Example 6 with IdmProcessedTaskItemDto

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

the class AbstractSchedulableStatefulExecutorUnitTest method testAddToProcessedQueue.

@Test
public void testAddToProcessedQueue() {
    IdmScheduledTaskDto scheduledTask = new IdmScheduledTaskDto();
    scheduledTask.setId(UUID.randomUUID());
    when(scheduledTaskService.findByLongRunningTaskId(any(UUID.class))).thenReturn(scheduledTask);
    when(scheduledTaskService.get(any(UUID.class))).thenReturn(scheduledTask);
    when(itemService.saveInternal(any(IdmProcessedTaskItemDto.class))).then(AdditionalAnswers.returnsFirstArg());
    when(itemService.createQueueItem(any(AbstractDto.class), any(OperationResult.class), any(IdmScheduledTaskDto.class))).thenCallRealMethod();
    // 
    IdmIdentityDto dto = getTestIdentityDto();
    OperationResult opResult = new OperationResult.Builder(OperationState.EXCEPTION).build();
    IdmProcessedTaskItemDto qItem = executor.addToProcessedQueue(dto, opResult);
    // 
    assertEquals(scheduledTask.getId(), qItem.getScheduledTaskQueueOwner());
    assertEquals(opResult, qItem.getOperationResult());
    assertEquals(dto.getClass().getCanonicalName(), qItem.getReferencedDtoType());
    assertEquals(dto.getId(), qItem.getReferencedEntityId());
    assertNull(qItem.getLongRunningTask());
    // 
    verify(itemService, times(1)).saveInternal(any(IdmProcessedTaskItemDto.class));
    verify(executor, times(1)).addToProcessedQueue(any(IdmIdentityDto.class), any(OperationResult.class));
    verify(scheduledTaskService, times(1)).findByLongRunningTaskId(any(UUID.class));
    verify(scheduledTaskService, times(1)).get(any(UUID.class));
    verify(itemService, times(1)).createQueueItem(any(AbstractDto.class), any(OperationResult.class), any(IdmScheduledTaskDto.class));
}
Also used : IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) UUID(java.util.UUID) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractVerifiableUnitTest(eu.bcvsolutions.idm.test.api.AbstractVerifiableUnitTest) Test(org.junit.Test)

Example 7 with IdmProcessedTaskItemDto

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

the class DefaultIdmProcessedTaskItemDtoServiceTest method testDeleteQueueItemIntegrity.

@Test
public void testDeleteQueueItemIntegrity() {
    IdmScheduledTaskDto d = helper.createSchedulableTask();
    IdmProcessedTaskItemDto item = service.saveInternal(helper.prepareProcessedItem(d));
    // 
    scheduledTaskService.deleteInternal(d);
    // 
    assertNull(scheduledTaskService.get(d.getId()));
    assertNull(service.get(item.getId()));
}
Also used : IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with IdmProcessedTaskItemDto

use of eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto 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)

Example 9 with IdmProcessedTaskItemDto

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

the class HrContractExclusionProcessIntegrationTest method testExclusion3.

@Test
public void testExclusion3() {
    IdmIdentityContractDto dto = prepareTestData3();
    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(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);
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test)

Example 10 with IdmProcessedTaskItemDto

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

the class HrEnableContractProcessIntegrationTest method testEnable2.

/**
 * Disabled identity, two contracts, one gets enabled => must enable identity.
 */
@Test
public void testEnable2() {
    IdmIdentityContractDto dto = prepareTestData2();
    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)

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