use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategyMergeException.
// Expected PROVISIONING_MERGE_ATTRIBUTE_IS_NOT_MULTIVALUE
@Test(expected = ProvisioningException.class)
public void doIdentityProvisioningStrategyMergeException() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
filterSchemaAttr.setIdmPropertyName("email");
filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
attributeHandling.setEntityAttribute(true);
attributeHandling.setStrategyType(AttributeMappingStrategyType.MERGE);
SysSchemaAttributeDto schemaAttributeDto = schemaAttributeService.get(attributeHandling.getSchemaAttribute());
schemaAttributeDto.setMultivalued(false);
schemaAttributeService.save(schemaAttributeDto);
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeSingleAttribute.
@Test
public void doIdentityProvisioningChangeSingleAttribute() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
identity = identityService.save(identity);
Assert.assertEquals("Identity must have this first name!", IDENTITY_CHANGED_FIRST_NAME, identity.getFirstName());
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
filter.setSystemId(systemService.getByCode(SYSTEM_NAME).getId());
AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
SysSystemDto system = DtoUtils.getEmbedded(account, AccAccount_.system);
SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(account, AccAccount_.systemEntity);
SysSystemAttributeMappingFilter attributeFilter = new SysSystemAttributeMappingFilter();
attributeFilter.setSystemId(system.getId());
attributeFilter.setIdmPropertyName("firstName");
TestResource resourceAccount = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
Assert.assertEquals("Account on target system, must have same first name as Identity", IDENTITY_CHANGED_FIRST_NAME, resourceAccount.getFirstname());
provisioningService.doProvisioningForAttribute(systemEntity, systemAttributeMappingService.find(attributeFilter, null).getContent().get(0), IDENTITY_USERNAME, ProvisioningOperationType.UPDATE, identity);
resourceAccount = entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
Assert.assertEquals("Account on target system, must have changed first name!", IDENTITY_USERNAME, resourceAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningStrategyIfNull.
@Test
public void doIdentityProvisioningStrategyIfNull() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
// Default email strategy is CREATE, we check value
TestResource resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertEquals(EMAIL_ONE, resourceAccoutn.getEmail());
SysSystemAttributeMappingFilter filterSchemaAttr = new SysSystemAttributeMappingFilter();
filterSchemaAttr.setIdmPropertyName("email");
filterSchemaAttr.setSystemId(accountService.get(accountIdentityOne.getAccount()).getSystem());
SysSystemAttributeMappingDto attributeHandling = systemAttributeMappingService.find(filterSchemaAttr, null).getContent().get(0);
attributeHandling.setEntityAttribute(true);
attributeHandling.setStrategyType(AttributeMappingStrategyType.WRITE_IF_NULL);
attributeHandling.setTransformToResourceScript("return \"" + EMAIL_TWO + "\";");
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
// Email strategy is WRITE_IF_NULL ... email in account must not have new value
resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertNotEquals(EMAIL_TWO, resourceAccoutn.getEmail());
attributeHandling.setEntityAttribute(true);
attributeHandling.setStrategyType(AttributeMappingStrategyType.SET);
attributeHandling.setTransformToResourceScript("return \"" + EMAIL_TWO + "\";");
systemAttributeMappingService.save(attributeHandling);
// Do provisioning
provisioningService.doProvisioning(identity);
// Email strategy is SET ... email in account must have new value
resourceAccoutn = entityManager.find(TestResource.class, accountService.get(accountIdentityOne.getAccount()).getUid());
Assert.assertEquals(EMAIL_TWO, resourceAccoutn.getEmail());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterByEntityTypeFound.
@Test
public void testFilterByEntityTypeFound() {
SysSystemDto system = this.getHelper().createTestResourceSystem(true, getHelper().createName());
// Generate second system for add mapped attributes
this.getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filterMapping = new SysSystemMappingFilter();
filterMapping.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filterMapping, null).getContent();
assertEquals(1, mappings.size());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(system.getId());
filter.setEntityType(SystemEntityType.IDENTITY);
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
// Six is default for standard test resource
assertEquals(6, attributeMappings.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterByUid.
@Test
public void testFilterByUid() {
SysSystemDto system = this.getHelper().createTestResourceSystem(true, getHelper().createName());
// Generate second system for add mapped attributes
this.getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filterMapping = new SysSystemMappingFilter();
filterMapping.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filterMapping, null).getContent();
assertEquals(1, mappings.size());
SysSystemMappingDto mappingDto = mappings.get(0);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(mappingDto.getId());
filter.setIsUid(Boolean.TRUE);
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
assertEquals(1, attributeMappings.size());
SysSystemAttributeMappingDto attributeMappingDto = attributeMappings.get(0);
assertEquals(TestHelper.ATTRIBUTE_MAPPING_NAME, attributeMappingDto.getName());
}
Aggregations