Search in sources :

Example 51 with IdmLongRunningTaskFilter

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

the class IdmLongRunningTaskControllerRestTest method testFindByCreated.

@Test
public void testFindByCreated() {
    String mockInstanceId = getHelper().createName();
    IdmLongRunningTaskDto task = prepareDto();
    task.setTaskType(ProcessAutomaticRoleByTreeTaskExecutor.class.getCanonicalName());
    task.getTaskProperties().put(AbstractAutomaticRoleTaskExecutor.PARAMETER_ROLE_TREE_NODE, UUID.randomUUID());
    task.setInstanceId(mockInstanceId);
    IdmLongRunningTaskDto taskOne = createDto(task);
    // 
    // created is filled automatically
    getHelper().waitForResult(null, 1, 1);
    ZonedDateTime middle = ZonedDateTime.now();
    getHelper().waitForResult(null, 1, 1);
    // 
    task = prepareDto();
    task.setInstanceId(mockInstanceId);
    IdmLongRunningTaskDto taskTwo = createDto(task);
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    filter.setInstanceId(mockInstanceId);
    // 
    filter.setFrom(middle);
    List<IdmLongRunningTaskDto> results = find(filter);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(t -> t.getId().equals(taskTwo.getId())));
    // 
    filter.setFrom(null);
    filter.setTill(middle);
    results = find(filter);
    Assert.assertEquals(1, results.size());
    Assert.assertTrue(results.stream().anyMatch(t -> t.getId().equals(taskOne.getId())));
    // 
    filter.setFrom(taskOne.getCreated().truncatedTo(ChronoUnit.MILLIS));
    filter.setTill(taskTwo.getCreated().truncatedTo(ChronoUnit.MILLIS).plus(1, ChronoUnit.MILLIS));
    results = find(filter);
    Assert.assertEquals(2, results.size());
    Assert.assertTrue(results.stream().anyMatch(t -> t.getId().equals(taskOne.getId())));
    Assert.assertTrue(results.stream().anyMatch(t -> t.getId().equals(taskTwo.getId())));
}
Also used : ProcessAutomaticRoleByTreeTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessAutomaticRoleByTreeTaskExecutor) AbstractAutomaticRoleTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.AbstractAutomaticRoleTaskExecutor) ProcessAutomaticRoleByTreeTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessAutomaticRoleByTreeTaskExecutor) ZonedDateTime(java.time.ZonedDateTime) TestTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.TestTaskExecutor) Autowired(org.springframework.beans.factory.annotation.Autowired) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) UUID(java.util.UUID) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) Propagation(org.springframework.transaction.annotation.Propagation) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) ZonedDateTime(java.time.ZonedDateTime) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 52 with IdmLongRunningTaskFilter

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

the class LongRunningTaskDeleteBulkActionIntegrationTest method testProcessBulkActionByFilter.

@Test
public void testProcessBulkActionByFilter() {
    List<IdmLongRunningTaskDto> tasks = createTasks(5);
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    filter.setId(tasks.get(2).getId());
    List<IdmLongRunningTaskDto> checkEvents = service.find(filter, null).getContent();
    Assert.assertEquals(1, checkEvents.size());
    IdmBulkActionDto bulkAction = findBulkAction(IdmLongRunningTask.class, LongRunningTaskDeleteBulkAction.NAME);
    bulkAction.setTransformedFilter(filter);
    bulkAction.setFilter(toMap(filter));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    Assert.assertNull(service.get(tasks.get(2)));
    Assert.assertNotNull(service.get(tasks.get(1)));
    Assert.assertNotNull(service.get(tasks.get(3)));
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 53 with IdmLongRunningTaskFilter

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

the class LongRunningTaskRunBulkActionIntegrationTest method processBulkActionByFilter.

@Test
public void processBulkActionByFilter() {
    List<IdmLongRunningTaskDto> tasks = createTasks(5);
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    filter.setId(tasks.get(2).getId());
    List<IdmLongRunningTaskDto> checkEvents = service.find(filter, null).getContent();
    Assert.assertEquals(1, checkEvents.size());
    IdmBulkActionDto bulkAction = findBulkAction(IdmLongRunningTask.class, LongRunningTaskRunBulkAction.NAME);
    bulkAction.setTransformedFilter(filter);
    bulkAction.setFilter(toMap(filter));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    Assert.assertEquals(OperationState.EXCEPTION, service.get(tasks.get(2)).getResultState());
    Assert.assertEquals(OperationState.CREATED, service.get(tasks.get(1)).getResultState());
    Assert.assertEquals(OperationState.CREATED, service.get(tasks.get(3)).getResultState());
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 54 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceIntegrationTest method typeFilterTest.

@Test
public void typeFilterTest() {
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    String expectedResult = getHelper().createName();
    // set tasks
    LongRunningTaskExecutor<String> taskExecutor = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor.getLongRunningTaskId());
    manager.executeSync(taskExecutor);
    IdmLongRunningTaskDto task1 = service.get(taskExecutor.getLongRunningTaskId());
    task1.setTaskType(getHelper().createName());
    service.save(task1);
    filter.setTaskType(task1.getTaskType());
    Page<IdmLongRunningTaskDto> result = service.find(filter, null);
    assertEquals("Wrong TaskType", task1.getId(), result.getContent().get(0).getId());
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmLongRunningTaskFilter (eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter)54 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)41 Test (org.junit.Test)31 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)21 UUID (java.util.UUID)18 Transactional (org.springframework.transaction.annotation.Transactional)11 AbstractBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractBulkActionTest)9 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)8 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)8 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)8 List (java.util.List)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 LongRunningFutureTask (eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask)7 Assert (org.junit.Assert)7 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)6 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)5 EventConfiguration (eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration)5 AutomaticRoleAttributeRuleComparison (eu.bcvsolutions.idm.core.api.domain.AutomaticRoleAttributeRuleComparison)5 AutomaticRoleAttributeRuleType (eu.bcvsolutions.idm.core.api.domain.AutomaticRoleAttributeRuleType)5