syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [64/70] syncope git commit: [SYNCOPE-666] All done now
Date Thu, 11 Jun 2015 14:17:54 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ReportTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ReportTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ReportTest.java
deleted file mode 100644
index 9c49aae..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ReportTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.relationship;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.Date;
-import javax.persistence.EntityExistsException;
-import org.apache.syncope.common.lib.types.ReportExecStatus;
-import org.apache.syncope.core.persistence.api.dao.ReportDAO;
-import org.apache.syncope.core.persistence.api.dao.ReportExecDAO;
-import org.apache.syncope.core.persistence.api.entity.Report;
-import org.apache.syncope.core.persistence.api.entity.ReportExec;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class ReportTest extends AbstractTest {
-
-    @Autowired
-    private ReportDAO reportDAO;
-
-    @Autowired
-    private ReportExecDAO reportExecDAO;
-
-    @Test
-    public void find() {
-        Report report = reportDAO.find(1L);
-        assertNotNull(report);
-
-        assertNotNull(report.getExecs());
-        assertFalse(report.getExecs().isEmpty());
-        assertEquals(1, report.getExecs().size());
-    }
-
-    @Test(expected = EntityExistsException.class)
-    public void saveWithExistingName() {
-        Report report = reportDAO.find(1L);
-        assertNotNull(report);
-
-        String name = report.getName();
-
-        report = entityFactory.newEntity(Report.class);
-        report.setName(name);
-
-        reportDAO.save(report);
-        reportDAO.flush();
-    }
-
-    @Test
-    public void save() {
-        Report report = reportDAO.find(1L);
-        assertNotNull(report);
-        assertEquals(1, report.getExecs().size());
-
-        ReportExec reportExec = entityFactory.newEntity(ReportExec.class);
-        reportExec.setReport(report);
-        reportExec.setStartDate(new Date());
-        reportExec.setEndDate(new Date());
-        reportExec.setStatus(ReportExecStatus.SUCCESS);
-
-        report.addExec(reportExec);
-
-        reportExec = reportExecDAO.save(reportExec);
-        assertNotNull(reportExec);
-        assertNotNull(reportExec.getKey());
-
-        reportExecDAO.flush();
-
-        report = reportDAO.find(1L);
-        assertNotNull(report);
-        assertEquals(2, report.getExecs().size());
-    }
-
-    @Test
-    public void deleteReport() {
-        reportDAO.delete(1L);
-
-        reportDAO.flush();
-
-        assertNull(reportDAO.find(1L));
-        assertNull(reportExecDAO.find(1L));
-    }
-
-    @Test
-    public void deleteReportExecution() {
-        ReportExec execution = reportExecDAO.find(1L);
-        int executionNumber = execution.getReport().getExecs().size();
-
-        reportExecDAO.delete(1L);
-
-        reportExecDAO.flush();
-
-        assertNull(reportExecDAO.find(1L));
-
-        Report report = reportDAO.find(1L);
-        assertEquals(report.getExecs().size(), executionNumber - 1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ResourceTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ResourceTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ResourceTest.java
deleted file mode 100644
index 8e1e554..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ResourceTest.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.relationship;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.persistence.EntityManager;
-import org.apache.syncope.common.lib.types.IntMappingType;
-import org.apache.syncope.common.lib.types.MappingPurpose;
-import org.apache.syncope.common.lib.types.TaskType;
-import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
-import org.apache.syncope.core.persistence.api.dao.ConnInstanceDAO;
-import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
-import org.apache.syncope.core.persistence.api.dao.PolicyDAO;
-import org.apache.syncope.core.persistence.api.dao.TaskDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.ConnInstance;
-import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.PasswordPolicy;
-import org.apache.syncope.core.persistence.api.entity.resource.Mapping;
-import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
-import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.apache.syncope.core.persistence.jpa.entity.resource.JPAMappingItem;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class ResourceTest extends AbstractTest {
-
-    @Autowired
-    private EntityManager entityManager;
-
-    @Autowired
-    private ExternalResourceDAO resourceDAO;
-
-    @Autowired
-    private ConnInstanceDAO connInstanceDAO;
-
-    @Autowired
-    private AnyTypeDAO anyTypeDAO;
-
-    @Autowired
-    private UserDAO userDAO;
-
-    @Autowired
-    private TaskDAO taskDAO;
-
-    @Autowired
-    private PolicyDAO policyDAO;
-
-    @Test
-    public void createWithPasswordPolicy() {
-        final String resourceName = "resourceWithPasswordPolicy";
-
-        PasswordPolicy policy = (PasswordPolicy) policyDAO.find(4L);
-        ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
-        resource.setKey(resourceName);
-        resource.setPasswordPolicy(policy);
-
-        ConnInstance connector = connInstanceDAO.find(100L);
-        assertNotNull("connector not found", connector);
-        resource.setConnector(connector);
-
-        ExternalResource actual = resourceDAO.save(resource);
-        assertNotNull(actual);
-
-        actual = resourceDAO.find(actual.getKey());
-        assertNotNull(actual);
-        assertNotNull(actual.getPasswordPolicy());
-
-        resourceDAO.delete(resourceName);
-        assertNull(resourceDAO.find(resourceName));
-
-        assertNotNull(policyDAO.find(4L));
-    }
-
-    @Test
-    public void save() {
-        ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
-        resource.setKey("ws-target-resource-save");
-
-        // specify the connector
-        ConnInstance connector = connInstanceDAO.find(100L);
-        assertNotNull("connector not found", connector);
-
-        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);
-
-        // specify mappings
-        for (int i = 0; i < 3; i++) {
-            MappingItem item = entityFactory.newEntity(MappingItem.class);
-            item.setExtAttrName("test" + i);
-            item.setIntAttrName("nonexistent" + i);
-            item.setIntMappingType(IntMappingType.UserPlainSchema);
-            item.setMandatoryCondition("false");
-            item.setPurpose(MappingPurpose.SYNCHRONIZATION);
-            mapping.add(item);
-            item.setMapping(mapping);
-        }
-        MappingItem connObjectKey = entityFactory.newEntity(MappingItem.class);
-        connObjectKey.setExtAttrName("username");
-        connObjectKey.setIntAttrName("username");
-        connObjectKey.setIntMappingType(IntMappingType.UserKey);
-        connObjectKey.setPurpose(MappingPurpose.PROPAGATION);
-        mapping.setConnObjectKeyItem(connObjectKey);
-        connObjectKey.setMapping(mapping);
-
-        // map a derived attribute
-        MappingItem derived = entityFactory.newEntity(MappingItem.class);
-        derived.setConnObjectKey(false);
-        derived.setExtAttrName("fullname");
-        derived.setIntAttrName("cn");
-        derived.setIntMappingType(IntMappingType.UserDerivedSchema);
-        derived.setPurpose(MappingPurpose.PROPAGATION);
-        mapping.add(derived);
-        derived.setMapping(mapping);
-
-        // save the resource
-        ExternalResource actual = resourceDAO.save(resource);
-        assertNotNull(actual);
-        assertNotNull(actual.getProvision(anyTypeDAO.findUser()).getMapping());
-
-        resourceDAO.flush();
-        resourceDAO.detach(actual);
-        connInstanceDAO.detach(connector);
-
-        // assign the new resource to an user
-        User user = userDAO.find(1L);
-        assertNotNull("user not found", user);
-
-        user.add(actual);
-
-        resourceDAO.flush();
-
-        // retrieve resource
-        resource = resourceDAO.find(actual.getKey());
-        assertNotNull(resource);
-        resourceDAO.refresh(resource);
-
-        // check connector
-        connector = connInstanceDAO.find(100L);
-        assertNotNull(connector);
-        assertNotNull(connector.getResources());
-
-        assertNotNull(resource.getConnector());
-        assertTrue(resource.getConnector().equals(connector));
-
-        // check mappings
-        List<? extends MappingItem> items = resource.getProvision(anyTypeDAO.findUser()).getMapping().getItems();
-        assertNotNull(items);
-        assertEquals(5, items.size());
-
-        // check user
-        user = userDAO.find(1L);
-        assertNotNull(user);
-        assertNotNull(user.getResources());
-        assertTrue(user.getResources().contains(actual));
-    }
-
-    @Test
-    public void delete() {
-        ExternalResource resource = resourceDAO.find("resource-testdb");
-        assertNotNull("find to delete did not work", resource);
-
-        // -------------------------------------
-        // Get originally associated connector
-        // -------------------------------------
-        ConnInstance connector = resource.getConnector();
-        assertNotNull(connector);
-        // -------------------------------------
-
-        // -------------------------------------
-        // Get originally associated users
-        // -------------------------------------
-        List<User> users = userDAO.findByResource(resource);
-        assertNotNull(users);
-
-        Set<Long> userIds = new HashSet<>();
-        for (User user : users) {
-            userIds.add(user.getKey());
-        }
-        // -------------------------------------
-
-        // Get tasks
-        List<PropagationTask> propagationTasks = taskDAO.findAll(resource, TaskType.PROPAGATION);
-        assertFalse(propagationTasks.isEmpty());
-
-        // delete resource
-        resourceDAO.delete(resource.getKey());
-
-        // close the transaction
-        resourceDAO.flush();
-
-        // resource must be removed
-        ExternalResource actual = resourceDAO.find("resource-testdb");
-        assertNull("delete did not work", actual);
-
-        // resource must be not referenced any more from users
-        for (Long id : userIds) {
-            User actualUser = userDAO.find(id);
-            assertNotNull(actualUser);
-            for (ExternalResource res : userDAO.findAllResources(actualUser)) {
-                assertFalse(res.getKey().equalsIgnoreCase(resource.getKey()));
-            }
-        }
-
-        // resource must be not referenced any more from the connector
-        ConnInstance actualConnector = connInstanceDAO.find(connector.getKey());
-        assertNotNull(actualConnector);
-        for (ExternalResource res : actualConnector.getResources()) {
-            assertFalse(res.getKey().equalsIgnoreCase(resource.getKey()));
-        }
-
-        // there must be no tasks
-        for (PropagationTask task : propagationTasks) {
-            assertNull(taskDAO.find(task.getKey()));
-        }
-    }
-
-    @Test
-    public void emptyMapping() {
-        ExternalResource ldap = resourceDAO.find("resource-ldap");
-        assertNotNull(ldap);
-        assertNotNull(ldap.getProvision(anyTypeDAO.findUser()).getMapping());
-        assertNotNull(ldap.getProvision(anyTypeDAO.findGroup()).getMapping());
-
-        List<? extends MappingItem> items = ldap.getProvision(anyTypeDAO.findGroup()).getMapping().getItems();
-        assertNotNull(items);
-        assertFalse(items.isEmpty());
-        List<Long> itemKeys = new ArrayList<>(items.size());
-        for (MappingItem item : items) {
-            itemKeys.add(item.getKey());
-        }
-
-        ldap.remove(ldap.getProvision(anyTypeDAO.findGroup()));
-
-        // need to avoid any class not defined in this Maven module
-        ldap.getPropagationActionsClassNames().clear();
-
-        resourceDAO.save(ldap);
-        resourceDAO.flush();
-
-        for (Long itemId : itemKeys) {
-            assertNull(entityManager.find(JPAMappingItem.class, itemId));
-        }
-    }
-
-    @Test
-    public void issue243() {
-        ExternalResource csv = resourceDAO.find("resource-csv");
-        assertNotNull(csv);
-
-        int origMapItems = csv.getProvision(anyTypeDAO.findUser()).getMapping().getItems().size();
-
-        MappingItem newMapItem = entityFactory.newEntity(MappingItem.class);
-        newMapItem.setIntMappingType(IntMappingType.Username);
-        newMapItem.setExtAttrName("TEST");
-        newMapItem.setPurpose(MappingPurpose.PROPAGATION);
-        csv.getProvision(anyTypeDAO.findUser()).getMapping().add(newMapItem);
-
-        resourceDAO.save(csv);
-        resourceDAO.flush();
-
-        csv = resourceDAO.find("resource-csv");
-        assertNotNull(csv);
-        assertEquals(origMapItems + 1, csv.getProvision(anyTypeDAO.findUser()).getMapping().getItems().size());
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/RoleTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/RoleTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/RoleTest.java
deleted file mode 100644
index 5fdc803..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/RoleTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.relationship;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.Transformer;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.Entitlement;
-import org.apache.syncope.core.persistence.api.dao.AnyTypeClassDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.RealmDAO;
-import org.apache.syncope.core.persistence.api.dao.RoleDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.user.DynRoleMembership;
-import org.apache.syncope.core.persistence.api.entity.Role;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.apache.syncope.core.persistence.jpa.entity.user.JPADynRoleMembership;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class RoleTest extends AbstractTest {
-
-    @Autowired
-    private EntityManager entityManager;
-
-    @Autowired
-    private RoleDAO roleDAO;
-
-    @Autowired
-    private RealmDAO realmDAO;
-
-    @Autowired
-    private PlainSchemaDAO plainSchemaDAO;
-
-    @Autowired
-    private UserDAO userDAO;
-
-    @Autowired
-    private AnyTypeClassDAO anyTypeClassDAO;
-
-    /**
-     * Static copy of {@link org.apache.syncope.core.persistence.jpa.dao.JPAUserDAO} method with same signature:
-     * required for avoiding creating new transaction - good for general use case but bad for the way how
-     * this test class is architected.
-     */
-    private Collection<Role> findDynRoleMemberships(final User user) {
-        TypedQuery<Role> query = entityManager.createQuery(
-                "SELECT e.role FROM " + JPADynRoleMembership.class.getSimpleName()
-                + " e WHERE :user MEMBER OF e.users", Role.class);
-        query.setParameter("user", user);
-
-        return query.getResultList();
-    }
-
-    @Test
-    public void dynMembership() {
-        // 0. create user matching the condition below
-        User user = entityFactory.newEntity(User.class);
-        user.setUsername("username");
-        user.setRealm(realmDAO.find("/even/two"));
-        user.add(anyTypeClassDAO.find("other"));
-
-        UPlainAttr attr = entityFactory.newEntity(UPlainAttr.class);
-        attr.setOwner(user);
-        attr.setSchema(plainSchemaDAO.find("cool"));
-        attr.add("true", anyUtilsFactory.getInstance(AnyTypeKind.USER));
-        user.add(attr);
-
-        user = userDAO.save(user);
-        Long newUserKey = user.getKey();
-        assertNotNull(newUserKey);
-
-        // 1. create role with dynamic membership
-        Role role = entityFactory.newEntity(Role.class);
-        role.setName("new");
-        role.addRealm(realmDAO.getRoot());
-        role.addRealm(realmDAO.find("/even/two"));
-        role.getEntitlements().add(Entitlement.LOG_LIST);
-        role.getEntitlements().add(Entitlement.LOG_SET_LEVEL);
-
-        DynRoleMembership dynMembership = entityFactory.newEntity(DynRoleMembership.class);
-        dynMembership.setFIQLCond("cool==true");
-        dynMembership.setRole(role);
-
-        role.setDynMembership(dynMembership);
-
-        Role actual = roleDAO.save(role);
-        assertNotNull(actual);
-
-        roleDAO.flush();
-
-        // 2. verify that dynamic membership is there
-        actual = roleDAO.find(actual.getKey());
-        assertNotNull(actual);
-        assertNotNull(actual.getDynMembership());
-        assertNotNull(actual.getDynMembership().getKey());
-        assertEquals(actual, actual.getDynMembership().getRole());
-
-        // 3. verify that expected users have the created role dynamically assigned
-        assertEquals(2, actual.getDynMembership().getMembers().size());
-        assertEquals(new HashSet<>(Arrays.asList(4L, newUserKey)),
-                CollectionUtils.collect(actual.getDynMembership().getMembers(), new Transformer<User, Long>() {
-
-                    @Override
-                    public Long transform(final User input) {
-                        return input.getKey();
-                    }
-                }, new HashSet<Long>()));
-
-        user = userDAO.find(4L);
-        assertNotNull(user);
-        Collection<Role> dynRoleMemberships = findDynRoleMemberships(user);
-        assertEquals(1, dynRoleMemberships.size());
-        assertTrue(dynRoleMemberships.contains(actual.getDynMembership().getRole()));
-
-        // 4. delete the new user and verify that dynamic membership was updated
-        userDAO.delete(newUserKey);
-
-        userDAO.flush();
-
-        actual = roleDAO.find(actual.getKey());
-        assertEquals(1, actual.getDynMembership().getMembers().size());
-        assertEquals(4L, actual.getDynMembership().getMembers().get(0).getKey(), 0);
-
-        // 5. delete role and verify that dynamic membership was also removed
-        Long dynMembershipKey = actual.getDynMembership().getKey();
-
-        roleDAO.delete(actual);
-
-        roleDAO.flush();
-
-        assertNull(entityManager.find(JPADynRoleMembership.class, dynMembershipKey));
-
-        dynRoleMemberships = findDynRoleMemberships(user);
-        assertTrue(dynRoleMemberships.isEmpty());
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SecurityQuestionTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SecurityQuestionTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SecurityQuestionTest.java
deleted file mode 100644
index a3deb6e..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SecurityQuestionTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.relationship;
-
-import static org.junit.Assert.assertNull;
-
-import org.apache.syncope.core.persistence.api.dao.SecurityQuestionDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class SecurityQuestionTest extends AbstractTest {
-
-    @Autowired
-    private SecurityQuestionDAO securityQuestionDAO;
-
-    @Autowired
-    private UserDAO userDAO;
-
-    @Test
-    public void test() {
-        User user = userDAO.find(4L);
-        assertNull(user.getSecurityQuestion());
-        assertNull(user.getSecurityAnswer());
-
-        user.setSecurityQuestion(securityQuestionDAO.find(1L));
-        user.setSecurityAnswer("Rossi");
-        userDAO.save(user);
-
-        userDAO.flush();
-
-        securityQuestionDAO.delete(1L);
-
-        userDAO.flush();
-
-        user = userDAO.find(4L);
-
-        assertNull(user.getSecurityQuestion());
-        assertNull(user.getSecurityAnswer());
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/TaskTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/TaskTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/TaskTest.java
deleted file mode 100644
index 76621a1..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/TaskTest.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.relationship;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.MatchingRule;
-import org.apache.syncope.common.lib.types.PropagationMode;
-import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
-import org.apache.syncope.common.lib.types.ResourceOperation;
-import org.apache.syncope.common.lib.types.TaskType;
-import org.apache.syncope.common.lib.types.UnmatchingRule;
-import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
-import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
-import org.apache.syncope.core.persistence.api.dao.TaskDAO;
-import org.apache.syncope.core.persistence.api.dao.TaskExecDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
-import org.apache.syncope.core.persistence.api.entity.task.PushTask;
-import org.apache.syncope.core.persistence.api.entity.task.SyncTask;
-import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
-import org.apache.syncope.core.persistence.api.entity.task.AnyTemplate;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.apache.syncope.core.provisioning.api.sync.SyncActions;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class TaskTest extends AbstractTest {
-
-    @Autowired
-    private TaskDAO taskDAO;
-
-    @Autowired
-    private TaskExecDAO taskExecDAO;
-
-    @Autowired
-    private ExternalResourceDAO resourceDAO;
-
-    @Autowired
-    private UserDAO userDAO;
-
-    @Test
-    public void read() {
-        PropagationTask task = taskDAO.find(1L);
-        assertNotNull(task);
-
-        assertNotNull(task.getExecs());
-        assertFalse(task.getExecs().isEmpty());
-        assertEquals(1, task.getExecs().size());
-    }
-
-    @Test
-    public void save() {
-        ExternalResource resource = resourceDAO.find("ws-target-resource-1");
-        assertNotNull(resource);
-
-        User user = userDAO.find(2L);
-        assertNotNull(user);
-
-        PropagationTask task = entityFactory.newEntity(PropagationTask.class);
-        task.setResource(resource);
-        task.setAnyTypeKind(AnyTypeKind.USER);
-        task.setPropagationMode(PropagationMode.TWO_PHASES);
-        task.setPropagationOperation(ResourceOperation.CREATE);
-        task.setConnObjectKey("one@two.com");
-
-        Set<Attribute> attributes = new HashSet<>();
-        attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
-        attributes.add(AttributeBuilder.buildPassword("password".toCharArray()));
-        task.setAttributes(attributes);
-
-        task = taskDAO.save(task);
-        assertNotNull(task);
-
-        PropagationTask actual = taskDAO.find(task.getKey());
-        assertEquals(task, actual);
-
-        taskDAO.flush();
-
-        resource = resourceDAO.find("ws-target-resource-1");
-        assertTrue(taskDAO.findAll(resource, TaskType.PROPAGATION).contains(task));
-    }
-
-    @Test
-    public void addPropagationTaskExecution() {
-        PropagationTask task = taskDAO.find(1L);
-        assertNotNull(task);
-
-        int executionNumber = task.getExecs().size();
-
-        TaskExec execution = entityFactory.newEntity(TaskExec.class);
-        execution.setTask(task);
-        execution.setStatus(PropagationTaskExecStatus.CREATED.name());
-        task.addExec(execution);
-        execution.setStartDate(new Date());
-
-        taskDAO.save(task);
-        taskDAO.flush();
-
-        task = taskDAO.find(1L);
-        assertNotNull(task);
-
-        assertEquals(executionNumber + 1, task.getExecs().size());
-    }
-
-    @Test
-    public void addSyncTaskExecution() {
-        SyncTask task = taskDAO.find(4L);
-        assertNotNull(task);
-
-        int executionNumber = task.getExecs().size();
-
-        TaskExec execution = entityFactory.newEntity(TaskExec.class);
-        execution.setStatus("Text-free status");
-        execution.setTask(task);
-        task.addExec(execution);
-        execution.setMessage("A message");
-
-        taskDAO.save(task);
-        taskDAO.flush();
-
-        task = taskDAO.find(4L);
-        assertNotNull(task);
-
-        assertEquals(executionNumber + 1, task.getExecs().size());
-    }
-
-    @Test
-    public void addPushTaskExecution() {
-        PushTask task = taskDAO.find(13L);
-        assertNotNull(task);
-
-        int executionNumber = task.getExecs().size();
-
-        TaskExec execution = entityFactory.newEntity(TaskExec.class);
-        execution.setStatus("Text-free status");
-        execution.setTask(task);
-        task.addExec(execution);
-        execution.setMessage("A message");
-
-        taskDAO.save(task);
-        taskDAO.flush();
-
-        task = taskDAO.find(13L);
-        assertNotNull(task);
-
-        assertEquals(executionNumber + 1, task.getExecs().size());
-    }
-
-    @Test
-    public void deleteTask() {
-        taskDAO.delete(1L);
-
-        taskDAO.flush();
-
-        assertNull(taskDAO.find(1L));
-        assertNull(taskExecDAO.find(1L));
-    }
-
-    @Test
-    public void deleteTaskExecution() {
-        TaskExec execution = taskExecDAO.find(1L);
-        int executionNumber = execution.getTask().getExecs().size();
-
-        taskExecDAO.delete(1L);
-
-        taskExecDAO.flush();
-
-        assertNull(taskExecDAO.find(1L));
-
-        PropagationTask task = taskDAO.find(1L);
-        assertEquals(task.getExecs().size(), executionNumber - 1);
-    }
-
-    @Test
-    public void saveSyncTask() {
-        ExternalResource resource = resourceDAO.find("ws-target-resource-1");
-        assertNotNull(resource);
-
-        AnyTemplate template = entityFactory.newEntity(AnyTemplate.class);
-        template.set(new UserTO());
-
-        SyncTask task = entityFactory.newEntity(SyncTask.class);
-        task.setName("saveSyncTask");
-        task.setDescription("SyncTask description");
-        task.add(template);
-        task.setCronExpression("BLA BLA");
-        task.setMatchingRule(MatchingRule.UPDATE);
-        task.setUnmatchingRule(UnmatchingRule.PROVISION);
-
-        // this save() fails because of an invalid Cron Expression
-        InvalidEntityException exception = null;
-        try {
-            taskDAO.save(task);
-        } catch (InvalidEntityException e) {
-            exception = e;
-        }
-        assertNotNull(exception);
-
-        task.setCronExpression(null);
-        // this save() fails because a SyncTask requires a target resource
-        exception = null;
-        try {
-            taskDAO.save(task);
-        } catch (InvalidEntityException e) {
-            exception = e;
-        }
-        assertNotNull(exception);
-
-        task.setResource(resource);
-        task.getActionsClassNames().add(getClass().getName());
-
-        // this save() fails because jobActionsClassName does not implement 
-        // the right interface
-        exception = null;
-        try {
-            taskDAO.save(task);
-        } catch (InvalidEntityException e) {
-            exception = e;
-        }
-        assertNotNull(exception);
-
-        task.getActionsClassNames().clear();
-        task.getActionsClassNames().add(SyncActions.class.getName());
-        // this save() finally works
-        task = taskDAO.save(task);
-        assertNotNull(task);
-
-        SyncTask actual = taskDAO.find(task.getKey());
-        assertEquals(task, actual);
-    }
-
-    @Test
-    public void issueSYNCOPE144() {
-        ExternalResource resource = resourceDAO.find("ws-target-resource-1");
-        assertNotNull(resource);
-
-        SyncTask task = entityFactory.newEntity(SyncTask.class);
-
-        task.setResource(resource);
-        task.setName("issueSYNCOPE144");
-        task.setDescription("issueSYNCOPE144 Description");
-        task.getActionsClassNames().add(SyncActions.class.getName());
-        task.setMatchingRule(MatchingRule.UPDATE);
-        task.setUnmatchingRule(UnmatchingRule.PROVISION);
-
-        task = taskDAO.save(task);
-        assertNotNull(task);
-
-        SyncTask actual = taskDAO.find(task.getKey());
-        assertEquals(task, actual);
-        assertEquals("issueSYNCOPE144", actual.getName());
-        assertEquals("issueSYNCOPE144 Description", actual.getDescription());
-
-        actual.setName("issueSYNCOPE144_2");
-        actual.setDescription("issueSYNCOPE144 Description_2");
-
-        actual = taskDAO.save(actual);
-        assertNotNull(actual);
-        assertEquals("issueSYNCOPE144_2", actual.getName());
-        assertEquals("issueSYNCOPE144 Description_2", actual.getDescription());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/UserTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/UserTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/UserTest.java
deleted file mode 100644
index 5a12044..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/UserTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.relationship;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.user.UMembership;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.user.URelationship;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.AbstractTest;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional
-public class UserTest extends AbstractTest {
-
-    @Autowired
-    private AnyObjectDAO anyObjectDAO;
-
-    @Autowired
-    private UserDAO userDAO;
-
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Autowired
-    private PlainSchemaDAO plainSchemaDAO;
-
-    @Autowired
-    private PlainAttrDAO plainAttrDAO;
-
-    @Autowired
-    private PlainAttrValueDAO plainAttrValueDAO;
-
-    @Test
-    public void delete() {
-        List<UMembership> memberships = groupDAO.findUMemberships(groupDAO.find(7L));
-        assertFalse(memberships.isEmpty());
-        List<URelationship> relationships = anyObjectDAO.findURelationships(anyObjectDAO.find(1L));
-        assertFalse(relationships.isEmpty());
-
-        userDAO.delete(4L);
-
-        userDAO.flush();
-
-        assertNull(userDAO.find(4L));
-        assertNull(plainAttrDAO.find(550L, UPlainAttr.class));
-        assertNull(plainAttrValueDAO.find(22L, UPlainAttrValue.class));
-        assertNotNull(plainSchemaDAO.find("loginDate"));
-
-        memberships = groupDAO.findUMemberships(groupDAO.find(7L));
-        assertTrue(memberships.isEmpty());
-        relationships = anyObjectDAO.findURelationships(anyObjectDAO.find(1L));
-        assertTrue(relationships.isEmpty());
-    }
-
-    @Test
-    public void ships() {
-        User user = userDAO.find(4L);
-        assertNotNull(user);
-        assertEquals(1, user.getMemberships().size());
-        assertEquals(7L, user.getMemberships().get(0).getRightEnd().getKey(), 0);
-
-        user.remove(user.getMemberships().get(0));
-
-        UMembership newM = entityFactory.newEntity(UMembership.class);
-        newM.setLeftEnd(user);
-        newM.setRightEnd(groupDAO.find(13L));
-        user.add(newM);
-
-        userDAO.save(user);
-
-        userDAO.flush();
-
-        user = userDAO.find(4L);
-        assertEquals(1, user.getMemberships().size());
-        assertEquals(13L, user.getMemberships().get(0).getRightEnd().getKey(), 0);
-        assertEquals(1, user.getRelationships().size());
-        assertEquals(1L, user.getRelationships().get(0).getRightEnd().getKey(), 0);
-
-        user.remove(user.getRelationships().get(0));
-
-        URelationship newR = entityFactory.newEntity(URelationship.class);
-        newR.setLeftEnd(user);
-        newR.setRightEnd(anyObjectDAO.find(2L));
-        user.add(newR);
-
-        userDAO.save(user);
-
-        userDAO.flush();
-
-        user = userDAO.find(4L);
-        assertEquals(1, user.getRelationships().size());
-        assertEquals(2L, user.getRelationships().get(0).getRightEnd().getKey(), 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/persistence-jpa/src/test/resources/content.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/content.xml b/core/persistence-jpa/src/test/resources/content.xml
index 7b11faa..8b4740a 100644
--- a/core/persistence-jpa/src/test/resources/content.xml
+++ b/core/persistence-jpa/src/test/resources/content.xml
@@ -112,6 +112,9 @@ under the License.
   <Policy DTYPE="SyncPolicy" id="9" description="sync policy for java rule" type="SYNC" 
           specification='{"conflictResolutionAction":"IGNORE","items":[]}'/>
 
+  <RelationshipType name="inclusion" description="Models the act that an object is included in another"/>
+  <RelationshipType name="neighborhood"/>
+  
   <AnyTypeClass name="generic membership"/>
 
   <AnyType name="USER" kind="USER"/>
@@ -141,8 +144,8 @@ under the License.
   <AnyObject id="2" realm_id="1" type_name="PRINTER"
              creator="admin" lastModifier="admin" 
              creationDate="2010-10-20 11:00:00" lastChangeDate="2010-10-20 11:00:00"/>
-
-  <ARelationship id="1" left_anyObject_id="1" right_anyObject_id="2"/>
+  
+  <ARelationship id="1" left_anyObject_id="1" right_anyObject_id="2" type_name="neighborhood"/>
   
   <SyncopeRole id="1" name="User reviewer"/>
   <SyncopeRole_entitlements entitlement="USER_READ" role_id="1"/>
@@ -254,7 +257,7 @@ under the License.
                 creator="admin" lastModifier="admin" 
                 creationDate="2010-10-20 11:00:00" lastChangeDate="2010-10-20 11:00:00"/>
   
-  <URelationship id="1" user_id="4" anyObject_id="1"/>
+  <URelationship id="1" user_id="4" anyObject_id="1" type_name="neighborhood"/>
 
   <UMembership id="1" user_id="1" group_id="1"/>
   <UMembership id="2" user_id="2" group_id="1"/>

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RelationshipTypeDataBinder.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RelationshipTypeDataBinder.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RelationshipTypeDataBinder.java
new file mode 100644
index 0000000..3e940ee
--- /dev/null
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RelationshipTypeDataBinder.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.api.data;
+
+import org.apache.syncope.common.lib.to.RelationshipTypeTO;
+import org.apache.syncope.core.persistence.api.entity.RelationshipType;
+
+public interface RelationshipTypeDataBinder {
+
+    RelationshipType create(RelationshipTypeTO relationshipTypeTO);
+
+    void update(RelationshipType relationshipType, RelationshipTypeTO relationshipTypeTO);
+
+    RelationshipTypeTO getRelationshipTypeTO(RelationshipType relationshipType);
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RelationshipTypeDataBinderImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RelationshipTypeDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RelationshipTypeDataBinderImpl.java
new file mode 100644
index 0000000..4d324cf
--- /dev/null
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RelationshipTypeDataBinderImpl.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.java.data;
+
+import org.apache.syncope.common.lib.to.RelationshipTypeTO;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.RelationshipType;
+import org.apache.syncope.core.provisioning.api.data.RelationshipTypeDataBinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class RelationshipTypeDataBinderImpl implements RelationshipTypeDataBinder {
+
+    private static final Logger LOG = LoggerFactory.getLogger(RelationshipTypeDataBinder.class);
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    @Override
+    public RelationshipType create(final RelationshipTypeTO relationshipTypeTO) {
+        RelationshipType relationshipType = entityFactory.newEntity(RelationshipType.class);
+        update(relationshipType, relationshipTypeTO);
+        return relationshipType;
+    }
+
+    @Override
+    public void update(final RelationshipType relationshipType, final RelationshipTypeTO relationshipTypeTO) {
+        if (relationshipType.getKey() == null) {
+            relationshipType.setKey(relationshipTypeTO.getKey());
+        }
+
+        relationshipType.setDescription(relationshipTypeTO.getDescription());
+    }
+
+    @Override
+    public RelationshipTypeTO getRelationshipTypeTO(final RelationshipType relationshipType) {
+        RelationshipTypeTO relationshipTypeTO = new RelationshipTypeTO();
+
+        relationshipTypeTO.setKey(relationshipType.getKey());
+        relationshipTypeTO.setDescription(relationshipType.getDescription());
+
+        return relationshipTypeTO;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RelationshipTypeServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RelationshipTypeServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RelationshipTypeServiceImpl.java
new file mode 100644
index 0000000..6e1958e
--- /dev/null
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/RelationshipTypeServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.rest.cxf.service;
+
+import java.net.URI;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.apache.syncope.common.lib.to.RelationshipTypeTO;
+import org.apache.syncope.common.rest.api.RESTHeaders;
+import org.apache.syncope.common.rest.api.service.RelationshipTypeService;
+import org.apache.syncope.core.logic.RelationshipTypeLogic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RelationshipTypeServiceImpl extends AbstractServiceImpl implements RelationshipTypeService {
+
+    @Autowired
+    private RelationshipTypeLogic logic;
+
+    @Override
+    public List<RelationshipTypeTO> list() {
+        return logic.list();
+    }
+
+    @Override
+    public RelationshipTypeTO read(final String key) {
+        return logic.read(key);
+    }
+
+    @Override
+    public Response create(final RelationshipTypeTO anyTypeTO) {
+        RelationshipTypeTO created = logic.create(anyTypeTO);
+        URI location = uriInfo.getAbsolutePathBuilder().path(String.valueOf(created.getKey())).build();
+        return Response.created(location).
+                header(RESTHeaders.RESOURCE_KEY, created.getKey()).
+                build();
+    }
+
+    @Override
+    public void update(final RelationshipTypeTO anyTypeTO) {
+        logic.update(anyTypeTO);
+    }
+
+    @Override
+    public void delete(final String key) {
+        logic.delete(key);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
index 77e4c50..7c36611 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
@@ -63,6 +63,7 @@ import org.apache.syncope.common.rest.api.service.ReportService;
 import org.apache.syncope.common.rest.api.service.ResourceService;
 import org.apache.syncope.common.rest.api.service.GroupService;
 import org.apache.syncope.common.rest.api.service.RealmService;
+import org.apache.syncope.common.rest.api.service.RelationshipTypeService;
 import org.apache.syncope.common.rest.api.service.RoleService;
 import org.apache.syncope.common.rest.api.service.SchemaService;
 import org.apache.syncope.common.rest.api.service.SecurityQuestionService;
@@ -158,6 +159,8 @@ public abstract class AbstractITCase {
 
     protected static AnyTypeService anyTypeService;
 
+    protected static RelationshipTypeService relationshipTypeService;
+
     protected static RealmService realmService;
 
     protected static AnyObjectService anyObjectService;
@@ -232,6 +235,7 @@ public abstract class AbstractITCase {
         syncopeService = adminClient.getService(SyncopeService.class);
         anyTypeClassService = adminClient.getService(AnyTypeClassService.class);
         anyTypeService = adminClient.getService(AnyTypeService.class);
+        relationshipTypeService = adminClient.getService(RelationshipTypeService.class);
         realmService = adminClient.getService(RealmService.class);
         anyObjectService = adminClient.getService(AnyObjectService.class);
         roleService = adminClient.getService(RoleService.class);

http://git-wip-us.apache.org/repos/asf/syncope/blob/d8927ef4/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RelationshipTypeITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RelationshipTypeITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RelationshipTypeITCase.java
new file mode 100644
index 0000000..3d8d82f
--- /dev/null
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/RelationshipTypeITCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.fit.core.reference;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import javax.ws.rs.core.Response;
+import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.to.RelationshipTypeTO;
+import org.apache.syncope.common.lib.types.ClientExceptionType;
+import org.apache.syncope.common.rest.api.service.RelationshipTypeService;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.JVM)
+public class RelationshipTypeITCase extends AbstractITCase {
+
+    @Test
+    public void read() {
+        RelationshipTypeTO otherType = relationshipTypeService.read("inclusion");
+        assertNotNull(otherType);
+        assertEquals("inclusion", otherType.getKey());
+    }
+
+    @Test
+    public void list() {
+        List<RelationshipTypeTO> list = relationshipTypeService.list();
+        assertFalse(list.isEmpty());
+    }
+
+    @Test
+    public void crud() {
+        RelationshipTypeTO newType = new RelationshipTypeTO();
+        newType.setKey("new type");
+        newType.setDescription("description");
+
+        Response response = relationshipTypeService.create(newType);
+        assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
+
+        newType = getObject(response.getLocation(), RelationshipTypeService.class, RelationshipTypeTO.class);
+        assertNotNull(newType);
+        assertEquals("description", newType.getDescription());
+
+        newType.setDescription("new description");
+        relationshipTypeService.update(newType);
+
+        newType = relationshipTypeService.read(newType.getKey());
+        assertNotNull(newType);
+        assertEquals("new description", newType.getDescription());
+
+        relationshipTypeService.delete(newType.getKey());
+
+        try {
+            relationshipTypeService.read(newType.getKey());
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.NotFound, e.getType());
+        }
+    }
+
+    @Test
+    public void createInvalidName() {
+        RelationshipTypeTO newType = new RelationshipTypeTO();
+        newType.setKey("membership");
+        try {
+            relationshipTypeService.create(newType);
+            fail();
+        } catch (SyncopeClientException e) {
+            assertEquals(ClientExceptionType.InvalidRelationshipType, e.getType());
+        }
+    }
+}


Mime
View raw message