Search in sources :

Example 21 with IdmProcessedTaskItemDto

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);
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with IdmProcessedTaskItemDto

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);
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with IdmProcessedTaskItemDto

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;
}
Also used : IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)

Example 24 with IdmProcessedTaskItemDto

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());
}
Also used : IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test)

Example 25 with IdmProcessedTaskItemDto

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());
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) IdmProcessedTaskItemDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmProcessedTaskItemDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) 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