use of eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter in project CzechIdMng by bcvsolutions.
the class ContractGuaranteeSaveAndDeleteProcessorTest method testCreateContractGuaranteeWithoutProvisioning.
@Test
public void testCreateContractGuaranteeWithoutProvisioning() {
IdmIdentityDto identity = testHelper.createIdentity();
//
IdmIdentityDto guarantee = testHelper.createIdentity();
IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
testHelper.createContractGuarantee(primeContract.getId(), guarantee.getId());
//
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setEntityIdentifier(identity.getId());
List<SysProvisioningArchiveDto> content = provisioningArchiveService.find(filter, null).getContent();
assertEquals(0, content.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter in project CzechIdMng by bcvsolutions.
the class DefaultProvisioningExecutorIntegrationTest method testClearProvisioningBatchOnReadonlySystem.
@Test
public void testClearProvisioningBatchOnReadonlySystem() {
SysSystemDto system = helper.createTestResourceSystem(true);
system.setReadonly(true);
system = systemService.save(system);
String firstname = "firstname";
SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, firstname);
Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
//
// publish event
// 1 - create
provisioningExecutor.execute(provisioningOperation);
// is necessary to get again operation from service
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemEntity(provisioningOperation.getSystemEntity());
filter.setSystemId(system.getId());
SysProvisioningOperationDto readOnlyOperation = provisioningOperationService.find(filter, null).getContent().get(0);
assertEquals(OperationState.NOT_EXECUTED, readOnlyOperation.getResultState());
assertEquals(AccResultCode.PROVISIONING_SYSTEM_READONLY.name(), readOnlyOperation.getResult().getModel().getStatusEnum());
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
// 2 - update
provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 2));
// 3 - update
provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 3));
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertTrue(systemEntity.isWish());
assertNull(helper.findResource(uid));
//
// check batch
SysProvisioningBatchDto batch = provisioningBatchService.findBatch(system.getId(), readOnlyOperation.getEntityIdentifier(), systemEntity.getId());
Assert.assertNotNull(batch);
//
// check provisioning operation requests
List<SysProvisioningOperationDto> requests = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
Assert.assertEquals(3, requests.size());
//
// execute first operation - create
system.setReadonly(false);
system = systemService.save(system);
provisioningExecutor.execute(readOnlyOperation);
Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertFalse(systemEntity.isWish());
TestResource resource = helper.findResource(uid);
assertNotNull(resource);
Assert.assertEquals(firstname, resource.getFirstname());
Assert.assertEquals(2, provisioningOperationService.findByBatchId(batch.getId(), null).getContent().size());
//
// execute whole batch
provisioningExecutor.execute(batch);
//
resource = helper.findResource(uid);
Assert.assertEquals(firstname + 3, resource.getFirstname());
Assert.assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
Assert.assertNull(provisioningBatchService.get(batch.getId()));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter in project CzechIdMng by bcvsolutions.
the class DefaultProvisioningExecutorIntegrationTest method testAsynchronousSystem.
@Test
public void testAsynchronousSystem() {
SysSystemDto system = helper.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(helper.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(helper.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(helper.findResource(uid));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationFilterIntegrationTest method systemEntityUidFilterTest.
@Test
public void systemEntityUidFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
SysSystemDto system = createSystem();
SysProvisioningOperationDto provisioningOperation1 = createProvisioningOperation(entityType, system);
SysProvisioningOperationDto provisioningOperation2 = createProvisioningOperation(entityType, system);
SysProvisioningOperationDto provisioningOperation3 = createProvisioningOperation(entityType, system);
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
filter.setSystemEntityUid(provisioningOperation1.getSystemEntityUid());
Page<SysProvisioningOperationDto> result = operationService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(provisioningOperation1));
assertFalse(result.getContent().contains(provisioningOperation2));
assertFalse(result.getContent().contains(provisioningOperation3));
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter in project CzechIdMng by bcvsolutions.
the class SysProvisioningOperationFilterIntegrationTest method dateTimeFilterTest.
@Test
public void dateTimeFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
SysSystemDto system = createSystem();
createProvisioningOperation(entityType, system);
helper.waitForResult(null, null, 1);
DateTime dateTime = DateTime.now();
SysProvisioningOperationDto provisioningOperation2 = createProvisioningOperation(entityType, system);
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemId(system.getId());
filter.setFrom(dateTime);
Page<SysProvisioningOperationDto> result = operationService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(provisioningOperation2));
dateTime = dateTime.minusHours(1);
SysProvisioningOperationFilter filter2 = new SysProvisioningOperationFilter();
filter2.setSystemId(system.getId());
filter2.setTill(dateTime);
Page<SysProvisioningOperationDto> result2 = operationService.find(filter2, null, permission);
assertEquals(0, result2.getTotalElements());
}
Aggregations