use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter 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.filter.SysSystemAttributeMappingFilter 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.filter.SysSystemAttributeMappingFilter 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.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceTest method textFilterTest.
@Test
public void textFilterTest() {
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);
SysSystemAttributeMappingDto attributeMapping1 = createAttributeMappingSystem(systemMapping, strategyType, schemaAttribute.getId());
attributeMapping1.setName("OriginalName01");
attributeMappingService.save(attributeMapping1);
SysSystemAttributeMappingDto attributeMapping2 = createAttributeMappingSystem(systemMapping, AttributeMappingStrategyType.CREATE, schemaAttribute.getId());
attributeMapping2.setName("OriginalName21");
attributeMappingService.save(attributeMapping2);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setText("OriginalName0");
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.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class SystemMappingDeleteProcessor method process.
@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
SysSystemMappingDto systemMapping = event.getContent();
//
if (configService.countBySystemMapping(systemMapping) > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("mapping", systemMapping.getName()));
}
//
// remove all handled attributes
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(systemMapping.getId());
systemAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
systemAttributeMappingService.delete(systemAttributeMapping);
});
//
// delete mapped roles
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setSystemMappingId(systemMapping.getId());
roleSystemService.find(roleSystemFilter, null).forEach(roleSystem -> {
roleSystemService.delete(roleSystem);
});
//
systemMappingService.deleteInternal(systemMapping);
//
return new DefaultEventResult<>(event, this);
}
Aggregations