Search in sources :

Example 46 with IdmLongRunningTaskFilter

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());
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) ZonedDateTime(java.time.ZonedDateTime) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 47 with IdmLongRunningTaskFilter

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());
}
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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 48 with IdmLongRunningTaskFilter

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

Example 49 with IdmLongRunningTaskFilter

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());
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 50 with IdmLongRunningTaskFilter

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());
}
Also used : 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)

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