Search in sources :

Example 41 with ResourceTO

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

the class ResourceITCase method updateWithException.

@Test
public void updateWithException() {
    try {
        ResourceTO resourceTO = new ResourceTO();
        resourceTO.setKey("resourcenotfound");
        resourceService.update(resourceTO);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
    }
}
Also used : ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 42 with ResourceTO

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

the class ResourceITCase method issueSYNCOPE645.

public void issueSYNCOPE645() {
    ResourceTO resource = new ResourceTO();
    resource.setKey("ws-target-resource-basic-save-invalid");
    String connector = resourceService.read("ws-target-resource-1").getConnector();
    resource.setConnector(connector);
    ProvisionTO provision = new ProvisionTO();
    provision.setAnyType(AnyTypeKind.USER.name());
    provision.setObjectClass("__ACCOUNT__");
    resource.getProvisions().add(provision);
    MappingTO mapping = new MappingTO();
    provision.setMapping(mapping);
    ItemTO item = new ItemTO();
    item.setIntAttrName("icon");
    item.setExtAttrName("icon");
    item.setPurpose(MappingPurpose.BOTH);
    mapping.setConnObjectKeyItem(item);
    // save the resource
    try {
        resourceService.create(resource);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.InvalidMapping, e.getType());
    }
}
Also used : MappingTO(org.apache.syncope.common.lib.to.MappingTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO)

Example 43 with ResourceTO

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

the class ResourceITCase method create.

@Test
public void create() {
    String resourceKey = "ws-target-resource-create";
    ResourceTO resourceTO = buildResourceTO(resourceKey);
    Response response = resourceService.create(resourceTO);
    resourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
    assertNotNull(resourceTO);
    // check for existence
    resourceTO = resourceService.read(resourceKey);
    assertNotNull(resourceTO);
}
Also used : Response(javax.ws.rs.core.Response) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) Test(org.junit.jupiter.api.Test)

Example 44 with ResourceTO

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

the class ResourceITCase method buildResourceTO.

private ResourceTO buildResourceTO(final String resourceKey) {
    ResourceTO resourceTO = new ResourceTO();
    resourceTO.setKey(resourceKey);
    resourceTO.setConnector("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08");
    ProvisionTO provisionTO = new ProvisionTO();
    provisionTO.setAnyType(AnyTypeKind.USER.name());
    provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
    resourceTO.getProvisions().add(provisionTO);
    MappingTO mapping = new MappingTO();
    provisionTO.setMapping(mapping);
    ItemTO item = new ItemTO();
    item.setExtAttrName("userId");
    item.setIntAttrName("userId");
    item.setPurpose(MappingPurpose.BOTH);
    mapping.add(item);
    item = new ItemTO();
    item.setExtAttrName("username");
    item.setIntAttrName("key");
    item.setPurpose(MappingPurpose.BOTH);
    mapping.setConnObjectKeyItem(item);
    item = new ItemTO();
    item.setExtAttrName("fullname");
    item.setIntAttrName("cn");
    item.setConnObjectKey(false);
    item.setPurpose(MappingPurpose.PROPAGATION);
    mapping.add(item);
    return resourceTO;
}
Also used : MappingTO(org.apache.syncope.common.lib.to.MappingTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO)

Example 45 with ResourceTO

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

the class ResourceITCase method read.

@Test
public void read() {
    ResourceTO resource = resourceService.read(RESOURCE_NAME_DBVIRATTR);
    assertNotNull(resource);
    Optional<ProvisionTO> provision = resource.getProvision(AnyTypeKind.USER.name());
    assertTrue(provision.isPresent());
    assertFalse(provision.get().getMapping().getItems().isEmpty());
    assertFalse(provision.get().getMapping().getLinkingItems().isEmpty());
}
Also used : ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)61 Test (org.junit.jupiter.api.Test)49 ItemTO (org.apache.syncope.common.lib.to.ItemTO)32 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)29 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)27 Response (javax.ws.rs.core.Response)23 MappingTO (org.apache.syncope.common.lib.to.MappingTO)23 UserTO (org.apache.syncope.common.lib.to.UserTO)17 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)14 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)12 ResourceService (org.apache.syncope.common.rest.api.service.ResourceService)11 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)10 GroupTO (org.apache.syncope.common.lib.to.GroupTO)10 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)9 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)9 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)8 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)8 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)8 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)8 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)8