Search in sources :

Example 51 with PlainSchema

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));
    }
}
Also used : PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) InvalidEntityException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 52 with PlainSchema

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());
}
Also used : GPlainAttr(org.apache.syncope.core.persistence.api.entity.group.GPlainAttr) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 53 with PlainSchema

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));
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) UPlainAttrUniqueValue(org.apache.syncope.core.persistence.api.entity.user.UPlainAttrUniqueValue) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) UPlainAttr(org.apache.syncope.core.persistence.api.entity.user.UPlainAttr) InvalidEntityException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 54 with PlainSchema

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);
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) ValidationException(javax.validation.ValidationException) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) UPlainAttr(org.apache.syncope.core.persistence.api.entity.user.UPlainAttr) InvalidEntityException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException) ValidationException(javax.validation.ValidationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InvalidEntityException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 55 with PlainSchema

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);
}
Also used : PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) UPlainAttr(org.apache.syncope.core.persistence.api.entity.user.UPlainAttr) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

PlainSchema (org.apache.syncope.core.persistence.api.entity.PlainSchema)55 Test (org.junit.jupiter.api.Test)22 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)21 AnyUtils (org.apache.syncope.core.persistence.api.entity.AnyUtils)15 VirSchema (org.apache.syncope.core.persistence.api.entity.VirSchema)14 User (org.apache.syncope.core.persistence.api.entity.user.User)13 DerSchema (org.apache.syncope.core.persistence.api.entity.DerSchema)12 UPlainAttr (org.apache.syncope.core.persistence.api.entity.user.UPlainAttr)11 ArrayList (java.util.ArrayList)10 PlainAttrValue (org.apache.syncope.core.persistence.api.entity.PlainAttrValue)10 Transactional (org.springframework.transaction.annotation.Transactional)10 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)9 AnyTypeClass (org.apache.syncope.core.persistence.api.entity.AnyTypeClass)9 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)9 Collections (java.util.Collections)8 HashSet (java.util.HashSet)8 List (java.util.List)8 Optional (java.util.Optional)8 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)8 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)8