use of eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmProcessedTaskItemService method createLogItem.
@Override
@Transactional
public <E extends AbstractDto> IdmProcessedTaskItemDto createLogItem(E processedItem, OperationResult result, IdmLongRunningTaskDto lrt) {
//
Assert.notNull(processedItem);
Assert.notNull(result);
Assert.notNull(lrt);
//
IdmProcessedTaskItemDto item = createProcessedItemDto(processedItem, result);
item.setLongRunningTask(lrt.getId());
return this.saveInternal(item);
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmProcessedTaskItemService method createQueueItem.
@Override
@Transactional
public <E extends AbstractDto> IdmProcessedTaskItemDto createQueueItem(E processedItem, OperationResult result, IdmScheduledTaskDto st) {
//
Assert.notNull(processedItem);
Assert.notNull(result);
Assert.notNull(st);
//
IdmProcessedTaskItemDto item = createProcessedItemDto(processedItem, result);
item.setScheduledTaskQueueOwner(st.getId());
return this.saveInternal(item);
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method prepareProcessedItem.
@Override
public IdmProcessedTaskItemDto prepareProcessedItem(IdmLongRunningTaskDto lrt) {
IdmProcessedTaskItemDto item = new IdmProcessedTaskItemDto();
item.setReferencedDtoType(IdmIdentityDto.class.getCanonicalName());
item.setReferencedEntityId(UUID.randomUUID());
item.setLongRunningTask(lrt.getId());
item.setOperationResult(new OperationResult.Builder(OperationState.EXECUTED).build());
return item;
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto in project CzechIdMng by bcvsolutions.
the class IdmLongRunningTaskItemControllerRestTest method deleteItem.
@Test
public void deleteItem() throws Exception {
IdmScheduledTaskDto scheduledTaskDto = helper.createSchedulableTask();
IdmProcessedTaskItemDto taskItem = service.saveInternal(helper.prepareProcessedItem(scheduledTaskDto));
getMockMvc().perform(get(BaseController.BASE_PATH + PATH + "/" + taskItem.getId()).with(authentication(getAuthentication())).contentType(InitTestData.HAL_CONTENT_TYPE)).andExpect(status().isOk()).andExpect(MockMvcResultMatchers.content().contentType(InitTestData.HAL_CONTENT_TYPE)).andExpect(jsonPath("$.id", equalTo(taskItem.getId().toString())));
int status = getMockMvc().perform(delete(BaseController.BASE_PATH + PATH + "/" + taskItem.getId()).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getStatus();
assertEquals(403, status);
getMockMvc().perform(get(BaseController.BASE_PATH + PATH + taskItem.getId()).with(authentication(getAuthentication())).contentType(InitTestData.HAL_CONTENT_TYPE)).andExpect(status().isNotFound());
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto in project CzechIdMng by bcvsolutions.
the class AbstractSchedulableStatefulExecutorIntegrationTest method testExecute.
/**
* Tests the stateful execution method of the task by the following
* scenario:
* 1. find all identities to process
* 2. process retrieved identities
* 3. persist processing log
* 4. save processed identities into processed queue
*
* Second execution run:
* 1. find all identities to process - same as first run
* 2. call process retrieved identities - all have been processed already
* 3. check processing log - nothing new was processed, therefore must be empty
* 4. check processed items queue did not change
*
* Third run:
* 1. find all identities to process - returns empty list
* 2. check processing log - nothing was processed
* 3. check processed items queue - must be empty
* @throws Exception
*/
@Test
public void testExecute() throws Exception {
// manually prepare control entities - normally scheduler will take care of it itself
IdmScheduledTaskDto scheduledTask = createIdmScheduledTask(UUID.randomUUID().toString());
IdmLongRunningTaskDto longRunningTask = createIdmLongRunningTask(scheduledTask, TestIdenityIntegrationExecutor.class);
executor.setLongRunningTaskId(longRunningTask.getId());
// first run
List<IdmIdentityDto> itemsToProcess = getTestIdentities();
// set executor data
executor.dtos = itemsToProcess;
//
Boolean result = executor.process();
Page<IdmProcessedTaskItemDto> queueItems = itemService.findQueueItems(scheduledTask, null);
Page<IdmProcessedTaskItemDto> logItems = itemService.findLogItems(longRunningTask, null);
//
assertTrue(result);
assertEquals(longRunningTask.getScheduledTask(), scheduledTask.getId());
assertEquals(itemsToProcess.size(), queueItems.getTotalElements());
assertEquals(itemsToProcess.size(), logItems.getTotalElements());
assertEquals(Long.valueOf(itemsToProcess.size()), executor.getCount());
assertEquals(Long.valueOf(itemsToProcess.size()), executor.getCounter());
SchedulerTestUtils.checkLogItems(longRunningTask, IdmIdentityDto.class, logItems);
SchedulerTestUtils.checkQueueItems(scheduledTask, IdmIdentityDto.class, queueItems);
//
// second run
//
longRunningTask = createIdmLongRunningTask(scheduledTask, TestIdenityIntegrationExecutor.class);
executor.setLongRunningTaskId(longRunningTask.getId());
executor.dtos = itemsToProcess;
//
result = executor.process();
queueItems = itemService.findQueueItems(scheduledTask, null);
logItems = itemService.findLogItems(longRunningTask, null);
//
assertTrue(result);
assertEquals(itemsToProcess.size(), queueItems.getTotalElements());
assertEquals(0, logItems.getTotalElements());
assertEquals(Long.valueOf(0), executor.getCount());
assertEquals(Long.valueOf(0), executor.getCounter());
SchedulerTestUtils.checkQueueItems(scheduledTask, IdmIdentityDto.class, queueItems);
//
// third run
//
longRunningTask = createIdmLongRunningTask(scheduledTask, TestIdenityIntegrationExecutor.class);
executor.setLongRunningTaskId(longRunningTask.getId());
//
result = executor.process();
queueItems = itemService.findQueueItems(scheduledTask, null);
logItems = itemService.findLogItems(longRunningTask, null);
//
assertTrue(result);
assertEquals(0, queueItems.getTotalElements());
assertEquals(0, logItems.getTotalElements());
assertEquals(Long.valueOf(0), executor.getCount());
assertEquals(Long.valueOf(0), executor.getCounter());
}
Aggregations