use of org.junit.Assert.assertEquals in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedDiffPriorityTest.
@Test
@Transactional
public void compileAttributesOverrloadedDiffPriorityTest() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
// roleOne
SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// roleTwo
SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
roleDto = roleService.get(roleSystem2.getRole());
roleDto.setPriority(100);
roleDto = roleService.save(roleDto);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloaded".equals(attribute.getName());
}).findFirst().isPresent());
}
use of org.junit.Assert.assertEquals in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedDisabledTest.
@Test
@Transactional
public void compileAttributesOverrloadedDisabledTest() {
List<AttributeMapping> defaultAttributes = new ArrayList<>();
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
initDataSystem();
SysSchemaAttributeDto attOne = new SysSchemaAttributeDto();
attOne.setName("attOne");
attOne.setObjectClass(objectClasses.get(0).getId());
attOne.setClassType(String.class.getName());
attOne = schemaAttributeService.save(attOne);
SysSchemaAttributeDto attTwo = new SysSchemaAttributeDto();
attTwo.setName("attTwo");
attTwo.setObjectClass(objectClasses.get(0).getId());
attTwo.setClassType(String.class.getName());
attTwo = schemaAttributeService.save(attTwo);
SysSystemAttributeMappingDto defOne = new SysSystemAttributeMappingDto();
defOne.setEntityAttribute(true);
defOne.setIdmPropertyName("one");
defOne.setName("defOne");
defOne.setDisabledAttribute(true);
defOne.setSchemaAttribute(attOne.getId());
defOne.setSystemMapping(systemMapping.getId());
defOne = systemAttributeMappingService.save(defOne);
defaultAttributes.add(defOne);
SysSystemAttributeMappingDto defTwo = new SysSystemAttributeMappingDto();
defTwo.setEntityAttribute(true);
defTwo.setIdmPropertyName("two");
defTwo.setName("defTwo");
defTwo.setSchemaAttribute(attTwo.getId());
defTwo.setSystemMapping(systemMapping.getId());
defTwo = systemAttributeMappingService.save(defTwo);
defaultAttributes.add(defTwo);
IdmRoleDto roleOne = new IdmRoleDto();
roleOne.setName("roleOne");
roleOne.setPriority(100);
roleOne = roleService.save(roleOne);
SysRoleSystemDto roleSystem = new SysRoleSystemDto();
roleSystem.setRole(roleOne.getId());
roleSystem.setSystem(system.getId());
roleSystem.setSystemMapping(systemMapping.getId());
roleSystem = roleSystemService.save(roleSystem);
SysRoleSystemAttributeDto overloadedOne = new SysRoleSystemAttributeDto();
overloadedOne.setSystemAttributeMapping(defOne.getId());
overloadedOne.setEntityAttribute(true);
overloadedOne.setIdmPropertyName("one");
overloadedOne.setName("defOneOverloaded");
overloadedOne.setDisabledDefaultAttribute(false);
overloadedOne.setRoleSystem(roleSystem.getId());
overloadedOne = roleSystemAttributeService.save(overloadedOne);
overloadingAttributes.add(overloadedOne);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloaded".equals(attribute.getName());
}).findFirst().isPresent());
}
use of org.junit.Assert.assertEquals in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyMergeAuthoDisableTest.
@Test
@Transactional
public void compileAttributesOverrloadedStrategyMergeAuthoDisableTest() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
// roleOne
SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// roleTwo
SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
roleDto = roleService.get(roleSystem2.getRole());
roleDto.setPriority(500);
roleDto = roleService.save(roleDto);
// overloadedRoleOne
SysRoleSystemAttributeDto attribute1 = overloadingAttributes.get(0);
attribute1.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
attribute1 = roleSystemAttributeService.save(attribute1);
overloadingAttributes.set(0, attribute1);
// overloadedRoleTwo
SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
attribute2.setStrategyType(AttributeMappingStrategyType.AUTHORITATIVE_MERGE);
attribute2.setDisabledDefaultAttribute(true);
attribute2 = roleSystemAttributeService.save(attribute2);
overloadingAttributes.set(1, attribute2);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloaded".equals(attribute.getName());
}).findFirst().isPresent());
}
use of org.junit.Assert.assertEquals in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method compileAttributesOverrloadedStrategyCreateTest.
@Test
@Transactional
public void compileAttributesOverrloadedStrategyCreateTest() {
List<SysRoleSystemAttributeDto> overloadingAttributes = new ArrayList<>();
List<AttributeMapping> defaultAttributes = new ArrayList<>();
initDataSystem();
initOverloadedAttributes(overloadingAttributes, defaultAttributes);
// roleOne
SysRoleSystemDto roleSystem1 = roleSystemService.get(overloadingAttributes.get(0).getRoleSystem());
IdmRoleDto roleDto = roleService.get(roleSystem1.getRole());
roleDto.setPriority(200);
roleDto = roleService.save(roleDto);
// roleTwo
SysRoleSystemDto roleSystem2 = roleSystemService.get(overloadingAttributes.get(1).getRoleSystem());
roleDto = roleService.get(roleSystem2.getRole());
roleDto.setPriority(500);
roleDto = roleService.save(roleDto);
// overloadedRoleOne
SysRoleSystemAttributeDto attribute1 = overloadingAttributes.get(0);
attribute1.setStrategyType(AttributeMappingStrategyType.CREATE);
attribute1 = roleSystemAttributeService.save(attribute1);
overloadingAttributes.set(0, attribute1);
// overloadedRoleTwo
SysRoleSystemAttributeDto attribute2 = overloadingAttributes.get(1);
attribute2.setStrategyType(AttributeMappingStrategyType.CREATE);
attribute2 = roleSystemAttributeService.save(attribute2);
overloadingAttributes.set(1, attribute2);
List<AttributeMapping> compilledAttributes = provisioningService.compileAttributes(defaultAttributes, overloadingAttributes, SystemEntityType.IDENTITY);
Assert.assertEquals(2, compilledAttributes.size());
Assert.assertTrue(compilledAttributes.stream().filter(attribute -> {
return "defOneOverloadedRoleTwo".equals(attribute.getName());
}).findFirst().isPresent());
}
use of org.junit.Assert.assertEquals in project flow by vaadin.
the class BinderConverterValidatorTest method save_beanValidationErrorsWithConverter.
@Test(expected = ValidationException.class)
public void save_beanValidationErrorsWithConverter() throws ValidationException {
Binder<Person> binder = new Binder<>();
binder.forField(ageField).withConverter(new StringToIntegerConverter("Can't convert")).bind(Person::getAge, Person::setAge);
binder.withValidator(Validator.from(person -> false, "b"));
Person person = new Person();
ageField.setValue("1");
try {
binder.writeBean(person);
} finally {
// Bean should have been updated for item validation but reverted
Assert.assertEquals(0, person.getAge());
}
}
Aggregations