use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method isUidFitlerTest.
@Test
public void isUidFitlerTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto systemMapping1 = testHelper.createMappingSystem(entityType, objectClass);
SysSystemMappingDto systemMapping2 = testHelper.createMappingSystem(entityType, objectClass);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping1, AttributeMappingStrategyType.CREATE, schemaAttribute.getId());
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping2, strategyType, schemaAttribute.getId());
attributeMapping2.setUid(true);
attributeMappingService.save(attributeMapping2);
createAttributeMappingSystem(systemMapping1, AttributeMappingStrategyType.SET, schemaAttribute.getId());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setIsUid(true);
filter.setSystemId(system.getId());
Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(attributeMapping2));
assertFalse(result.getContent().contains(attributeMapping1));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method schemaAttributeIdFilterTest.
@Test
public void schemaAttributeIdFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto systemMapping = testHelper.createMappingSystem(entityType, objectClass);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(objectClass);
SysSchemaAttributeDto schemaAttribute2 = createSchemaAttribute(objectClass);
SysSystemAttributeMappingDto attributeMapping = createAttributeMappingSystem(systemMapping, strategyType, schemaAttribute.getId());
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping, strategyType, schemaAttribute2.getId());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSchemaAttributeId(schemaAttribute.getId());
Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(attributeMapping));
assertFalse(result.getContent().contains(attributeMapping2));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method transformationToScriptFailure.
@Test
public void transformationToScriptFailure() {
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objClass = createObjectClass(system);
SysSchemaAttributeDto schemaAttr = createSchemaAttribute(objClass);
SysSystemMappingDto systemMapping = testHelper.createMappingSystem(SystemEntityType.IDENTITY, objClass);
SysSystemAttributeMappingDto attrMapping = createAttributeMappingSystem(systemMapping, AttributeMappingStrategyType.CREATE, schemaAttr.getId());
// script consists of just one missing symbol,
// which is supposed to be part of error message
String script = "xxxxx";
attrMapping.setTransformToResourceScript(script);
systemMapping = mappingService.save(systemMapping);
try {
attributeMappingService.transformValueToResource(null, "testValue", attrMapping, new IdmIdentityDto());
fail();
} catch (ResultCodeException ex) {
ErrorModel errModel = ex.getError().getError();
String message = (String) errModel.getParameters().get(SysSystemAttributeMappingService.MAPPING_SCRIPT_FAIL_MESSAGE_KEY);
String idmPath = (String) errModel.getParameters().get(SysSystemAttributeMappingService.MAPPING_SCRIPT_FAIL_IDM_PATH_KEY);
assertEquals(errModel.getStatusEnum(), AccResultCode.GROOVY_SCRIPT_ATTR_TRANSFORMATION_FAILED.getCode());
assertTrue(message.contains(script));
assertTrue(idmPath.contains(system.getCode()));
assertTrue(idmPath.contains(systemMapping.getName()));
assertTrue(idmPath.contains(attrMapping.getName()));
} catch (Exception e) {
fail();
}
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method systemIdFilterTest.
@Test
public void systemIdFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
AttributeMappingStrategyType strategyType = AttributeMappingStrategyType.MERGE;
SysSystemDto system1 = createSystem();
SysSystemDto system2 = createSystem();
SysSchemaObjectClassDto objectClass1 = createObjectClass(system1);
SysSchemaObjectClassDto objectClass2 = createObjectClass(system2);
SysSystemMappingDto systemMapping1 = testHelper.createMappingSystem(entityType, objectClass1);
SysSystemMappingDto systemMapping2 = testHelper.createMappingSystem(entityType, objectClass2);
SysSchemaAttributeDto schemaAttribute1 = createSchemaAttribute(objectClass1);
SysSchemaAttributeDto schemaAttribute2 = createSchemaAttribute(objectClass2);
SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping1, strategyType, schemaAttribute1.getId());
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping2, strategyType, schemaAttribute2.getId());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(system1.getId());
Page<SysSystemAttributeMappingDto> result = attributeMappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(attributeMapping1));
assertFalse(result.getContent().contains(attributeMapping2));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method createExtendedAttributeTest.
@Test
public void createExtendedAttributeTest() {
SysSystemDto system = testHelper.createSystem(TestResource.TABLE_NAME);
SysSystemMappingDto mapping = testHelper.createMapping(system);
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
SysSchemaAttributeDto descriptionSchemaAttribute = attributeService.find(schemaAttributeFilter, null).getContent().stream().filter(//
schemaAttribute -> TestHelper.ATTRIBUTE_MAPPING_DESCRIPTION.equalsIgnoreCase(schemaAttribute.getName())).findFirst().get();
// create EAV attribute
String propertyName = testHelper.createName();
SysSystemAttributeMappingDto attributeMapping = new SysSystemAttributeMappingDto();
attributeMapping.setExtendedAttribute(true);
attributeMapping.setName(descriptionSchemaAttribute.getName());
attributeMapping.setIdmPropertyName(propertyName);
attributeMapping.setSchemaAttribute(descriptionSchemaAttribute.getId());
attributeMapping.setSystemMapping(mapping.getId());
attributeMapping = attributeMappingService.save(attributeMapping);
IdmFormDefinitionDto definition = formService.getDefinition(IdmIdentityDto.class);
IdmFormAttributeDto formAttributeDto = //
definition.getFormAttributes().stream().filter(//
formAttribute -> propertyName.equals(formAttribute.getCode())).findFirst().get();
assertEquals(propertyName, formAttributeDto.getCode());
assertEquals(testHelper.getSchemaColumnName(TestHelper.ATTRIBUTE_MAPPING_DESCRIPTION), formAttributeDto.getName());
assertEquals(false, formAttributeDto.isMultiple());
assertEquals(false, formAttributeDto.isConfidential());
assertEquals(false, formAttributeDto.isRequired());
assertEquals(false, formAttributeDto.isReadonly());
assertEquals(false, formAttributeDto.isUnique());
assertEquals(PersistentType.SHORTTEXT, formAttributeDto.getPersistentType());
}
Aggregations