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.setCode("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 DefaultSysProvisioningArchiveServiceIntegrationTest method differenceObjectMultipleTest.
@Test
public void differenceObjectMultipleTest() {
String attrName = getHelper().createName();
IcAttributeImpl icAttributeOne = new IcAttributeImpl(attrName, Lists.newArrayList("TESTExisting", "TESTRemoved"));
IcConnectorObject connObjectOld = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeOne));
IcAttributeImpl icAttributeTwo = new IcAttributeImpl(attrName, Lists.newArrayList("TESTExisting", "TESTNew"));
IcConnectorObject connObjectNew = new IcConnectorObjectImpl(getHelper().createName(), new IcObjectClassImpl("__mock__"), ImmutableList.of(icAttributeTwo));
List<SysAttributeDifferenceDto> diffs = service.evaluateProvisioningDifferences(connObjectOld, connObjectNew);
List<SysAttributeDifferenceValueDto> values = diffs.get(0).getValues();
Assert.assertEquals(1, diffs.size());
Assert.assertTrue(diffs.get(0).isMultivalue());
Assert.assertTrue(diffs.get(0).isChanged());
Assert.assertNotNull(values);
Assert.assertEquals(3, values.size());
SysAttributeDifferenceValueDto value;
value = values.stream().filter(item -> item.getChange() == null).findFirst().orElse(null);
Assert.assertNotNull(value);
Assert.assertEquals("TESTExisting", value.getValue());
Assert.assertEquals("TESTExisting", value.getOldValue());
value = values.stream().filter(item -> item.getChange() == SysValueChangeType.ADDED).findFirst().orElse(null);
Assert.assertNotNull(value);
Assert.assertEquals("TESTNew", value.getValue());
Assert.assertEquals(null, value.getOldValue());
value = values.stream().filter(item -> item.getChange() == SysValueChangeType.REMOVED).findFirst().orElse(null);
Assert.assertNotNull(value);
Assert.assertEquals("TESTRemoved", value.getValue());
Assert.assertEquals("TESTRemoved", value.getOldValue());
}
use of org.junit.Assert.assertEquals in project CzechIdMng by bcvsolutions.
the class IdentityPasswordProvisioningTest method testSendPasswordNotificationCreateCancelled.
@Test
public void testSendPasswordNotificationCreateCancelled() {
// init readOnly system
SysSystemDto system = initSystem();
system.setReadonly(true);
system = systemService.save(system);
IdmRoleDto role = initRole(system);
IdmIdentityDto identity = helper.createIdentity();
// CREATE operation
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
checkIdentityAccount(identity, identityRole, 1);
// => new password is sent for valid identity only
identity.setState(IdentityState.VALID);
identity.setFirstName(getHelper().createName());
// UPDATE operation
identityService.save(identity);
//
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
TestResource entityOnSystem = helper.findResource(account.getUid());
Assert.assertNull(entityOnSystem);
//
// Check for send password notification
IdmNotificationFilter notificationFilter = new IdmNotificationFilter();
notificationFilter.setTopic(AccModuleDescriptor.TOPIC_NEW_PASSWORD);
notificationFilter.setRecipient(identity.getUsername());
List<IdmNotificationLogDto> notifications = //
notificationLogService.find(notificationFilter, null).getContent().stream().filter(//
notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
Assert.assertTrue(notifications.isEmpty());
//
// cancel the first provisioning operation
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setEntityType(SystemEntityType.IDENTITY);
filter.setEntityIdentifier(identity.getId());
List<SysProvisioningOperationDto> operations = provisioningOperationService.find(filter, null).getContent();
Assert.assertEquals(2, operations.size());
// ~ readonly
Assert.assertTrue(operations.stream().allMatch(o -> o.getResultState() == OperationState.NOT_EXECUTED));
SysProvisioningOperationDto createOperation = operations.stream().filter(o -> o.getOperationType() == ProvisioningEventType.CREATE).findFirst().get();
SysProvisioningOperationDto updateOperation = operations.stream().filter(o -> o.getOperationType() == ProvisioningEventType.UPDATE).findFirst().get();
//
// active system
system.setReadonly(false);
system = systemService.save(system);
//
// cancel the first operation
provisioningExecutor.cancel(createOperation);
operations = provisioningOperationService.find(filter, null).getContent();
Assert.assertEquals(1, operations.size());
notifications = //
notificationLogService.find(notificationFilter, null).getContent().stream().filter(//
notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
Assert.assertTrue(notifications.isEmpty());
//
provisioningExecutor.execute(updateOperation);
operations = provisioningOperationService.find(filter, null).getContent();
Assert.assertTrue(operations.isEmpty());
notifications = //
notificationLogService.find(notificationFilter, null).getContent().stream().filter(//
notification -> IdmEmailLog.NOTIFICATION_TYPE.equals(notification.getType())).collect(Collectors.toList());
Assert.assertEquals(1, notifications.size());
}
use of org.junit.Assert.assertEquals in project flow by vaadin.
the class BinderConverterValidatorTest method save_fieldsAndBeanLevelValidation.
@Test
public void save_fieldsAndBeanLevelValidation() throws ValidationException {
binder.forField(nameField).withValidator(new NotEmptyValidator<>("a")).bind(Person::getFirstName, Person::setFirstName);
binder.withValidator(Validator.from(person -> person.getLastName() != null, "b"));
Person person = new Person();
person.setLastName("bar");
nameField.setValue("foo");
binder.writeBean(person);
Assert.assertEquals(nameField.getValue(), person.getFirstName());
Assert.assertEquals("bar", person.getLastName());
}
Aggregations