Search in sources :

Example 26 with SyncopeClientException

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

the class PlainSchemaITCase method update.

@Test
public void update() {
    PlainSchemaTO schemaTO = schemaService.read(SchemaType.PLAIN, "icon");
    assertNotNull(schemaTO);
    schemaService.update(SchemaType.PLAIN, schemaTO);
    PlainSchemaTO updatedTO = schemaService.read(SchemaType.PLAIN, "icon");
    assertEquals(schemaTO, updatedTO);
    updatedTO.setType(AttrSchemaType.Date);
    try {
        schemaService.update(SchemaType.PLAIN, updatedTO);
        fail("This should not be reacheable");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.InvalidPlainSchema, 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 27 with SyncopeClientException

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

the class PlainSchemaITCase method issueSYNCOPE323.

@Test
public void issueSYNCOPE323() {
    PlainSchemaTO actual = schemaService.read(SchemaType.PLAIN, "icon");
    assertNotNull(actual);
    try {
        createSchema(SchemaType.PLAIN, actual);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(Response.Status.CONFLICT, e.getType().getResponseStatus());
        assertEquals(ClientExceptionType.EntityExists, e.getType());
    }
    actual.setKey(null);
    try {
        createSchema(SchemaType.PLAIN, actual);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(Response.Status.BAD_REQUEST, e.getType().getResponseStatus());
        assertEquals(ClientExceptionType.RequiredValuesMissing, 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 28 with SyncopeClientException

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

the class PolicyITCase method buildPullPolicyTO.

private PullPolicyTO buildPullPolicyTO() throws IOException {
    ImplementationTO corrRule = null;
    try {
        corrRule = implementationService.read(ImplementationType.PULL_CORRELATION_RULE, "TestPullRule");
    } catch (SyncopeClientException e) {
        if (e.getType().getResponseStatus() == Response.Status.NOT_FOUND) {
            corrRule = new ImplementationTO();
            corrRule.setKey("TestPullRule");
            corrRule.setEngine(ImplementationEngine.GROOVY);
            corrRule.setType(ImplementationType.PULL_CORRELATION_RULE);
            corrRule.setBody(IOUtils.toString(getClass().getResourceAsStream("/TestPullRule.groovy"), StandardCharsets.UTF_8));
            Response response = implementationService.create(corrRule);
            corrRule = implementationService.read(corrRule.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
            assertNotNull(corrRule);
        }
    }
    assertNotNull(corrRule);
    PullPolicyTO policy = new PullPolicyTO();
    policy.getCorrelationRules().put(AnyTypeKind.USER.name(), corrRule.getKey());
    policy.setDescription("Pull policy");
    return policy;
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) PullPolicyTO(org.apache.syncope.common.lib.policy.PullPolicyTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException)

Example 29 with SyncopeClientException

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

the class PolicyITCase method delete.

@Test
public void delete() throws IOException {
    PullPolicyTO policy = buildPullPolicyTO();
    PullPolicyTO policyTO = createPolicy(PolicyType.PULL, policy);
    assertNotNull(policyTO);
    policyService.delete(PolicyType.PULL, policyTO.getKey());
    try {
        policyService.read(PolicyType.PULL, policyTO.getKey());
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertNotNull(e);
    }
}
Also used : PullPolicyTO(org.apache.syncope.common.lib.policy.PullPolicyTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 30 with SyncopeClientException

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

the class PullTaskITCase method testPullActionsSetup.

@BeforeAll
public static void testPullActionsSetup() {
    ImplementationTO pullActions = null;
    try {
        pullActions = implementationService.read(ImplementationType.PULL_ACTIONS, TestPullActions.class.getSimpleName());
    } catch (SyncopeClientException e) {
        if (e.getType().getResponseStatus() == Response.Status.NOT_FOUND) {
            pullActions = new ImplementationTO();
            pullActions.setKey(TestPullActions.class.getSimpleName());
            pullActions.setEngine(ImplementationEngine.JAVA);
            pullActions.setType(ImplementationType.PULL_ACTIONS);
            pullActions.setBody(TestPullActions.class.getName());
            Response response = implementationService.create(pullActions);
            pullActions = implementationService.read(pullActions.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
            assertNotNull(pullActions);
        }
    }
    assertNotNull(pullActions);
    PullTaskTO pullTask = taskService.read(TaskType.PULL, PULL_TASK_KEY, true);
    pullTask.getActions().add(pullActions.getKey());
    taskService.update(TaskType.PULL, pullTask);
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) PullTaskTO(org.apache.syncope.common.lib.to.PullTaskTO) BeforeAll(org.junit.jupiter.api.BeforeAll)

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