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