Search in sources :

Example 31 with ConnInstance

use of org.apache.syncope.core.persistence.api.entity.ConnInstance 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 32 with ConnInstance

use of org.apache.syncope.core.persistence.api.entity.ConnInstance 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 33 with ConnInstance

use of org.apache.syncope.core.persistence.api.entity.ConnInstance 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 34 with ConnInstance

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

the class ConnInstanceTest method delete.

@Test
public void delete() {
    ConnInstance connectorInstance = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
    assertNotNull(connectorInstance);
    connInstanceDAO.delete(connectorInstance.getKey());
    ConnInstance actual = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
    assertNull(actual);
}
Also used : ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

ConnInstance (org.apache.syncope.core.persistence.api.entity.ConnInstance)34 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)17 Test (org.junit.jupiter.api.Test)17 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)13 Mapping (org.apache.syncope.core.persistence.api.entity.resource.Mapping)11 Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)11 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)10 Transactional (org.springframework.transaction.annotation.Transactional)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 HashSet (java.util.HashSet)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)5 DelegatedAdministrationException (org.apache.syncope.core.spring.security.DelegatedAdministrationException)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Date (java.util.Date)4 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)4 PasswordPolicy (org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 Set (java.util.Set)3