Search in sources :

Example 1 with PlainSchemaTO

use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.

the class PlainSchemaITCase method issue258.

@Test
public void issue258() {
    PlainSchemaTO schemaTO = new PlainSchemaTO();
    schemaTO.setKey("schema_issue258");
    schemaTO.setType(AttrSchemaType.Double);
    schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    assertNotNull(schemaTO);
    AnyTypeClassTO typeClass = new AnyTypeClassTO();
    typeClass.setKey("issue258");
    typeClass.getPlainSchemas().add(schemaTO.getKey());
    anyTypeClassService.create(typeClass);
    UserTO userTO = UserITCase.getUniqueSampleTO("issue258@syncope.apache.org");
    userTO.getAuxClasses().add(typeClass.getKey());
    userTO.getPlainAttrs().add(attrTO(schemaTO.getKey(), "1.2"));
    userTO = createUser(userTO).getEntity();
    assertNotNull(userTO);
    schemaTO.setType(AttrSchemaType.Long);
    try {
        schemaService.update(SchemaType.PLAIN, schemaTO);
        fail("This should not be reacheable");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) UserTO(org.apache.syncope.common.lib.to.UserTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Example 2 with PlainSchemaTO

use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.

the class PlainSchemaITCase method createREnumWithoutEnumeration.

@Test
public void createREnumWithoutEnumeration() {
    PlainSchemaTO schemaTO = new PlainSchemaTO();
    schemaTO.setKey("enumcheck");
    schemaTO.setType(AttrSchemaType.Enum);
    try {
        createSchema(SchemaType.PLAIN, schemaTO);
        fail("This should not be reacheable");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
        assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidSchemaEnum.name()));
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 3 with PlainSchemaTO

use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.

the class PlainSchemaITCase method buildPlainSchemaTO.

private PlainSchemaTO buildPlainSchemaTO(final String name, final AttrSchemaType type) {
    PlainSchemaTO schemaTO = new PlainSchemaTO();
    schemaTO.setKey(name + getUUIDString());
    schemaTO.setType(type);
    return schemaTO;
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO)

Example 4 with PlainSchemaTO

use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.

the class PlainSchemaITCase method create.

@Test
public void create() {
    PlainSchemaTO schemaTO = buildPlainSchemaTO("testAttribute", AttrSchemaType.String);
    schemaTO.setMandatoryCondition("false");
    PlainSchemaTO newPlainSchemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    assertEquals(schemaTO, newPlainSchemaTO);
    try {
        createSchema(SchemaType.PLAIN, schemaTO);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.EntityExists, e.getType());
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 5 with PlainSchemaTO

use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.

the class PlainSchemaITCase method issue260.

@Test
public void issue260() {
    PlainSchemaTO schemaTO = buildPlainSchemaTO("schema_issue260", AttrSchemaType.Double);
    schemaTO.setUniqueConstraint(true);
    schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
    assertNotNull(schemaTO);
    AnyTypeClassTO typeClass = new AnyTypeClassTO();
    typeClass.setKey("issue260");
    typeClass.getPlainSchemas().add(schemaTO.getKey());
    anyTypeClassService.create(typeClass);
    UserTO userTO = UserITCase.getUniqueSampleTO("issue260@syncope.apache.org");
    userTO.getAuxClasses().add(typeClass.getKey());
    userTO.getPlainAttrs().add(attrTO(schemaTO.getKey(), "1.2"));
    userTO = createUser(userTO).getEntity();
    assertNotNull(userTO);
    schemaTO.setUniqueConstraint(false);
    try {
        schemaService.update(SchemaType.PLAIN, schemaTO);
        fail("This should not be reacheable");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) UserTO(org.apache.syncope.common.lib.to.UserTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) Test(org.junit.jupiter.api.Test)

Aggregations

PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)39 Test (org.junit.jupiter.api.Test)26 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)19 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)11 UserTO (org.apache.syncope.common.lib.to.UserTO)9 AttrTO (org.apache.syncope.common.lib.to.AttrTO)6 Response (javax.ws.rs.core.Response)5 IOException (java.io.IOException)4 Set (java.util.Set)4 StandardCharsets (java.nio.charset.StandardCharsets)3 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)3 DerSchemaTO (org.apache.syncope.common.lib.to.DerSchemaTO)3 GroupTO (org.apache.syncope.common.lib.to.GroupTO)3 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)3 SchemaService (org.apache.syncope.common.rest.api.service.SchemaService)3 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 ListIterator (java.util.ListIterator)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2