use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testDeletePerformance200WithoutRequest.
@Ignore
@Test
@Transactional
public void testDeletePerformance200WithoutRequest() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
roleAccountFilter.setEntityId(identity.getId());
roleAccountFilter.setOwnership(Boolean.TRUE);
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
List<IdmRoleDto> roles = this.createRolesWithSystem(system, 200);
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
Date startAcm = new Date();
IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
helper.executeRequest(request, false, true);
Date endAcm = new Date();
System.out.println("testDeletePerformance200WithoutRequest - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(200, identityAccounts.size());
// Delete
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityContractId(primeContract.getId());
List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
Date startAcmDelete = new Date();
identityRoles.forEach(identityRole -> {
identityRoleService.delete(identityRole);
if (getHibernateSession().isOpen()) {
getHibernateSession().flush();
getHibernateSession().clear();
}
});
Date endAcmDelete = new Date();
System.out.println("testDeletePerformance200WithoutRequest - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testDeletePerformance100.
@Ignore
@Test
@Transactional
public void testDeletePerformance100() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
roleAccountFilter.setEntityId(identity.getId());
roleAccountFilter.setOwnership(Boolean.TRUE);
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
List<IdmRoleDto> roles = this.createRolesWithSystem(system, 100);
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identity.getId());
Date startAcm = new Date();
IdmRoleRequestDto request = helper.createRoleRequest(primeContract, roles.toArray(new IdmRoleDto[0]));
helper.executeRequest(request, false, true);
Date endAcm = new Date();
System.out.println("testDeletePerformance100 - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(100, identityAccounts.size());
// Delete
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityContractId(primeContract.getId());
List<IdmIdentityRoleDto> identityRoles = identityRoleService.find(identityRoleFilter, null).getContent();
IdmRoleRequestDto requestDel = helper.createRoleRequest(identity);
identityRoles.forEach(identityRole -> {
IdmConceptRoleRequestDto conceptRoleRequest = new IdmConceptRoleRequestDto();
conceptRoleRequest.setRoleRequest(requestDel.getId());
conceptRoleRequest.setIdentityContract(primeContract.getId());
conceptRoleRequest.setIdentityRole(identityRole.getId());
conceptRoleRequest.setOperation(ConceptRoleRequestOperation.REMOVE);
conceptRoleRequestService.save(conceptRoleRequest);
});
Date startAcmDelete = new Date();
helper.executeRequest(requestDel, false, true);
Date endAcmDelete = new Date();
System.out.println("testDeletePerformance100 - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(0, identityAccounts.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method defaultAccountAddValid.
@Test
public void defaultAccountAddValid() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
IdmRoleDto roleDefault = roleService.getByCode(ROLE_DEFAULT);
Assert.assertNull("No account for this identity can be found, before account management start!", helper.findResource("x" + IDENTITY_USERNAME));
IdmIdentityRoleDto irdto = new IdmIdentityRoleDto();
irdto.setIdentityContract(identityContractService.findAllByIdentity(identity.getId()).get(0).getId());
irdto.setRole(roleDefault.getId());
// This evokes IdentityRole SAVE event. On this event will be start
// account management and provisioning
IdmIdentityRoleDto irCreated = identityRoleService.save(irdto);
AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
iaccFilter.setIdentityId(identity.getId());
iaccFilter.setIdentityRoleId(irCreated.getId());
AccIdentityAccountDto identityAccount = identityAccountService.find(iaccFilter, null).getContent().get(0);
Assert.assertNotNull("Idenitity account have to exists after account management was started!", identityAccount);
Assert.assertNotNull("Account have to exists after account management was started!", identityAccount.getAccount());
Assert.assertEquals(accountService.get(identityAccount.getAccount()).getUid(), "x" + IDENTITY_USERNAME);
TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method overloadedAttributeAdd_B_DisableFirstNameRole.
@Test
public void overloadedAttributeAdd_B_DisableFirstNameRole() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
IdmRoleDto roleLastName = roleService.getByCode(ROLE_OVERLOADING_FIRST_NAME);
Assert.assertNotNull("Account for this identity have to be found!", helper.findResource("x" + IDENTITY_USERNAME));
IdmIdentityRoleDto irdto = new IdmIdentityRoleDto();
irdto.setIdentityContract(identityContractService.findAllByIdentity(identity.getId()).get(0).getId());
irdto.setRole(roleLastName.getId());
// This evokes IdentityRole SAVE event. On this event will be start
// account management and provisioning
identityRoleService.save(irdto);
AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
iaccFilter.setIdentityId(identity.getId());
// Now we have to identity roles (role_overloading_first_name and
// role_overloading_last_name) and identity accounts
Assert.assertEquals("Idenitity accounts have to exists (two items) after account management was started!", 2, identityAccountService.find(iaccFilter, null).getContent().size());
TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", createdAccount);
Assert.assertEquals("First name on target system must be equals with first name on identity", identity.getFirstName(), createdAccount.getFirstname());
identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
identity.setEmail(IDENTITY_EMAIL_CHANGED);
// This evokes Identity SAVE event. On this event will be start
// account management and provisioning
identityService.save(identity);
createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
// Because first name attribute was disabled, we now expect change only
// on email attribute
Assert.assertEquals("Last name on target system must be equals with email on identity (we use overloded attribute)", IDENTITY_EMAIL_CHANGED, createdAccount.getLastname());
Assert.assertNotEquals("First name on target system must be not equals with first name on identity (we use overloded disabled attribute)", identity.getFirstName(), createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testAcmPerformance100WithoutRequest.
@Ignore
@Test
@Transactional
public void testAcmPerformance100WithoutRequest() {
SysSystemDto system = initIdentityData();
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
mapping = systemMappingService.save(mapping);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountFilter roleAccountFilter = new AccIdentityAccountFilter();
roleAccountFilter.setEntityId(identity.getId());
roleAccountFilter.setOwnership(Boolean.TRUE);
roleAccountFilter.setSystemId(system.getId());
List<AccIdentityAccountDto> identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
// None role assigned
Assert.assertEquals(0, identityAccounts.size());
List<IdmRoleDto> roles = this.createRolesWithSystem(system, 100);
UUID primeContract = identityContractService.getPrimeContract(identity.getId()).getId();
Date startAcm = new Date();
roles.forEach(role -> {
IdmIdentityRoleDto identityRole = new IdmIdentityRoleDto();
identityRole.setIdentityContract(primeContract);
identityRole.setRole(role.getId());
identityRole = identityRoleService.save(identityRole);
// Call hard hibernate session flush and clear
if (getHibernateSession().isOpen()) {
getHibernateSession().flush();
getHibernateSession().clear();
}
});
Date endAcm = new Date();
System.out.println("testAcmPerformance100 - ACM duration: " + (endAcm.getTime() - startAcm.getTime()));
identityAccounts = identityAccountService.find(roleAccountFilter, null).getContent();
Assert.assertEquals(100, identityAccounts.size());
}
Aggregations