use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmLongRunningTaskServiceIntegrationTest method statefulFilterTest.
@Test
public void statefulFilterTest() {
ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.MILLIS);
IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
filter.setFrom(now);
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.setStateful(false);
service.save(task1);
//
LongRunningTaskExecutor<String> taskExecutor2 = new TestSimpleLongRunningTaskExecutor(expectedResult);
assertNull(taskExecutor2.getLongRunningTaskId());
manager.executeSync(taskExecutor2);
service.get(taskExecutor2.getLongRunningTaskId());
//
LongRunningTaskExecutor<String> taskExecutor3 = new TestSimpleLongRunningTaskExecutor(expectedResult);
assertNull(taskExecutor3.getLongRunningTaskId());
manager.executeSync(taskExecutor3);
service.get(taskExecutor3.getLongRunningTaskId());
// set filter
filter.setTaskType(task1.getTaskType());
filter.setStateful(true);
Page<IdmLongRunningTaskDto> result = service.find(filter, null);
assertEquals("Wrong StateFul true", 2, result.getTotalElements());
filter.setStateful(false);
result = service.find(filter, null);
assertEquals("Wrong StateFul false", 1, result.getTotalElements());
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmLongRunningTaskServiceIntegrationTest method datesFilterTest.
@Test
@Transactional
public void datesFilterTest() {
// set tasks
LongRunningTaskExecutor<String> taskExecutor = new TestFilterLongRunningTaskExecutor("one");
assertNull(taskExecutor.getLongRunningTaskId());
manager.executeSync(taskExecutor);
IdmLongRunningTaskDto task1 = service.get(taskExecutor.getLongRunningTaskId());
// created is filled automatically
getHelper().waitForResult(null, 1, 1);
LongRunningTaskExecutor<String> taskExecutor2 = new TestFilterLongRunningTaskExecutor("two");
assertNull(taskExecutor2.getLongRunningTaskId());
manager.executeSync(taskExecutor2);
IdmLongRunningTaskDto task2 = service.get(taskExecutor2.getLongRunningTaskId());
//
IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
filter.setTaskType(TestFilterLongRunningTaskExecutor.class.getCanonicalName());
//
filter.setFrom(task1.getCreated());
Page<IdmLongRunningTaskDto> result = service.find(filter, null);
assertEquals("Wrong From Date", 2, result.getTotalElements());
filter.setTill(task2.getCreated());
result = service.find(filter, null);
assertEquals("Wrong Till Date", 2, result.getTotalElements());
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmLongRunningTaskServiceIntegrationTest method runningFilterTest.
@Test
public void runningFilterTest() {
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.setRunning(true);
service.save(task1);
// set filter
filter.setTaskType(task1.getTaskType());
filter.setRunning(task1.isRunning());
Page<IdmLongRunningTaskDto> result = service.find(filter, null);
assertEquals("Wrong Running", task1.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class DefaultLongRunningTaskManagerIntegrationTest method testProcessCreatedLrtUnderNewTransactionId.
@Test
public void testProcessCreatedLrtUnderNewTransactionId() {
TestRegistrableSchedulableTask executorOne = new TestRegistrableSchedulableTask();
executorOne.setDescription(getHelper().createName());
executorOne.setCount(1L);
//
executorOne.setLongRunningTaskId(null);
manager.resolveLongRunningTask(executorOne, null, null);
executorOne.setLongRunningTaskId(null);
manager.resolveLongRunningTask(executorOne, null, OperationState.CREATED);
executorOne.setLongRunningTaskId(null);
manager.resolveLongRunningTask(executorOne, null, OperationState.CREATED);
//
manager.processCreated();
//
IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
filter.setTaskType(AutowireHelper.getTargetType(executorOne));
filter.setText(executorOne.getDescription());
filter.setOperationState(OperationState.EXECUTED);
getHelper().waitForResult(res -> {
return service.find(filter, null).getContent().size() != 3;
}, 500, 30);
//
List<IdmLongRunningTaskDto> ltrs = manager.findLongRunningTasks(filter, null).getContent();
//
Assert.assertEquals(3, ltrs.size());
Assert.assertNotEquals(ltrs.get(0).getTransactionId(), ltrs.get(1).getTransactionId());
Assert.assertNotEquals(ltrs.get(0).getTransactionId(), ltrs.get(2).getTransactionId());
Assert.assertNotEquals(ltrs.get(1).getTransactionId(), ltrs.get(2).getTransactionId());
}
use of eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter in project CzechIdMng by bcvsolutions.
the class LongRunningTaskCancelBulkActionIntegrationTest method testPreventCancelItself.
@Test
public void testPreventCancelItself() {
IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
filter.setRunning(Boolean.TRUE);
filter.setTaskType(LongRunningTaskCancelBulkAction.class.getCanonicalName());
//
IdmBulkActionDto bulkAction = findBulkAction(IdmLongRunningTask.class, LongRunningTaskCancelBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, null, 0L, 0L);
Assert.assertEquals(OperationState.EXECUTED, service.get(bulkAction.getLongRunningTaskId()).getResultState());
}
Aggregations