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