Search in sources :

Example 11 with Mapping

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

the class ResourceTest method saveVirtualMapping.

@Test
public void saveVirtualMapping() {
    ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
    resource.setKey("ws-target-resource-virtual-mapping");
    resource.setPropagationPriority(2);
    Provision provision = entityFactory.newEntity(Provision.class);
    provision.setAnyType(anyTypeDAO.findUser());
    provision.setObjectClass(ObjectClass.ACCOUNT);
    provision.setResource(resource);
    resource.add(provision);
    Mapping mapping = entityFactory.newEntity(Mapping.class);
    mapping.setProvision(provision);
    provision.setMapping(mapping);
    MappingItem connObjectKey = entityFactory.newEntity(MappingItem.class);
    connObjectKey.setExtAttrName("username");
    connObjectKey.setIntAttrName("fullname");
    connObjectKey.setPurpose(MappingPurpose.BOTH);
    mapping.setConnObjectKeyItem(connObjectKey);
    MappingItem virtualMapItem = entityFactory.newEntity(MappingItem.class);
    virtualMapItem.setIntAttrName("virtualReadOnly");
    virtualMapItem.setExtAttrName("TEST");
    virtualMapItem.setPurpose(MappingPurpose.PROPAGATION);
    virtualMapItem.setMapping(mapping);
    mapping.add(virtualMapItem);
    ConnInstance connector = resourceDAO.find("ws-target-resource-1").getConnector();
    resource.setConnector(connector);
    resourceDAO.save(resource);
}
Also used : Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) Mapping(org.apache.syncope.core.persistence.api.entity.resource.Mapping) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 12 with Mapping

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

the class ResourceTest method saveInvalidMappingExtAttr.

@Test
public void saveInvalidMappingExtAttr() {
    assertThrows(InvalidEntityException.class, () -> {
        ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
        resource.setKey("ws-target-resource-basic-save-invalid");
        ConnInstance connector = resourceDAO.find("ws-target-resource-1").getConnector();
        resource.setConnector(connector);
        Provision provision = entityFactory.newEntity(Provision.class);
        provision.setAnyType(anyTypeDAO.findUser());
        provision.setObjectClass(ObjectClass.ACCOUNT);
        provision.setResource(resource);
        resource.add(provision);
        Mapping mapping = entityFactory.newEntity(Mapping.class);
        mapping.setProvision(provision);
        provision.setMapping(mapping);
        MappingItem item = entityFactory.newEntity(MappingItem.class);
        item.setConnObjectKey(true);
        item.setIntAttrName("fullname");
        mapping.add(item);
        item = entityFactory.newEntity(MappingItem.class);
        item.setIntAttrName("userId");
        mapping.add(item);
        resourceDAO.save(resource);
    });
}
Also used : Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) Mapping(org.apache.syncope.core.persistence.api.entity.resource.Mapping) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

Mapping (org.apache.syncope.core.persistence.api.entity.resource.Mapping)12 Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)12 ConnInstance (org.apache.syncope.core.persistence.api.entity.ConnInstance)10 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)10 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)8 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)7 Test (org.junit.jupiter.api.Test)7 Date (java.util.Date)3 List (java.util.List)3 AnyTypeDAO (org.apache.syncope.core.persistence.api.dao.AnyTypeDAO)3 ObjectClass (org.identityconnectors.framework.common.objects.ObjectClass)3 ParseException (java.text.ParseException)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 Collectors (java.util.stream.Collectors)2 SyncopeClientCompositeException (org.apache.syncope.common.lib.SyncopeClientCompositeException)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 IteratorChain (org.apache.syncope.common.lib.collections.IteratorChain)2 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)2 ItemTO (org.apache.syncope.common.lib.to.ItemTO)2