Search in sources :

Example 6 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceTest method textFilterTest.

@Test
public void textFilterTest() {
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    String expectedResult = "TEST_SUCCESS_04_M";
    String type1 = "Type00001";
    String type2 = "Type00002";
    // set tasks
    LongRunningTaskExecutor<String> taskExecutor = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor.getLongRunningTaskId());
    manager.executeSync(taskExecutor);
    IdmLongRunningTaskDto task1 = idmLongRunningTaskService.get(taskExecutor.getLongRunningTaskId());
    task1.setTaskType(type1);
    idmLongRunningTaskService.save(task1);
    LongRunningTaskExecutor<String> taskExecutor2 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor2.getLongRunningTaskId());
    manager.executeSync(taskExecutor2);
    IdmLongRunningTaskDto task2 = idmLongRunningTaskService.get(taskExecutor2.getLongRunningTaskId());
    task2.setTaskType(type1);
    idmLongRunningTaskService.save(task2);
    LongRunningTaskExecutor<String> taskExecutor3 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor3.getLongRunningTaskId());
    manager.executeSync(taskExecutor3);
    IdmLongRunningTaskDto task3 = idmLongRunningTaskService.get(taskExecutor3.getLongRunningTaskId());
    task3.setTaskType(type2);
    idmLongRunningTaskService.save(task3);
    LongRunningTaskExecutor<String> taskExecutor4 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor4.getLongRunningTaskId());
    manager.executeSync(taskExecutor4);
    IdmLongRunningTaskDto task4 = idmLongRunningTaskService.get(taskExecutor4.getLongRunningTaskId());
    task4.setTaskDescription(type1);
    idmLongRunningTaskService.save(task4);
    // set filter
    filter.setText(type1);
    Page<IdmLongRunningTaskDto> result = idmLongRunningTaskService.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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 7 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceTest method statefulFilterTest.

@Test
public void statefulFilterTest() {
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    String expectedResult = "TEST_SUCCESS_01_M";
    // set tasks
    LongRunningTaskExecutor<String> taskExecutor = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor.getLongRunningTaskId());
    manager.executeSync(taskExecutor);
    IdmLongRunningTaskDto task1 = idmLongRunningTaskService.get(taskExecutor.getLongRunningTaskId());
    task1.setStateful(false);
    idmLongRunningTaskService.save(task1);
    // 
    LongRunningTaskExecutor<String> taskExecutor2 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor2.getLongRunningTaskId());
    manager.executeSync(taskExecutor2);
    idmLongRunningTaskService.get(taskExecutor2.getLongRunningTaskId());
    // 
    LongRunningTaskExecutor<String> taskExecutor3 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor3.getLongRunningTaskId());
    manager.executeSync(taskExecutor3);
    idmLongRunningTaskService.get(taskExecutor3.getLongRunningTaskId());
    // set filter
    filter.setTaskType(task1.getTaskType());
    filter.setStateful(true);
    Page<IdmLongRunningTaskDto> result = idmLongRunningTaskService.find(filter, null);
    assertEquals("Wrong StateFul true", 2, result.getTotalElements());
    filter.setStateful(false);
    result = idmLongRunningTaskService.find(filter, null);
    assertEquals("Wrong StateFul false", 1, result.getTotalElements());
}
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 8 with IdmLongRunningTaskFilter

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

the class DefaultIdmLongRunningTaskServiceTest method datesFilterTest.

@Test
public void datesFilterTest() {
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    String expectedResult = "TEST_SUCCESS_05_M";
    // set tasks
    LongRunningTaskExecutor<String> taskExecutor = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor.getLongRunningTaskId());
    manager.executeSync(taskExecutor);
    IdmLongRunningTaskDto task1 = idmLongRunningTaskService.get(taskExecutor.getLongRunningTaskId());
    LongRunningTaskExecutor<String> taskExecutor2 = new TestSimpleLongRunningTaskExecutor(expectedResult);
    assertNull(taskExecutor2.getLongRunningTaskId());
    manager.executeSync(taskExecutor2);
    IdmLongRunningTaskDto task2 = idmLongRunningTaskService.get(taskExecutor2.getLongRunningTaskId());
    task2.setCreated(task1.getCreated());
    idmLongRunningTaskService.save(task2);
    filter.setFrom(task1.getCreated());
    Page<IdmLongRunningTaskDto> result = idmLongRunningTaskService.find(filter, null);
    assertEquals("Wrong From Date", 2, result.getTotalElements());
    filter.setTill(task1.getModified());
    result = idmLongRunningTaskService.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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 9 with IdmLongRunningTaskFilter

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

the class RemoveAutomaticRoleTaskExecutor method validate.

/**
 * Automatic role removal can be start, if previously LRT ended.
 */
@Override
public void validate(IdmLongRunningTaskDto task) {
    super.validate(task);
    // 
    AbstractIdmAutomaticRoleDto automaticRole = roleTreeNodeService.get(getAutomaticRoleId());
    if (automaticRole == null) {
        // get from automatic role attribute service
        automaticRole = automaticRoleAttributeService.get(getAutomaticRoleId());
    }
    // 
    IdmLongRunningTaskFilter filter = new IdmLongRunningTaskFilter();
    filter.setTaskType(this.getClass().getCanonicalName());
    filter.setRunning(Boolean.TRUE);
    // 
    for (IdmLongRunningTaskDto longRunningTask : getLongRunningTaskService().find(filter, null)) {
        if (longRunningTask.getTaskProperties().get(AbstractAutomaticRoleTaskExecutor.PARAMETER_ROLE_TREE_NODE).equals(automaticRole.getId())) {
            throw new ResultCodeException(CoreResultCode.AUTOMATIC_ROLE_REMOVE_TASK_RUN_CONCURRENTLY, ImmutableMap.of("roleTreeNode", automaticRole.getId().toString(), "taskId", longRunningTask.getId().toString()));
        }
    }
    // 
    filter.setTaskType(AddNewAutomaticRoleTaskExecutor.class.getCanonicalName());
    for (IdmLongRunningTaskDto longRunningTask : getLongRunningTaskService().find(filter, null)) {
        if (longRunningTask.getTaskProperties().get(AbstractAutomaticRoleTaskExecutor.PARAMETER_ROLE_TREE_NODE).equals(automaticRole.getId())) {
            throw new ResultCodeException(CoreResultCode.AUTOMATIC_ROLE_REMOVE_TASK_ADD_RUNNING, ImmutableMap.of("roleTreeNode", automaticRole.getId().toString(), "taskId", longRunningTask.getId().toString()));
        }
    }
}
Also used : IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIdmAutomaticRoleDto(eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter)

Example 10 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)

Aggregations

IdmLongRunningTaskFilter (eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter)14 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)13 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)9 Test (org.junit.Test)9 Task (eu.bcvsolutions.idm.core.scheduler.api.dto.Task)4 DateTime (org.joda.time.DateTime)4 DependentTaskTrigger (eu.bcvsolutions.idm.core.scheduler.api.dto.DependentTaskTrigger)3 LongRunningFutureTask (eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask)3 FutureTask (java.util.concurrent.FutureTask)3 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)2 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 LongRunningTaskEvent (eu.bcvsolutions.idm.core.scheduler.api.event.LongRunningTaskEvent)2 UUID (java.util.UUID)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)1 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)1 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)1 AbstractIdmAutomaticRoleDto (eu.bcvsolutions.idm.core.api.dto.AbstractIdmAutomaticRoleDto)1 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)1