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));
}
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()));
}
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()));
}
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);
}
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);
}
Aggregations