use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class ProvisioningMergeTest method testChangeStrategyAttribteControlledValues.
@Test
public void testChangeStrategyAttribteControlledValues() {
SysSystemDto system = helper.createSystem("test_resource");
SysSystemMappingDto mapping = helper.createMapping(system);
IdmRoleDto roleOne = helper.createRole();
IdmRoleDto roleTwo = helper.createRole();
SysRoleSystemDto roleSystemOne = helper.createRoleSystem(roleOne, system);
SysRoleSystemDto roleSystemTwo = helper.createRoleSystem(roleTwo, system);
SysSchemaObjectClassDto objectClass = schemaService.get(mapping.getObjectClass());
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setObjectClassId(objectClass.getId());
schemaAttributeService.find(schemaAttributeFilter, null);
SysSchemaAttributeDto rightsSchemaAttribute = new SysSchemaAttributeDto();
rightsSchemaAttribute.setObjectClass(objectClass.getId());
rightsSchemaAttribute.setName(RIGHTS_ATTRIBUTE);
rightsSchemaAttribute.setMultivalued(true);
rightsSchemaAttribute.setClassType(String.class.getName());
rightsSchemaAttribute.setReadable(true);
rightsSchemaAttribute.setUpdateable(true);
rightsSchemaAttribute = schemaAttributeService.save(rightsSchemaAttribute);
SysSystemAttributeMappingDto rightsAttribute = new SysSystemAttributeMappingDto();
rightsAttribute.setSchemaAttribute(rightsSchemaAttribute.getId());
rightsAttribute.setSystemMapping(mapping.getId());
rightsAttribute.setName(RIGHTS_ATTRIBUTE);
rightsAttribute.setStrategyType(AttributeMappingStrategyType.MERGE);
rightsAttribute = attributeMappingService.save(rightsAttribute);
SysRoleSystemAttributeDto roleAttributeOne = new SysRoleSystemAttributeDto();
roleAttributeOne.setName(RIGHTS_ATTRIBUTE);
roleAttributeOne.setRoleSystem(roleSystemOne.getId());
roleAttributeOne.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeOne.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeOne.setTransformToResourceScript("return '" + ONE_VALUE + "';");
roleAttributeOne = roleSystemAttributeService.saveInternal(roleAttributeOne);
List<Serializable> controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
SysRoleSystemAttributeDto roleAttributeTwo = new SysRoleSystemAttributeDto();
roleAttributeTwo.setName(RIGHTS_ATTRIBUTE);
roleAttributeTwo.setRoleSystem(roleSystemTwo.getId());
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeTwo.setSystemAttributeMapping(rightsAttribute.getId());
roleAttributeTwo.setTransformToResourceScript("return '" + TWO_VALUE + "';");
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
assertNotNull(controlledAttributeValues);
assertEquals(2, controlledAttributeValues.size());
assertTrue(controlledAttributeValues.contains(ONE_VALUE));
assertTrue(controlledAttributeValues.contains(TWO_VALUE));
SysAttributeControlledValueFilter attributeControlledValueFilter = new SysAttributeControlledValueFilter();
attributeControlledValueFilter.setAttributeMappingId(rightsAttribute.getId());
attributeControlledValueFilter.setHistoricValue(Boolean.TRUE);
List<Serializable> historicControlledValues = //
attributeControlledValueService.find(attributeControlledValueFilter, //
null).getContent().stream().map(//
SysAttributeControlledValueDto::getValue).collect(Collectors.toList());
assertNotNull(historicControlledValues);
assertEquals(0, historicControlledValues.size());
// Set attribute TWO as SET (should be disappears from controlled values
// and appears in the history)
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.SET);
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
assertNotNull(controlledAttributeValues);
assertEquals(1, controlledAttributeValues.size());
assertTrue(controlledAttributeValues.contains(ONE_VALUE));
// Search historic controlled values for that attribute
historicControlledValues = //
attributeControlledValueService.find(attributeControlledValueFilter, //
null).getContent().stream().map(//
SysAttributeControlledValueDto::getValue).collect(Collectors.toList());
assertNotNull(historicControlledValues);
assertEquals(1, historicControlledValues.size());
assertTrue(historicControlledValues.contains(TWO_VALUE));
// Set attribute TWO as MERGE (should be appears in controlled values
// and disappears from the history)
roleAttributeTwo.setStrategyType(AttributeMappingStrategyType.MERGE);
roleAttributeTwo = roleSystemAttributeService.saveInternal(roleAttributeTwo);
controlledAttributeValues = attributeMappingService.getControlledAttributeValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE);
assertNotNull(controlledAttributeValues);
assertEquals(2, controlledAttributeValues.size());
assertTrue(controlledAttributeValues.contains(ONE_VALUE));
assertTrue(controlledAttributeValues.contains(TWO_VALUE));
// Manual recalculation (needed for deleting redundant historic value)
attributeMappingService.recalculateAttributeControlledValues(system.getId(), mapping.getEntityType(), RIGHTS_ATTRIBUTE, rightsAttribute);
// Search historic controlled values for that attribute
historicControlledValues = //
attributeControlledValueService.find(attributeControlledValueFilter, //
null).getContent().stream().map(//
SysAttributeControlledValueDto::getValue).collect(Collectors.toList());
assertNotNull(historicControlledValues);
assertEquals(0, historicControlledValues.size());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class SysSystemMappingServiceValidationTest method testSystemMappingValidationNotMissingIdentifier.
@Test
public void testSystemMappingValidationNotMissingIdentifier() {
SysSystemDto system = createSystem();
SysSchemaObjectClassDto schema = createSchema(system.getId());
SysSystemMappingDto mapping = createMapping(schema.getId(), SystemOperationType.PROVISIONING);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(schema.getId());
createAttributeMapping(mapping.getId(), schemaAttribute.getId(), true, "");
mappingService.validate(mapping.getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class SysSystemMappingServiceValidationTest method createMapping.
/*
* Creates and returns system mapping
*
* @param objectClass
* @return mapping
*/
private SysSystemMappingDto createMapping(UUID objectClass, SystemOperationType type) {
SysSystemMappingDto mapping = new SysSystemMappingDto();
String systemName = "mapping" + System.currentTimeMillis();
mapping.setName(systemName);
mapping.setOperationType(type);
mapping.setObjectClass(objectClass);
mapping.setEntityType(SystemEntityType.IDENTITY);
mapping = mappingService.save(mapping);
return mapping;
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class SysSystemMappingServiceValidationTest method testSystemMappingValidationMissingIdentifier.
@Test(expected = ResultCodeException.class)
public void testSystemMappingValidationMissingIdentifier() {
SysSystemDto system = createSystem();
SysSchemaObjectClassDto schema = createSchema(system.getId());
SysSystemMappingDto mapping = createMapping(schema.getId(), SystemOperationType.PROVISIONING);
SysSchemaAttributeDto schemaAttribute = createSchemaAttribute(schema.getId());
createAttributeMapping(mapping.getId(), schemaAttribute.getId(), false, "");
mappingService.validate(mapping.getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method initData.
private void initData() {
// create test system
system = helper.createSystem("test_tree_resource");
system.setName(SYSTEM_NAME);
system = systemService.save(system);
// key to EAV
IdmFormDefinitionDto formDefinition = systemService.getConnectorFormDefinition(system);
formService.saveValues(system, formDefinition, "keyColumn", ImmutableList.of("ID"));
// generate schema for system
List<SysSchemaObjectClassDto> objectClasses = systemService.generateSchema(system);
IdmTreeTypeDto treeType = new IdmTreeTypeDto();
treeType.setCode(TREE_TYPE_TEST);
treeType.setName(TREE_TYPE_TEST);
treeType = treeTypeService.save(treeType);
// Create synchronization mapping
SysSystemMappingDto syncSystemMapping = new SysSystemMappingDto();
syncSystemMapping.setName("default_" + System.currentTimeMillis());
syncSystemMapping.setEntityType(SystemEntityType.TREE);
syncSystemMapping.setTreeType(treeType.getId());
syncSystemMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
syncSystemMapping.setObjectClass(objectClasses.get(0).getId());
final SysSystemMappingDto syncMapping = systemMappingService.save(syncSystemMapping);
createMapping(system, syncMapping);
deleteAllResourceData();
initTreeData();
syncConfigService.find(null).getContent().forEach(config -> {
syncConfigService.delete(config);
});
}
Aggregations