use of org.apache.syncope.core.persistence.api.entity.user.UPlainAttrUniqueValue in project syncope by apache.
the class PlainAttrTest method validateAndSave.
@Test
public void validateAndSave() {
User user = userDAO.find("1417acbe-cbf6-4277-9372-e75e04f97000");
PlainSchema emailSchema = plainSchemaDAO.find("email");
assertNotNull(emailSchema);
PlainSchema fullnameSchema = plainSchemaDAO.find("fullname");
assertNotNull(fullnameSchema);
UPlainAttr attr = entityFactory.newEntity(UPlainAttr.class);
attr.setOwner(user);
attr.setSchema(emailSchema);
UPlainAttrUniqueValue uauv = entityFactory.newEntity(UPlainAttrUniqueValue.class);
uauv.setAttr(attr);
uauv.setSchema(fullnameSchema);
uauv.setStringValue("a value");
attr.setUniqueValue(uauv);
user.add(attr);
InvalidEntityException iee = null;
try {
userDAO.save(user);
fail("This should not happen");
} catch (InvalidEntityException e) {
iee = e;
}
assertNotNull(iee);
// for attribute
assertTrue(iee.hasViolation(EntityViolationType.InvalidValueList));
// for uauv
assertTrue(iee.hasViolation(EntityViolationType.InvalidPlainAttr));
}
Aggregations