use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.
the class ConfTest method issueSYNCOPE418.
@Test
public void issueSYNCOPE418() {
try {
PlainSchema failing = entityFactory.newEntity(PlainSchema.class);
failing.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
failing.setType(AttrSchemaType.String);
plainSchemaDAO.save(failing);
fail("This should not happen");
} catch (InvalidEntityException e) {
assertTrue(e.hasViolation(EntityViolationType.InvalidKey));
}
}
use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.
the class PlainSchemaTest method findAttrs.
@Test
public void findAttrs() {
PlainSchema schema = plainSchemaDAO.find("icon");
assertNotNull(schema);
List<GPlainAttr> attrs = plainSchemaDAO.findAttrs(schema, GPlainAttr.class);
assertNotNull(attrs);
assertFalse(attrs.isEmpty());
}
use of org.apache.syncope.core.persistence.api.entity.PlainSchema 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));
}
use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.
the class PlainAttrTest method saveWithEnum.
@Test
public void saveWithEnum() throws ClassNotFoundException {
User user = userDAO.find("1417acbe-cbf6-4277-9372-e75e04f97000");
assertNotNull(user);
PlainSchema gender = plainSchemaDAO.find("gender");
assertNotNull(gender);
assertNotNull(gender.getType());
assertNotNull(gender.getEnumerationValues());
UPlainAttr attribute = entityFactory.newEntity(UPlainAttr.class);
attribute.setOwner(user);
attribute.setSchema(gender);
user.add(attribute);
Exception thrown = null;
try {
attribute.add("A", anyUtilsFactory.getInstance(AnyTypeKind.USER));
} catch (ValidationException e) {
thrown = e;
}
assertNotNull(thrown);
attribute.add("M", anyUtilsFactory.getInstance(AnyTypeKind.USER));
InvalidEntityException iee = null;
try {
userDAO.save(user);
} catch (InvalidEntityException e) {
iee = e;
}
assertNull(iee);
}
use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.
the class PlainAttrTest method delete.
@Test
public void delete() {
UPlainAttr attribute = plainAttrDAO.find("9d0d9e40-1b18-488e-9482-37dab82163c9", UPlainAttr.class);
String attrSchemaName = attribute.getSchema().getKey();
plainAttrDAO.delete(attribute.getKey(), UPlainAttr.class);
PlainSchema schema = plainSchemaDAO.find(attrSchemaName);
assertNotNull(schema);
}
Aggregations