Search in sources :

Example 26 with Provision

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

the class ResourceTest method saveInvalidMappingIntAttr.

@Test
public void saveInvalidMappingIntAttr() {
    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 connObjectKey = entityFactory.newEntity(MappingItem.class);
        connObjectKey.setConnObjectKey(true);
        mapping.add(connObjectKey);
        // save the resource
        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 27 with Provision

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

the class ResourceTest method saveWithGroupMappingType.

@Test
public void saveWithGroupMappingType() {
    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.setIntAttrName("fullname");
    item.setExtAttrName("fullname");
    item.setPurpose(MappingPurpose.BOTH);
    mapping.setConnObjectKeyItem(item);
    item = entityFactory.newEntity(MappingItem.class);
    item.setIntAttrName("icon");
    item.setExtAttrName("icon");
    item.setPurpose(MappingPurpose.BOTH);
    mapping.add(item);
    item = entityFactory.newEntity(MappingItem.class);
    item.setIntAttrName("mderiveddata");
    item.setExtAttrName("mderiveddata");
    item.setPurpose(MappingPurpose.PROPAGATION);
    mapping.add(item);
    // save the resource
    ExternalResource actual = resourceDAO.save(resource);
    assertNotNull(actual);
    assertEquals(3, actual.getProvision(anyTypeDAO.findUser()).get().getMapping().getItems().size());
}
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 28 with Provision

use of org.apache.syncope.core.persistence.api.entity.resource.Provision 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 29 with Provision

use of org.apache.syncope.core.persistence.api.entity.resource.Provision 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)

Example 30 with Provision

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

the class VirSchemaTest method deal.

@Test
public void deal() {
    Provision provision = resourceDAO.find("ws-target-resource-1").getProvision(anyTypeDAO.findUser()).get();
    assertNotNull(provision);
    assertTrue(virSchemaDAO.findByProvision(provision).isEmpty());
    VirSchema virSchema = entityFactory.newEntity(VirSchema.class);
    virSchema.setKey("vSchema");
    virSchema.setReadonly(true);
    virSchema.setExtAttrName("EXT_ATTR");
    virSchema.setProvision(provision);
    virSchemaDAO.save(virSchema);
    virSchemaDAO.flush();
    virSchema = virSchemaDAO.find("vSchema");
    assertNotNull(virSchema);
    assertTrue(virSchema.isReadonly());
    assertEquals("EXT_ATTR", virSchema.getExtAttrName());
    provision = resourceDAO.find("ws-target-resource-1").getProvision(anyTypeDAO.findUser()).get();
    assertNotNull(provision);
    assertFalse(virSchemaDAO.findByProvision(provision).isEmpty());
    assertTrue(virSchemaDAO.findByProvision(provision).contains(virSchema));
    MappingItem item = virSchema.asLinkingMappingItem();
    assertNotNull(item);
    assertEquals(virSchema.getKey(), item.getIntAttrName());
}
Also used : Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)30 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)20 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)19 List (java.util.List)13 Set (java.util.Set)12 Autowired (org.springframework.beans.factory.annotation.Autowired)12 UserDAO (org.apache.syncope.core.persistence.api.dao.UserDAO)11 ArrayList (java.util.ArrayList)10 StringUtils (org.apache.commons.lang3.StringUtils)10 Attribute (org.identityconnectors.framework.common.objects.Attribute)10 HashSet (java.util.HashSet)9 GroupDAO (org.apache.syncope.core.persistence.api.dao.GroupDAO)9 VirSchemaDAO (org.apache.syncope.core.persistence.api.dao.VirSchemaDAO)9 OrgUnit (org.apache.syncope.core.persistence.api.entity.resource.OrgUnit)9 Connector (org.apache.syncope.core.provisioning.api.Connector)9 Test (org.junit.jupiter.api.Test)9 Transactional (org.springframework.transaction.annotation.Transactional)9 Collections (java.util.Collections)8 Collectors (java.util.stream.Collectors)8 IteratorChain (org.apache.syncope.common.lib.collections.IteratorChain)8