SyncopeUser user = userDAO.find(1L);
USchema emailSchema = userSchemaDAO.find("email", USchema.class);
assertNotNull(emailSchema);
UAttr attribute = new UAttr();
attribute.setSchema(emailSchema);
attribute.setOwner(user);
Exception thrown = null;
try {
attribute.addValue("john.doe@gmail.com", AttributableUtil.getInstance(AttributableType.USER));
attribute.addValue("mario.rossi@gmail.com", AttributableUtil.getInstance(AttributableType.USER));
} catch (ValidationException e) {
LOG.error("Unexpected exception", e);
thrown = e;
}
assertNull("no validation exception expected here ", thrown);
try {
attribute.addValue("http://www.apache.org", AttributableUtil.getInstance(AttributableType.USER));
} catch (ValidationException e) {
thrown = e;
}
assertNotNull("validation exception expected here ", thrown);
InvalidEntityException iee = null;
try {
attribute = attrDAO.save(attribute);
} catch (InvalidEntityException e) {
iee = e;
}
assertNull(iee);
UAttr actual = attrDAO.find(attribute.getId(), UAttr.class);
assertNotNull("expected save to work", actual);
assertEquals(attribute, actual);
}