use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class PerformanceAccountManagementTest method testDeletePerformance100WithoutRequest.
@Ignore
@Test
@Transactional
public void testDeletePerformance100WithoutRequest() {
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("testDeletePerformance100WithoutRequest - 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();
Date startAcmDelete = new Date();
identityRoles.forEach(identityRole -> {
identityRoleService.delete(identityRole);
if (getHibernateSession().isOpen()) {
getHibernateSession().flush();
getHibernateSession().clear();
}
});
Date endAcmDelete = new Date();
System.out.println("testDeletePerformance100WithoutRequest - Delete duration: " + (endAcmDelete.getTime() - startAcmDelete.getTime()));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter 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.core.api.dto.filter.IdmIdentityRoleFilter 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.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class IdentityProvisioningTest method testAttachment.
@Test
public void testAttachment() {
SysSystemDto systemDto = helper.createTestResourceSystem(true);
SysSystemMappingDto defaultMapping = helper.getDefaultMapping(systemDto);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(systemDto.getId());
List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
SysSchemaAttributeDto descriptionSchemaAttribute = schemaAttributes.stream().filter(attribute -> TestHelper.ATTRIBUTE_MAPPING_DESCRIPTION.equalsIgnoreCase(attribute.getName())).findFirst().get();
SysSystemAttributeMappingDto attributeByte = new SysSystemAttributeMappingDto();
attributeByte.setUid(false);
attributeByte.setEntityAttribute(false);
attributeByte.setExtendedAttribute(true);
attributeByte.setIdmPropertyName(getHelper().createName());
attributeByte.setName(descriptionSchemaAttribute.getName());
attributeByte.setSchemaAttribute(descriptionSchemaAttribute.getId());
attributeByte.setSystemMapping(defaultMapping.getId());
// Transformation data to string
attributeByte.setTransformToResourceScript("if(attributeValue == null) " + System.lineSeparator() + "{return null;}" + System.lineSeparator() + " return new String(attributeValue.getData());");
schemaAttributeMappingService.save(attributeByte);
IdmRoleDto roleWithSystem = helper.createRole();
helper.createRoleSystem(roleWithSystem, systemDto);
// Set type of attribute to attachment
IdmFormAttributeDto eavAttributeByte = formService.getAttribute(IdmIdentityDto.class, attributeByte.getIdmPropertyName());
eavAttributeByte.setPersistentType(PersistentType.ATTACHMENT);
eavAttributeByte = formService.saveAttribute(eavAttributeByte);
// Create attachment with content
String originalContent = getHelper().createName();
IdmAttachmentDto attachment = new IdmAttachmentDto();
attachment.setName("test.txt");
attachment.setMimetype("text/plain");
attachment.setInputData(IOUtils.toInputStream(originalContent));
attachment.setOwnerType(AttachmentManager.TEMPORARY_ATTACHMENT_OWNER_TYPE);
attachment = attachmentManager.saveAttachment(null, attachment);
InputStream inputStream = attachmentManager.getAttachmentData(attachment.getId());
try {
String content = IOUtils.toString(inputStream);
assertEquals(originalContent, content);
// Create form value with attachment
IdmIdentityDto identity = helper.createIdentity();
formService.saveValues(identity, eavAttributeByte, Lists.newArrayList(attachment.getId()));
// Assign the system
helper.createIdentityRole(identity, roleWithSystem, null, null);
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityId(identity.getId());
TestResource resource = helper.findResource(identity.getUsername());
assertNotNull(resource);
String valueOnResource = resource.getDescrip();
InputStream is = attachmentManager.getAttachmentData(attachment.getId());
try {
String data = new String(IOUtils.toByteArray(is));
assertEquals(data, valueOnResource);
} finally {
IOUtils.closeQuietly(is);
}
} catch (IOException e) {
throw new CoreException(e);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter in project CzechIdMng by bcvsolutions.
the class IdentityProvisioningTest method testAssignedRolesForSystem.
@Test
public void testAssignedRolesForSystem() {
SysSystemDto systemDto = helper.createTestResourceSystem(true);
SysSystemMappingDto defaultMapping = helper.getDefaultMapping(systemDto);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(systemDto.getId());
List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaAttributeFilter, null).getContent();
SysSchemaAttributeDto descriptionSchemaAttribute = schemaAttributes.stream().filter(attribute -> TestHelper.ATTRIBUTE_MAPPING_DESCRIPTION.equalsIgnoreCase(attribute.getName())).findFirst().get();
SysSystemAttributeMappingDto attributeAssignedRoles = new SysSystemAttributeMappingDto();
attributeAssignedRoles.setUid(false);
attributeAssignedRoles.setEntityAttribute(true);
attributeAssignedRoles.setIdmPropertyName(IdentityProvisioningExecutor.ASSIGNED_ROLES_FOR_SYSTEM_FIELD);
attributeAssignedRoles.setTransformToResourceScript("if(attributeValue == null) " + System.lineSeparator() + "{return null;}" + System.lineSeparator() + " String result = '';" + System.lineSeparator() + " for(Object assignedRole : attributeValue)" + System.lineSeparator() + " {result = result + (assignedRole.toString())};" + System.lineSeparator() + " return result;");
attributeAssignedRoles.setName(descriptionSchemaAttribute.getName());
attributeAssignedRoles.setSchemaAttribute(descriptionSchemaAttribute.getId());
attributeAssignedRoles.setSystemMapping(defaultMapping.getId());
schemaAttributeMappingService.save(attributeAssignedRoles);
IdmRoleDto roleWithSystem = helper.createRole();
IdmRoleDto roleWithOutSystem = helper.createRole();
helper.createRoleSystem(roleWithSystem, systemDto);
IdmIdentityDto identity = helper.createIdentity();
helper.createIdentityRole(identity, roleWithOutSystem, null, null);
IdmIdentityRoleDto identityRoleWithSystem = helper.createIdentityRole(identity, roleWithSystem, null, null);
IdmIdentityRoleFilter identityRoleFilter = new IdmIdentityRoleFilter();
identityRoleFilter.setIdentityId(identity.getId());
TestResource resource = helper.findResource(identity.getUsername());
assertNotNull(resource);
String valueOnResource = resource.getDescrip();
String result = "";
IdmFormInstanceDto formInstanceDto = identityRoleService.getRoleAttributeValues(identityRoleWithSystem);
identityRoleWithSystem.getEavs().clear();
identityRoleWithSystem.getEavs().add(formInstanceDto);
result = IdentityProvisioningExecutor.convertToAssignedRoleDto(identityRoleWithSystem).toString();
assertEquals(result, valueOnResource);
}
Aggregations