use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingServiceIntegrationTest method testAutomaticGenerateOfMappedAttributesRoleCatalogue.
@Test
public void testAutomaticGenerateOfMappedAttributesRoleCatalogue() {
SysSystemDto system = testHelper.createSystem(testHelper.createName());
SysSchemaObjectClassDto schema = this.createObjectClass(system);
createSchemaAttribute("__NAME__", schema);
createSchemaAttribute("parent", schema);
createSchemaAttribute("name", schema);
// redundant to __NAME__
createSchemaAttribute("code", schema);
createSchemaAttribute("description", schema);
createSchemaAttribute("not_exist", schema);
SysSystemMappingDto mappingDto = new SysSystemMappingDto();
mappingDto.setName(testHelper.createName());
mappingDto.setEntityType(SystemEntityType.ROLE_CATALOGUE);
mappingDto.setObjectClass(schema.getId());
mappingDto.setOperationType(SystemOperationType.PROVISIONING);
mappingDto = mappingService.publish(new SystemMappingEvent(SystemMappingEvent.SystemMappingEventType.CREATE, mappingDto, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, true))).getContent();
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mappingDto.getId());
List<SysSystemAttributeMappingDto> mappingAttributes = mappingAttributeService.find(attributeMappingFilter, null).getContent();
// Automatic attribute generating is enabled.
assertEquals(4, mappingAttributes.size());
SysSystemAttributeMappingDto primaryAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("__NAME__")).findFirst().orElse(null);
assertNotNull(primaryAttribute);
assertTrue(primaryAttribute.isUid());
assertEquals(IdmRoleCatalogue_.code.getName(), primaryAttribute.getIdmPropertyName());
SysSystemAttributeMappingDto nameAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("name")).findFirst().orElse(null);
assertNotNull(nameAttribute);
assertFalse(nameAttribute.isUid());
assertEquals(IdmRoleCatalogue_.name.getName(), nameAttribute.getIdmPropertyName());
SysSystemAttributeMappingDto parentAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("parent")).findFirst().orElse(null);
assertNotNull(parentAttribute);
assertFalse(parentAttribute.isUid());
assertEquals(IdmRoleCatalogue_.parent.getName(), parentAttribute.getIdmPropertyName());
SysSystemAttributeMappingDto descriptionAttribute = mappingAttributes.stream().filter(attribute -> attribute.getName().equals("description")).findFirst().orElse(null);
assertNotNull(descriptionAttribute);
assertFalse(descriptionAttribute.isUid());
assertEquals(IdmRoleCatalogue_.description.getName(), descriptionAttribute.getIdmPropertyName());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingServiceIntegrationTest method createProvisioningMappingSystem.
private SysSystemMappingDto createProvisioningMappingSystem(SystemEntityType type, SysSchemaObjectClassDto objectClass) {
// system mapping
SysSystemMappingDto mapping = new SysSystemMappingDto();
mapping.setName("Name" + UUID.randomUUID());
mapping.setEntityType(type);
mapping.setObjectClass(objectClass.getId());
mapping.setOperationType(SystemOperationType.PROVISIONING);
return mappingService.save(mapping);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingServiceIntegrationTest method treeTypeIdFilterTest.
@Test
public void treeTypeIdFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
IdmTreeTypeDto treeType = new IdmTreeTypeDto();
treeType.setName("SomeTreeTypeName");
treeType.setCode("CodeCodeCodeCode");
treeType = treeTypeService.save(treeType);
IdmTreeTypeDto treeType2 = new IdmTreeTypeDto();
treeType2.setName("SomeTreeTypeName2");
treeType2.setCode("CodeCodeCodeCode2");
treeType2 = treeTypeService.save(treeType2);
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
mappingSystem1.setTreeType(treeType.getId());
mappingSystem1 = mappingService.save(mappingSystem1);
SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(entityType, objectClass);
mappingSystem2.setTreeType(treeType2.getId());
mappingSystem2 = mappingService.save(mappingSystem2);
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setTreeTypeId(mappingSystem1.getTreeType());
Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
assertEquals(1, result.getTotalElements());
assertTrue(result.getContent().contains(mappingSystem1));
assertFalse(result.getContent().contains(mappingSystem2));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemMappingServiceIntegrationTest method textFilterTest.
@Test
public void textFilterTest() {
IdmBasePermission permission = IdmBasePermission.ADMIN;
SystemEntityType entityType = SystemEntityType.IDENTITY;
SysSystemDto system = createSystem();
SysSchemaObjectClassDto objectClass = createObjectClass(system);
SysSystemMappingDto mappingSystem1 = testHelper.createMappingSystem(entityType, objectClass);
mappingSystem1.setName("SomeName01");
mappingService.save(mappingSystem1);
SysSystemMappingDto mappingSystem2 = testHelper.createMappingSystem(entityType, objectClass);
mappingSystem2.setName("SomeName02");
mappingService.save(mappingSystem2);
SysSystemMappingDto mappingSystem3 = testHelper.createMappingSystem(entityType, objectClass);
mappingSystem3.setName("SomeName22");
mappingService.save(mappingSystem3);
SysSystemMappingFilter filter = new SysSystemMappingFilter();
filter.setText("SomeName0");
Page<SysSystemMappingDto> result = mappingService.find(filter, null, permission);
assertEquals(2, result.getTotalElements());
assertTrue(result.getContent().contains(mappingSystem1));
assertTrue(result.getContent().contains(mappingSystem2));
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterBySchemaAttributeId.
@Test
public void testFilterBySchemaAttributeId() {
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);
SysSchemaAttributeFilter schemaFilter = new SysSchemaAttributeFilter();
schemaFilter.setSystemId(system.getId());
schemaFilter.setName(TestHelper.ATTRIBUTE_MAPPING_EMAIL);
List<SysSchemaAttributeDto> schemaAttributes = schemaAttributeService.find(schemaFilter, null).getContent();
assertEquals(1, schemaAttributes.size());
SysSchemaAttributeDto schemaAttributeDto = schemaAttributes.get(0);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSchemaAttributeId(schemaAttributeDto.getId());
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
assertEquals(1, attributeMappings.size());
SysSystemAttributeMappingDto attributeMappingDto = attributeMappings.get(0);
assertEquals(TestHelper.ATTRIBUTE_MAPPING_EMAIL, attributeMappingDto.getName());
assertEquals(mappingDto.getId(), attributeMappingDto.getSystemMapping());
assertEquals(schemaAttributeDto.getId(), attributeMappingDto.getSchemaAttribute());
}
Aggregations