Search in sources :

Example 26 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceIntegrationTest method operationStateFilterTest.

@Test
public void operationStateFilterTest() {
    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());
    // set filter
    filter.setOperationState(task1.getResultState());
    Page<IdmLongRunningTaskDto> result = service.find(filter, null);
    assertEquals("Wrong operationState id", true, result.getContent().contains(task1));
}
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 27 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceIntegrationTest method textFilterTest.

@Test
public void textFilterTest() {
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    String expectedResult = getHelper().createName();
    String type1 = getHelper().createName();
    String type2 = getHelper().createName();
    // set tasks
    LongRunningTaskExecutor<String> taskExecutor = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor.getLongRunningTaskId());
    manager.executeSync(taskExecutor);
    IdmLongRunningTaskDto task1 = service.get(taskExecutor.getLongRunningTaskId());
    task1.setTaskType(type1);
    service.save(task1);
    LongRunningTaskExecutor<String> taskExecutor2 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor2.getLongRunningTaskId());
    manager.executeSync(taskExecutor2);
    IdmLongRunningTaskDto task2 = service.get(taskExecutor2.getLongRunningTaskId());
    task2.setTaskType(type1);
    service.save(task2);
    LongRunningTaskExecutor<String> taskExecutor3 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor3.getLongRunningTaskId());
    manager.executeSync(taskExecutor3);
    IdmLongRunningTaskDto task3 = service.get(taskExecutor3.getLongRunningTaskId());
    task3.setTaskType(type2);
    service.save(task3);
    LongRunningTaskExecutor<String> taskExecutor4 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor4.getLongRunningTaskId());
    manager.executeSync(taskExecutor4);
    IdmLongRunningTaskDto task4 = service.get(taskExecutor4.getLongRunningTaskId());
    task4.setTaskDescription(type1);
    service.save(task4);
    // set filter
    filter.setText(type1);
    Page<IdmLongRunningTaskDto> result = service.find(filter, null);
    assertEquals("Wrong Text Type", 3, result.getTotalElements());
    assertEquals("Wrong Text Type", true, result.getContent().contains(task4));
    assertEquals("Wrong Text Description", true, result.getContent().contains(task1));
}
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 28 with IdmLongRunningTaskFilter

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

the class DefaultLongRunningTaskManagerIntegrationTest method testRecoverableTask.

@Test
public void testRecoverableTask() {
    getHelper().setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
    // 
    try {
        TestTaskExecutor executorOne = new TestTaskExecutor();
        executorOne.setDescription(getHelper().createName());
        executorOne.setCount(1L);
        // first process
        manager.execute(executorOne);
        // 
        IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
        filter.setTaskType(TestTaskExecutor.class.getCanonicalName());
        filter.setText(executorOne.getDescription());
        filter.setOperationState(OperationState.EXECUTED);
        List<IdmLongRunningTaskDto> ltrs = service.find(filter, null).getContent();
        Assert.assertEquals(1, ltrs.size());
        // 
        IdmLongRunningTaskDto task = ltrs.get(0);
        manager.recover(task.getId());
        // 
        ltrs = service.find(filter, null).getContent();
        Assert.assertEquals(2, ltrs.size());
    } finally {
        getHelper().setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
    }
}
Also used : TestTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.TestTaskExecutor) 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 29 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceTest method typeFilterTest.

@Test
public void typeFilterTest() {
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    String expectedResult = "TEST_SUCCESS_03_M";
    // set tasks
    LongRunningTaskExecutor<String> taskExecutor = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor.getLongRunningTaskId());
    manager.executeSync(taskExecutor);
    IdmLongRunningTaskDto task1 = idmLongRunningTaskService.get(taskExecutor.getLongRunningTaskId());
    task1.setTaskType("Type0001");
    idmLongRunningTaskService.save(task1);
    filter.setTaskType(task1.getTaskType());
    Page<IdmLongRunningTaskDto> result = idmLongRunningTaskService.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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 30 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceTest method runningFilterTest.

@Test
public void runningFilterTest() {
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    String expectedResult = "TEST_SUCCESS_02_M";
    // set tasks
    LongRunningTaskExecutor<String> taskExecutor = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor.getLongRunningTaskId());
    manager.executeSync(taskExecutor);
    IdmLongRunningTaskDto task1 = idmLongRunningTaskService.get(taskExecutor.getLongRunningTaskId());
    task1.setRunning(true);
    idmLongRunningTaskService.save(task1);
    // set filter
    filter.setTaskType(task1.getTaskType());
    filter.setRunning(task1.isRunning());
    Page<IdmLongRunningTaskDto> result = idmLongRunningTaskService.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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

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