Search in sources :

Example 21 with PlainSchema

use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.

the class PlainSchemaTest method checkIdUniqueness.

@Test
public void checkIdUniqueness() {
    assertNotNull(derSchemaDAO.find("cn"));
    PlainSchema schema = entityFactory.newEntity(PlainSchema.class);
    schema.setKey("cn");
    schema.setType(AttrSchemaType.String);
    plainSchemaDAO.save(schema);
    try {
        plainSchemaDAO.flush();
        fail("This should not happen");
    } catch (Exception e) {
        assertTrue(e instanceof EntityExistsException);
    }
}
Also used : PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) EntityExistsException(javax.persistence.EntityExistsException) EntityExistsException(javax.persistence.EntityExistsException) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 22 with PlainSchema

use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.

the class PlainSchemaTest method delete.

@Test
public void delete() {
    PlainSchema firstname = plainSchemaDAO.find("firstname");
    plainSchemaDAO.delete(firstname.getKey());
    PlainSchema actual = plainSchemaDAO.find("firstname");
    assertNull(actual);
}
Also used : PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 23 with PlainSchema

use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.

the class PlainSchemaTest method findByName.

@Test
public void findByName() {
    PlainSchema schema = plainSchemaDAO.find("fullname");
    assertNotNull(schema);
}
Also used : PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 24 with PlainSchema

use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.

the class PlainSchemaTest method saveNonValid.

@Test
public void saveNonValid() {
    assertThrows(InvalidEntityException.class, () -> {
        PlainSchema schema = entityFactory.newEntity(PlainSchema.class);
        schema.setKey("secondaryEmail");
        schema.setType(AttrSchemaType.String);
        schema.setValidator(implementationDAO.find("EmailAddressValidator"));
        schema.setMandatoryCondition("false");
        schema.setMultivalue(true);
        schema.setUniqueConstraint(true);
        plainSchemaDAO.save(schema);
    });
}
Also used : PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 25 with PlainSchema

use of org.apache.syncope.core.persistence.api.entity.PlainSchema in project syncope by apache.

the class PlainSchemaTest method save.

@Test
public void save() {
    PlainSchema schema = entityFactory.newEntity(PlainSchema.class);
    schema.setKey("secondaryEmail");
    schema.setType(AttrSchemaType.String);
    schema.setValidator(implementationDAO.find("EmailAddressValidator"));
    schema.setMandatoryCondition("false");
    schema.setMultivalue(true);
    plainSchemaDAO.save(schema);
    PlainSchema actual = plainSchemaDAO.find("secondaryEmail");
    assertNotNull(actual);
    assertEquals(schema, actual);
}
Also used : PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) 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