Search in sources :

Example 21 with SyncopeClientException

use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.

the class NotificationITCase method delete.

@Test
public void delete() {
    NotificationTO notification = buildNotificationTO();
    notification.setSelfAsRecipient(true);
    Response response = notificationService.create(notification);
    notification = getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
    notificationService.delete(notification.getKey());
    try {
        notificationService.read(notification.getKey());
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.NotFound, e.getType());
    }
}
Also used : Response(javax.ws.rs.core.Response) NotificationTO(org.apache.syncope.common.lib.to.NotificationTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotificationService(org.apache.syncope.common.rest.api.service.NotificationService) Test(org.junit.jupiter.api.Test)

Example 22 with SyncopeClientException

use of org.apache.syncope.common.lib.SyncopeClientException 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 23 with SyncopeClientException

use of org.apache.syncope.common.lib.SyncopeClientException 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 24 with SyncopeClientException

use of org.apache.syncope.common.lib.SyncopeClientException 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 25 with SyncopeClientException

use of org.apache.syncope.common.lib.SyncopeClientException 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

SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)240 Test (org.junit.jupiter.api.Test)105 UserTO (org.apache.syncope.common.lib.to.UserTO)50 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)42 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)40 Response (javax.ws.rs.core.Response)34 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)20 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)19 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)18 Realm (org.apache.syncope.core.persistence.api.entity.Realm)18 GroupTO (org.apache.syncope.common.lib.to.GroupTO)17 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)16 AttrTO (org.apache.syncope.common.lib.to.AttrTO)15 Map (java.util.Map)14 SyncopeClientCompositeException (org.apache.syncope.common.lib.SyncopeClientCompositeException)14 ArrayList (java.util.ArrayList)12 List (java.util.List)12 ItemTO (org.apache.syncope.common.lib.to.ItemTO)12 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)11