Search in sources :

Example 1 with ProvisioningQueueTaskExecutor

use of eu.bcvsolutions.idm.acc.scheduler.task.impl.ProvisioningQueueTaskExecutor in project CzechIdMng by bcvsolutions.

the class DefaultProvisioningExecutorIntegrationTest method testAsynchronousSystem.

@Test
public void testAsynchronousSystem() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    system.setQueue(true);
    system = systemService.save(system);
    // 
    // create test provisioning context
    SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, "firstname");
    Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
    String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
    // 
    // publish event
    provisioningExecutor.execute(provisioningOperation);
    // is necessary to get again operation from service
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemEntity(provisioningOperation.getSystemEntity());
    filter.setSystemId(system.getId());
    SysProvisioningOperationDto operation = provisioningOperationService.find(filter, null).getContent().get(0);
    assertEquals(OperationState.CREATED, operation.getResultState());
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertTrue(systemEntity.isWish());
    assertNull(getHelper().findResource(uid));
    // 
    // execute LRT with incorrect setting - virtual at fist - expected no process
    ProvisioningQueueTaskExecutor provisioningQueueExecutor = new ProvisioningQueueTaskExecutor();
    provisioningQueueExecutor.setVirtual(true);
    Boolean result = longRunningTaskManager.executeSync(provisioningQueueExecutor);
    assertTrue(result);
    IdmLongRunningTaskDto lrt = longRunningTaskManager.getLongRunningTask(provisioningQueueExecutor.getLongRunningTaskId());
    assertEquals(0L, lrt.getCount().longValue());
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertTrue(systemEntity.isWish());
    assertNull(getHelper().findResource(uid));
    // 
    // execute LRT with correct setting
    provisioningQueueExecutor = new ProvisioningQueueTaskExecutor();
    result = longRunningTaskManager.executeSync(provisioningQueueExecutor);
    assertTrue(result);
    lrt = longRunningTaskManager.getLongRunningTask(provisioningQueueExecutor);
    assertEquals(1L, lrt.getCount().longValue());
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
    assertFalse(systemEntity.isWish());
    assertNotNull(getHelper().findResource(uid));
}
Also used : ProvisioningQueueTaskExecutor(eu.bcvsolutions.idm.acc.scheduler.task.impl.ProvisioningQueueTaskExecutor) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningAttributeDto(eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)1 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)1 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)1 ProvisioningQueueTaskExecutor (eu.bcvsolutions.idm.acc.scheduler.task.impl.ProvisioningQueueTaskExecutor)1 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 Test (org.junit.Test)1