syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [11/70] syncope git commit: [SYNCOPE-666] Initial commit, Travis CI builds disabled
Date Thu, 11 Jun 2015 14:17:01 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/SubjectSearchTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/SubjectSearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/SubjectSearchTest.java
deleted file mode 100644
index 22e7494..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/SubjectSearchTest.java
+++ /dev/null
@@ -1,483 +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.entity;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.types.SubjectType;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.SubjectSearchDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
-import org.apache.syncope.core.persistence.api.dao.search.GroupCond;
-import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
-import org.apache.syncope.core.persistence.api.dao.search.ResourceCond;
-import org.apache.syncope.core.persistence.api.dao.search.RoleCond;
-import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.apache.syncope.core.persistence.api.dao.search.SubjectCond;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-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 SubjectSearchTest extends AbstractTest {
-
-    @Autowired
-    private UserDAO userDAO;
-
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Autowired
-    private SubjectSearchDAO searchDAO;
-
-    @Test
-    public void userMatch() {
-        User user = userDAO.find(1L);
-        assertNotNull(user);
-
-        GroupCond groupCond = new GroupCond();
-        groupCond.setGroupKey(5L);
-        assertFalse(searchDAO.matches(user, SearchCond.getLeafCond(groupCond), SubjectType.USER));
-
-        groupCond.setGroupKey(1L);
-        assertTrue(searchDAO.matches(user, SearchCond.getLeafCond(groupCond), SubjectType.USER));
-
-        RoleCond roleCond = new RoleCond();
-        roleCond.setRoleKey(3L);
-        assertTrue(searchDAO.matches(user, SearchCond.getLeafCond(roleCond), SubjectType.USER));
-    }
-
-    @Test
-    public void groupMatch() {
-        Group group = groupDAO.find(1L);
-        assertNotNull(group);
-
-        AttributeCond attrCond = new AttributeCond();
-        attrCond.setSchema("show");
-        attrCond.setType(AttributeCond.Type.ISNOTNULL);
-
-        assertTrue(searchDAO.matches(group, SearchCond.getLeafCond(attrCond), SubjectType.GROUP));
-    }
-
-    @Test
-    public void searchWithLikeCondition() {
-        AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.LIKE);
-        fullnameLeafCond.setSchema("fullname");
-        fullnameLeafCond.setExpression("%o%");
-
-        GroupCond groupCond = new GroupCond();
-        groupCond.setGroupKey(1L);
-
-        AttributeCond loginDateCond = new AttributeCond(AttributeCond.Type.EQ);
-        loginDateCond.setSchema("loginDate");
-        loginDateCond.setExpression("2009-05-26");
-
-        SearchCond subCond = SearchCond.getAndCond(SearchCond.getLeafCond(fullnameLeafCond), SearchCond.getLeafCond(
-                groupCond));
-
-        assertTrue(subCond.isValid());
-
-        SearchCond cond = SearchCond.getAndCond(subCond, SearchCond.getLeafCond(loginDateCond));
-
-        assertTrue(cond.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-    }
-
-    @Test
-    public void searchWithNotCondition() {
-        AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.EQ);
-        fullnameLeafCond.setSchema("fullname");
-        fullnameLeafCond.setExpression("Giuseppe Verdi");
-
-        SearchCond cond = SearchCond.getNotLeafCond(fullnameLeafCond);
-        assertTrue(cond.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(4, users.size());
-
-        Set<Long> ids = new HashSet<>(users.size());
-        for (User user : users) {
-            ids.add(user.getKey());
-        }
-        assertTrue(ids.contains(1L));
-        assertTrue(ids.contains(3L));
-    }
-
-    @Test
-    public void searchByBoolean() {
-        AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.EQ);
-        coolLeafCond.setSchema("cool");
-        coolLeafCond.setExpression("true");
-
-        SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
-        assertTrue(cond.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-
-        assertEquals(Long.valueOf(4L), users.get(0).getKey());
-    }
-
-    @Test
-    public void searchByPageAndSize() {
-        AttributeCond fullnameLeafCond = new AttributeCond(AttributeCond.Type.LIKE);
-        fullnameLeafCond.setSchema("fullname");
-        fullnameLeafCond.setExpression("%o%");
-
-        GroupCond groupCond = new GroupCond();
-        groupCond.setGroupKey(1L);
-
-        AttributeCond loginDateCond = new AttributeCond(AttributeCond.Type.EQ);
-        loginDateCond.setSchema("loginDate");
-        loginDateCond.setExpression("2009-05-26");
-
-        SearchCond subCond = SearchCond.getAndCond(
-                SearchCond.getLeafCond(fullnameLeafCond), SearchCond.getLeafCond(groupCond));
-
-        assertTrue(subCond.isValid());
-
-        SearchCond cond = SearchCond.getAndCond(subCond, SearchCond.getLeafCond(loginDateCond));
-
-        assertTrue(cond.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                cond, 1, 2, Collections.<OrderByClause>emptyList(),
-                SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-
-        users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                cond, 2, 2, Collections.<OrderByClause>emptyList(),
-                SubjectType.USER);
-        assertNotNull(users);
-        assertTrue(users.isEmpty());
-    }
-
-    @Test
-    public void searchByGroup() {
-        GroupCond groupCond = new GroupCond();
-        groupCond.setGroupKey(1L);
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(groupCond), SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(2, users.size());
-
-        groupCond = new GroupCond();
-        groupCond.setGroupKey(5L);
-
-        users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getNotLeafCond(groupCond), SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(5, users.size());
-    }
-
-    @Test
-    public void searchByRole() {
-        RoleCond roleCond = new RoleCond();
-        roleCond.setRoleKey(3L);
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(roleCond), SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-    }
-
-    @Test
-    public void searchByIsNull() {
-        AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.ISNULL);
-        coolLeafCond.setSchema("cool");
-
-        List<User> users = searchDAO.search(
-                SyncopeConstants.FULL_ADMIN_REALMS, SearchCond.getLeafCond(coolLeafCond), SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(4, users.size());
-
-        coolLeafCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
-        coolLeafCond.setSchema("cool");
-
-        users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(coolLeafCond), SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-    }
-
-    @Test
-    public void searchByResource() {
-        ResourceCond ws2 = new ResourceCond();
-        ws2.setResourceName("ws-target-resource-2");
-
-        ResourceCond ws1 = new ResourceCond();
-        ws1.setResourceName("ws-target-resource-list-mappings-2");
-
-        SearchCond searchCondition = SearchCond.getAndCond(SearchCond.getNotLeafCond(ws2), SearchCond.getLeafCond(ws1));
-        assertTrue(searchCondition.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-    }
-
-    @Test
-    public void searchByBooleanSubjectCond() {
-        AttributeCond booleanCond = new AttributeCond(SubjectCond.Type.EQ);
-        booleanCond.setSchema("show");
-        booleanCond.setExpression("true");
-
-        List<Group> matchingGroups = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(booleanCond), SubjectType.GROUP);
-        assertNotNull(matchingGroups);
-        assertFalse(matchingGroups.isEmpty());
-    }
-
-    @Test
-    public void searchByUsernameAndKey() {
-        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.LIKE);
-        usernameLeafCond.setSchema("username");
-        usernameLeafCond.setExpression("%ini");
-
-        SubjectCond idRightCond = new SubjectCond(SubjectCond.Type.LT);
-        idRightCond.setSchema("key");
-        idRightCond.setExpression("2");
-
-        SearchCond searchCondition = SearchCond.getAndCond(
-                SearchCond.getLeafCond(usernameLeafCond),
-                SearchCond.getLeafCond(idRightCond));
-
-        List<User> matchingUsers = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, SubjectType.USER);
-
-        assertNotNull(matchingUsers);
-        assertEquals(1, matchingUsers.size());
-        assertEquals("rossini", matchingUsers.iterator().next().getUsername());
-        assertEquals(1L, matchingUsers.iterator().next().getKey(), 0);
-    }
-
-    @Test
-    public void searchByGroupNameAndKey() {
-        SubjectCond groupNameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
-        groupNameLeafCond.setSchema("name");
-        groupNameLeafCond.setExpression("root");
-
-        SubjectCond idRightCond = new SubjectCond(SubjectCond.Type.LT);
-        idRightCond.setSchema("key");
-        idRightCond.setExpression("2");
-
-        SearchCond searchCondition = SearchCond.getAndCond(
-                SearchCond.getLeafCond(groupNameLeafCond),
-                SearchCond.getLeafCond(idRightCond));
-
-        assertTrue(searchCondition.isValid());
-
-        List<Group> matchingGroups = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, SubjectType.GROUP);
-
-        assertNotNull(matchingGroups);
-        assertEquals(1, matchingGroups.size());
-        assertEquals("root", matchingGroups.iterator().next().getName());
-        assertEquals(1L, matchingGroups.iterator().next().getKey(), 0);
-    }
-
-    @Test
-    public void searchByUsernameAndFullname() {
-        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
-        usernameLeafCond.setSchema("username");
-        usernameLeafCond.setExpression("rossini");
-
-        AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.LIKE);
-        idRightCond.setSchema("fullname");
-        idRightCond.setExpression("Giuseppe V%");
-
-        SearchCond searchCondition = SearchCond.getOrCond(
-                SearchCond.getLeafCond(usernameLeafCond),
-                SearchCond.getLeafCond(idRightCond));
-
-        List<User> matchingUsers = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, SubjectType.USER);
-        assertNotNull(matchingUsers);
-        assertEquals(2, matchingUsers.size());
-    }
-
-    @Test
-    public void searchById() {
-        SubjectCond idLeafCond = new SubjectCond(SubjectCond.Type.LT);
-        idLeafCond.setSchema("id");
-        idLeafCond.setExpression("2");
-
-        SearchCond searchCondition = SearchCond.getLeafCond(idLeafCond);
-        assertTrue(searchCondition.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-        assertEquals(1L, users.iterator().next().getKey(), 0);
-
-        idLeafCond = new SubjectCond(SubjectCond.Type.LT);
-        idLeafCond.setSchema("id");
-        idLeafCond.setExpression("4");
-
-        searchCondition = SearchCond.getNotLeafCond(idLeafCond);
-        assertTrue(searchCondition.isValid());
-
-        users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(2, users.size());
-        assertTrue(CollectionUtils.exists(users, new Predicate<User>() {
-
-            @Override
-            public boolean evaluate(User user) {
-                return user.getKey() == 4;
-            }
-        }));
-    }
-
-    @Test
-    public void userOrderBy() {
-        SubjectCond usernameLeafCond = new SubjectCond(SubjectCond.Type.EQ);
-        usernameLeafCond.setSchema("username");
-        usernameLeafCond.setExpression("rossini");
-        AttributeCond idRightCond = new AttributeCond(AttributeCond.Type.LIKE);
-        idRightCond.setSchema("fullname");
-        idRightCond.setExpression("Giuseppe V%");
-        SearchCond searchCondition = SearchCond.getOrCond(
-                SearchCond.getLeafCond(usernameLeafCond), SearchCond.getLeafCond(idRightCond));
-
-        List<OrderByClause> orderByClauses = new ArrayList<>();
-        OrderByClause orderByClause = new OrderByClause();
-        orderByClause.setField("username");
-        orderByClause.setDirection(OrderByClause.Direction.DESC);
-        orderByClauses.add(orderByClause);
-        orderByClause = new OrderByClause();
-        orderByClause.setField("fullname");
-        orderByClause.setDirection(OrderByClause.Direction.ASC);
-        orderByClauses.add(orderByClause);
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, orderByClauses, SubjectType.USER);
-        assertEquals(searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, SubjectType.USER),
-                users.size());
-    }
-
-    @Test
-    public void groupOrderBy() {
-        SubjectCond idLeafCond = new SubjectCond(SubjectCond.Type.LIKE);
-        idLeafCond.setSchema("name");
-        idLeafCond.setExpression("%r");
-        SearchCond searchCondition = SearchCond.getLeafCond(idLeafCond);
-        assertTrue(searchCondition.isValid());
-
-        OrderByClause orderByClause = new OrderByClause();
-        orderByClause.setField("name");
-
-        List<Group> groups = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, Collections.singletonList(orderByClause), SubjectType.GROUP);
-        assertEquals(searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS,
-                searchCondition, SubjectType.GROUP),
-                groups.size());
-    }
-
-    @Test
-    public void issue202() {
-        ResourceCond ws2 = new ResourceCond();
-        ws2.setResourceName("ws-target-resource-2");
-
-        ResourceCond ws1 = new ResourceCond();
-        ws1.setResourceName("ws-target-resource-list-mappings-1");
-
-        SearchCond searchCondition =
-                SearchCond.getAndCond(SearchCond.getNotLeafCond(ws2), SearchCond.getNotLeafCond(ws1));
-        assertTrue(searchCondition.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(2, users.size());
-        assertTrue(CollectionUtils.exists(users, new Predicate<User>() {
-
-            @Override
-            public boolean evaluate(User user) {
-                return user.getKey() == 4;
-            }
-        }));
-    }
-
-    @Test
-    public void issue242() {
-        SubjectCond cond = new SubjectCond(AttributeCond.Type.LIKE);
-        cond.setSchema("id");
-        cond.setExpression("test%");
-
-        SearchCond searchCondition = SearchCond.getLeafCond(cond);
-        assertTrue(searchCondition.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, SubjectType.USER);
-        assertNotNull(users);
-        assertTrue(users.isEmpty());
-    }
-
-    @Test
-    public void issueSYNCOPE46() {
-        SubjectCond cond = new SubjectCond(AttributeCond.Type.LIKE);
-        cond.setSchema("username");
-        cond.setExpression("%ossin%");
-
-        SearchCond searchCondition = SearchCond.getLeafCond(cond);
-        assertTrue(searchCondition.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, searchCondition, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-    }
-
-    @Test
-    public void issueSYNCOPE433() {
-        AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNULL);
-        isNullCond.setSchema("loginDate");
-
-        SubjectCond likeCond = new SubjectCond(AttributeCond.Type.LIKE);
-        likeCond.setSchema("username");
-        likeCond.setExpression("%ossin%");
-
-        SearchCond searchCond = SearchCond.getOrCond(
-                SearchCond.getLeafCond(isNullCond), SearchCond.getLeafCond(likeCond));
-
-        Integer count = searchDAO.count(SyncopeConstants.FULL_ADMIN_REALMS, searchCond, SubjectType.USER);
-        assertNotNull(count);
-        assertTrue(count > 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/TaskTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/TaskTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/TaskTest.java
index 5fc71d2..43d65d1 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/TaskTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/TaskTest.java
@@ -26,14 +26,14 @@ import static org.junit.Assert.assertNull;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.PropagationMode;
 import org.apache.syncope.common.lib.types.ResourceOperation;
 import org.apache.syncope.common.lib.types.TaskType;
 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.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
+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.user.User;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
@@ -81,12 +81,12 @@ public class TaskTest extends AbstractTest {
 
         PropagationTask task = entityFactory.newEntity(PropagationTask.class);
         task.setResource(resource);
-        task.setSubjectType(AttributableType.USER);
+        task.setAnyTypeKind(AnyTypeKind.USER);
         task.setPropagationMode(PropagationMode.TWO_PHASES);
         task.setPropagationOperation(ResourceOperation.CREATE);
-        task.setAccountId("one@two.com");
+        task.setConnObjectKey("one@two.com");
 
-        Set<Attribute> attributes = new HashSet<Attribute>();
+        Set<Attribute> attributes = new HashSet<>();
         attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
         attributes.add(AttributeBuilder.buildPassword("password".toCharArray()));
         task.setAttributes(attributes);

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirAttrTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirAttrTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirAttrTest.java
index 9537d5e..e1ffc11 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirAttrTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirAttrTest.java
@@ -23,19 +23,14 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.util.List;
-import org.apache.syncope.core.persistence.api.dao.MembershipDAO;
 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.dao.VirAttrDAO;
 import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
-import org.apache.syncope.core.persistence.api.entity.membership.MVirAttr;
-import org.apache.syncope.core.persistence.api.entity.membership.MVirAttrTemplate;
-import org.apache.syncope.core.persistence.api.entity.membership.Membership;
+import org.apache.syncope.core.persistence.api.entity.VirSchema;
 import org.apache.syncope.core.persistence.api.entity.group.GVirAttr;
-import org.apache.syncope.core.persistence.api.entity.group.GVirAttrTemplate;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
 import org.apache.syncope.core.persistence.api.entity.user.UVirAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UVirSchema;
 import org.apache.syncope.core.persistence.api.entity.user.User;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.junit.Test;
@@ -55,9 +50,6 @@ public class VirAttrTest extends AbstractTest {
     private GroupDAO groupDAO;
 
     @Autowired
-    private MembershipDAO membershipDAO;
-
-    @Autowired
     private VirSchemaDAO virSchemaDAO;
 
     @Test
@@ -74,7 +66,7 @@ public class VirAttrTest extends AbstractTest {
 
     @Test
     public void saveUVirAttribute() {
-        UVirSchema virSchema = virSchemaDAO.find("virtualdata", UVirSchema.class);
+        VirSchema virSchema = virSchemaDAO.find("virtualdata");
         assertNotNull(virSchema);
 
         User owner = userDAO.find(3L);
@@ -92,33 +84,18 @@ public class VirAttrTest extends AbstractTest {
     }
 
     @Test
-    public void saveMVirAttribute() {
-        Membership owner = membershipDAO.find(3L);
-        assertNotNull("did not get expected membership", owner);
-
-        MVirAttr virAttr = entityFactory.newEntity(MVirAttr.class);
-        virAttr.setOwner(owner);
-        virAttr.setTemplate(owner.getGroup().getAttrTemplate(MVirAttrTemplate.class, "mvirtualdata"));
-
-        virAttr = virAttrDAO.save(virAttr);
-        assertNotNull(virAttr.getTemplate());
-
-        MVirAttr actual = virAttrDAO.find(virAttr.getKey(), MVirAttr.class);
-        assertNotNull("expected save to work", actual);
-        assertEquals(virAttr, actual);
-    }
+    public void saveGVirAttribute() {
+        VirSchema virSchema = virSchemaDAO.find("rvirtualdata");
+        assertNotNull(virSchema);
 
-    @Test
-    public void saveRVirAttribute() {
         Group owner = groupDAO.find(3L);
         assertNotNull("did not get expected membership", owner);
 
         GVirAttr virAttr = entityFactory.newEntity(GVirAttr.class);
         virAttr.setOwner(owner);
-        virAttr.setTemplate(owner.getAttrTemplate(GVirAttrTemplate.class, "rvirtualdata"));
+        virAttr.setSchema(virSchema);
 
         virAttr = virAttrDAO.save(virAttr);
-        assertNotNull(virAttr.getTemplate());
 
         GVirAttr actual = virAttrDAO.find(virAttr.getKey(), GVirAttr.class);
         assertNotNull("expected save to work", actual);
@@ -135,8 +112,7 @@ public class VirAttrTest extends AbstractTest {
         UVirAttr actual = virAttrDAO.find(1000L, UVirAttr.class);
         assertNull("delete did not work", actual);
 
-        UVirSchema attributeSchema = virSchemaDAO.find(attributeSchemaName, UVirSchema.class);
-
+        VirSchema attributeSchema = virSchemaDAO.find(attributeSchemaName);
         assertNotNull("user virtual attribute schema deleted " + "when deleting values", attributeSchema);
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirSchemaTest.java
index 919f787..3706f5f 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirSchemaTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/entity/VirSchemaTest.java
@@ -25,13 +25,10 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.util.List;
-import org.apache.syncope.common.lib.types.AttributableType;
 import org.apache.syncope.common.lib.types.EntityViolationType;
 import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
 import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
 import org.apache.syncope.core.persistence.api.entity.VirSchema;
-import org.apache.syncope.core.persistence.api.entity.group.GVirSchema;
-import org.apache.syncope.core.persistence.api.entity.user.UVirSchema;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,51 +42,51 @@ public class VirSchemaTest extends AbstractTest {
 
     @Test
     public void findAll() {
-        List<UVirSchema> list = virSchemaDAO.findAll(UVirSchema.class);
-        assertEquals(2, list.size());
+        List<VirSchema> list = virSchemaDAO.findAll();
+        assertEquals(4, list.size());
     }
 
     @Test
     public void findByName() {
-        UVirSchema attributeSchema = virSchemaDAO.find("virtualdata", UVirSchema.class);
+        VirSchema attributeSchema = virSchemaDAO.find("virtualdata");
         assertNotNull("did not find expected virtual attribute schema", attributeSchema);
     }
 
     @Test
     public void save() {
-        UVirSchema virtualAttributeSchema = entityFactory.newEntity(UVirSchema.class);
+        VirSchema virtualAttributeSchema = entityFactory.newEntity(VirSchema.class);
         virtualAttributeSchema.setKey("virtual");
         virtualAttributeSchema.setReadonly(true);
 
         virSchemaDAO.save(virtualAttributeSchema);
 
-        UVirSchema actual = virSchemaDAO.find("virtual", UVirSchema.class);
+        VirSchema actual = virSchemaDAO.find("virtual");
         assertNotNull("expected save to work", actual);
         assertTrue(actual.isReadonly());
     }
 
     @Test
     public void delete() {
-        UVirSchema virtualdata = virSchemaDAO.find("virtualdata", UVirSchema.class);
+        VirSchema virtualdata = virSchemaDAO.find("virtualdata");
 
-        virSchemaDAO.delete(virtualdata.getKey(), attrUtilsFactory.getInstance(AttributableType.USER));
+        virSchemaDAO.delete(virtualdata.getKey());
 
-        VirSchema actual = virSchemaDAO.find("virtualdata", UVirSchema.class);
+        VirSchema actual = virSchemaDAO.find("virtualdata");
         assertNull("delete did not work", actual);
 
         // ------------- //
-        GVirSchema rvirtualdata = virSchemaDAO.find("rvirtualdata", GVirSchema.class);
+        VirSchema rvirtualdata = virSchemaDAO.find("rvirtualdata");
         assertNotNull(rvirtualdata);
 
-        virSchemaDAO.delete(rvirtualdata.getKey(), attrUtilsFactory.getInstance(AttributableType.GROUP));
+        virSchemaDAO.delete(rvirtualdata.getKey());
 
-        actual = virSchemaDAO.find("rvirtualdata", GVirSchema.class);
+        actual = virSchemaDAO.find("rvirtualdata");
         assertNull("delete did not work", actual);
     }
 
     @Test
     public void issueSYNCOPE418() {
-        UVirSchema schema = entityFactory.newEntity(UVirSchema.class);
+        VirSchema schema = entityFactory.newEntity(VirSchema.class);
         schema.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
 
         try {

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AnySearchTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AnySearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AnySearchTest.java
new file mode 100644
index 0000000..b038222
--- /dev/null
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AnySearchTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.assertTrue;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.syncope.common.lib.SyncopeConstants;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.Entitlement;
+import org.apache.syncope.core.persistence.api.dao.GroupDAO;
+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.AnySearchDAO;
+import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
+import org.apache.syncope.core.persistence.api.dao.search.RoleCond;
+import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
+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.group.Group;
+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 AnySearchTest extends AbstractTest {
+
+    @Autowired
+    private GroupDAO groupDAO;
+
+    @Autowired
+    private AnySearchDAO searchDAO;
+
+    @Autowired
+    private RealmDAO realmDAO;
+
+    @Autowired
+    private RoleDAO roleDAO;
+
+    @Test
+    public void issueSYNCOPE95() {
+        Set<Group> groups = new HashSet<>(groupDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 100));
+        for (Group group : groups) {
+            groupDAO.delete(group.getKey());
+        }
+        groupDAO.flush();
+
+        AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.EQ);
+        coolLeafCond.setSchema("cool");
+        coolLeafCond.setExpression("true");
+
+        SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
+        assertTrue(cond.isValid());
+
+        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, AnyTypeKind.USER);
+        assertNotNull(users);
+        assertEquals(1, users.size());
+
+        assertEquals(4L, users.get(0).getKey(), 0);
+    }
+
+    @Test
+    public void searchByDynMembership() {
+        // 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 = roleDAO.save(role);
+        assertNotNull(role);
+
+        roleDAO.flush();
+
+        // 2. search user by this dynamic role
+        RoleCond roleCond = new RoleCond();
+        roleCond.setRoleKey(role.getKey());
+
+        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
+                SearchCond.getLeafCond(roleCond), AnyTypeKind.USER);
+        assertNotNull(users);
+        assertEquals(1, users.size());
+        assertEquals(4L, users.get(0).getKey(), 0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AttrTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AttrTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AttrTest.java
index 6c99465..ef500fe 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AttrTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/AttrTest.java
@@ -25,24 +25,18 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import org.apache.syncope.common.lib.SyncopeConstants;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.AttrSchemaType;
-import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.common.lib.types.CipherAlgorithm;
 import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
 import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
-import org.apache.syncope.core.persistence.api.dao.MembershipDAO;
 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.membership.MPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.membership.MPlainAttrTemplate;
-import org.apache.syncope.core.persistence.api.entity.membership.MPlainSchema;
-import org.apache.syncope.core.persistence.api.entity.membership.Membership;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrTemplate;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
+import org.apache.syncope.core.persistence.api.entity.PlainSchema;
 import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UDerSchema;
 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.User;
@@ -70,12 +64,6 @@ public class AttrTest extends AbstractTest {
     private DerSchemaDAO derSchemaDAO;
 
     @Autowired
-    private MembershipDAO membershipDAO;
-
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Autowired
     private UserDAO userDAO;
 
     @Test
@@ -106,48 +94,43 @@ public class AttrTest extends AbstractTest {
     @Test
     public void checkForEnumType() {
         User user = userDAO.find(1L);
-        Membership membership = user.getMembership(1L);
-        assertNotNull(membership);
+        user.setPassword("password123", CipherAlgorithm.SHA);
+        assertNotNull(user);
 
-        MPlainSchema schema = entityFactory.newEntity(MPlainSchema.class);
+        PlainSchema schema = entityFactory.newEntity(PlainSchema.class);
         schema.setType(AttrSchemaType.Enum);
         schema.setKey("color");
         schema.setEnumerationValues("red" + SyncopeConstants.ENUM_VALUES_SEPARATOR + "yellow");
 
-        MPlainSchema actualSchema = plainSchemaDAO.save(schema);
+        PlainSchema actualSchema = plainSchemaDAO.save(schema);
         assertNotNull(actualSchema);
 
-        MPlainAttrTemplate template = entityFactory.newEntity(MPlainAttrTemplate.class);
-        template.setSchema(actualSchema);
-        membership.getGroup().getAttrTemplates(MPlainAttrTemplate.class).add(template);
+        UPlainAttr attr = entityFactory.newEntity(UPlainAttr.class);
+        attr.setSchema(actualSchema);
+        attr.setOwner(user);
+        attr.add("yellow", anyUtilsFactory.getInstance(AnyTypeKind.USER));
+        user.add(attr);
 
-        MPlainAttr attr = entityFactory.newEntity(MPlainAttr.class);
-        attr.setTemplate(template);
-        attr.setOwner(membership);
-        attr.addValue("yellow", attrUtilsFactory.getInstance(AttributableType.MEMBERSHIP));
-        membership.addPlainAttr(attr);
+        userDAO.save(user);
+        userDAO.flush();
 
-        MPlainAttr actualAttribute = userDAO.save(user).getMembership(1L).getPlainAttr("color");
-        assertNotNull(actualAttribute);
-
-        membership = membershipDAO.find(1L);
-        assertNotNull(membership);
-        assertNotNull(membership.getPlainAttr(schema.getKey()));
-        assertNotNull(membership.getPlainAttr(schema.getKey()).getValues());
-
-        assertEquals(membership.getPlainAttr(schema.getKey()).getValues().size(), 1);
+        user = userDAO.find(1L);
+        assertNotNull(user);
+        assertNotNull(user.getPlainAttr(schema.getKey()));
+        assertNotNull(user.getPlainAttr(schema.getKey()).getValues());
+        assertEquals(user.getPlainAttr(schema.getKey()).getValues().size(), 1);
     }
 
     @Test
     public void derAttrFromSpecialAttrs() {
-        UDerSchema sderived = entityFactory.newEntity(UDerSchema.class);
+        DerSchema sderived = entityFactory.newEntity(DerSchema.class);
         sderived.setKey("sderived");
         sderived.setExpression("username + ' - ' + creationDate + '[' + failedLogins + ']'");
 
         sderived = derSchemaDAO.save(sderived);
         derSchemaDAO.flush();
 
-        UDerSchema actual = derSchemaDAO.find("sderived", UDerSchema.class);
+        DerSchema actual = derSchemaDAO.find("sderived");
         assertNotNull("expected save to work", actual);
         assertEquals(sderived, actual);
 
@@ -170,22 +153,4 @@ public class AttrTest extends AbstractTest {
         assertTrue(value.startsWith("vivaldi - 2010-10-20"));
         assertTrue(value.endsWith("[0]"));
     }
-
-    @Test
-    public void unmatchedGroupAttr() {
-        Group group = groupDAO.find(1L);
-        assertNotNull(group);
-
-        assertNotNull(group.getAttrTemplate(GPlainAttrTemplate.class, "icon"));
-        assertNotNull(group.getPlainAttr("icon"));
-
-        assertTrue(group.getAttrTemplates(GPlainAttrTemplate.class).
-                remove(group.getAttrTemplate(GPlainAttrTemplate.class, "icon")));
-
-        group = groupDAO.save(group);
-        groupDAO.flush();
-
-        assertNull(group.getAttrTemplate(GPlainAttrTemplate.class, "icon"));
-        assertNull(group.getPlainAttr("icon"));
-    }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ConnInstanceTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ConnInstanceTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ConnInstanceTest.java
index ce85dc5..34aaef5 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ConnInstanceTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/ConnInstanceTest.java
@@ -29,7 +29,7 @@ import org.apache.syncope.common.lib.types.ConnectorCapability;
 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.entity.ConnInstance;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/DerSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/DerSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/DerSchemaTest.java
index 92b016e..9448886 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/DerSchemaTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/DerSchemaTest.java
@@ -20,12 +20,11 @@ package org.apache.syncope.core.persistence.jpa.relationship;
 
 import static org.junit.Assert.assertNull;
 
-import org.apache.syncope.common.lib.types.AttributableType;
 import org.apache.syncope.core.persistence.api.dao.DerAttrDAO;
 import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.entity.DerSchema;
 import org.apache.syncope.core.persistence.api.entity.user.UDerAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UDerSchema;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,13 +44,13 @@ public class DerSchemaTest extends AbstractTest {
 
     @Test
     public void test() {
-        UDerSchema schema = derSchemaDAO.find("cn", UDerSchema.class);
+        DerSchema schema = derSchemaDAO.find("cn");
 
-        derSchemaDAO.delete(schema.getKey(), attrUtilsFactory.getInstance(AttributableType.USER));
+        derSchemaDAO.delete(schema.getKey());
 
         derSchemaDAO.flush();
 
-        assertNull(derSchemaDAO.find(schema.getKey(), UDerSchema.class));
+        assertNull(derSchemaDAO.find(schema.getKey()));
         assertNull(derAttrDAO.find(100L, UDerAttr.class));
         assertNull(userDAO.find(3L).getDerAttr(schema.getKey()));
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/GroupTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/GroupTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/GroupTest.java
index d6d99ce..4767422 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/GroupTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/GroupTest.java
@@ -32,7 +32,7 @@ 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.AttributableType;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
 import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO;
@@ -40,16 +40,14 @@ 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.RealmDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.DynGroupMembership;
 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainSchema;
 import org.apache.syncope.core.persistence.api.entity.group.Group;
+import org.apache.syncope.core.persistence.api.entity.user.UDynGroupMembership;
 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainSchema;
 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.JPADynGroupMembership;
+import org.apache.syncope.core.persistence.jpa.entity.user.JPAUDynGroupMembership;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -121,7 +119,7 @@ public class GroupTest extends AbstractTest {
         assertEquals(userDAO.findAllGroups(userDAO.find(2L)).size(), 2);
         assertNull(plainAttrDAO.find(700L, GPlainAttr.class));
         assertNull(plainAttrValueDAO.find(41L, GPlainAttrValue.class));
-        assertNotNull(plainSchemaDAO.find("icon", GPlainSchema.class));
+        assertNotNull(plainSchemaDAO.find("icon"));
     }
 
     /**
@@ -131,7 +129,7 @@ public class GroupTest extends AbstractTest {
      */
     private Collection<Group> findDynGroupMemberships(final User user) {
         TypedQuery<Group> query = entityManager.createQuery(
-                "SELECT e.group FROM " + JPADynGroupMembership.class.getSimpleName()
+                "SELECT e.group FROM " + JPAUDynGroupMembership.class.getSimpleName()
                 + " e WHERE :user MEMBER OF e.users", Group.class);
         query.setParameter("user", user);
 
@@ -146,10 +144,10 @@ public class GroupTest extends AbstractTest {
         user.setRealm(realmDAO.find("/even/two"));
 
         UPlainAttr attribute = entityFactory.newEntity(UPlainAttr.class);
-        attribute.setSchema(plainSchemaDAO.find("cool", UPlainSchema.class));
+        attribute.setSchema(plainSchemaDAO.find("cool"));
         attribute.setOwner(user);
-        attribute.addValue("true", attrUtilsFactory.getInstance(AttributableType.USER));
-        user.addPlainAttr(attribute);
+        attribute.add("true", anyUtilsFactory.getInstance(AnyTypeKind.USER));
+        user.add(attribute);
 
         user = userDAO.save(user);
         Long newUserKey = user.getKey();
@@ -160,11 +158,11 @@ public class GroupTest extends AbstractTest {
         group.setRealm(realmDAO.getRoot());
         group.setName("new");
 
-        DynGroupMembership dynMembership = entityFactory.newEntity(DynGroupMembership.class);
+        UDynGroupMembership dynMembership = entityFactory.newEntity(UDynGroupMembership.class);
         dynMembership.setFIQLCond("cool==true");
         dynMembership.setGroup(group);
 
-        group.setDynMembership(dynMembership);
+        group.setUDynMembership(dynMembership);
 
         Group actual = groupDAO.save(group);
         assertNotNull(actual);
@@ -174,14 +172,14 @@ public class GroupTest extends AbstractTest {
         // 2. verify that dynamic membership is there
         actual = groupDAO.find(actual.getKey());
         assertNotNull(actual);
-        assertNotNull(actual.getDynMembership());
-        assertNotNull(actual.getDynMembership().getKey());
-        assertEquals(actual, actual.getDynMembership().getGroup());
+        assertNotNull(actual.getUDynMembership());
+        assertNotNull(actual.getUDynMembership().getKey());
+        assertEquals(actual, actual.getUDynMembership().getGroup());
 
         // 3. verify that expected users have the created group dynamically assigned
-        assertEquals(2, actual.getDynMembership().getUsers().size());
+        assertEquals(2, actual.getUDynMembership().getMembers().size());
         assertEquals(new HashSet<>(Arrays.asList(4L, newUserKey)),
-                CollectionUtils.collect(actual.getDynMembership().getUsers(), new Transformer<User, Long>() {
+                CollectionUtils.collect(actual.getUDynMembership().getMembers(), new Transformer<User, Long>() {
 
                     @Override
                     public Long transform(final User input) {
@@ -193,7 +191,7 @@ public class GroupTest extends AbstractTest {
         assertNotNull(user);
         Collection<Group> dynGroupMemberships = findDynGroupMemberships(user);
         assertEquals(1, dynGroupMemberships.size());
-        assertTrue(dynGroupMemberships.contains(actual.getDynMembership().getGroup()));
+        assertTrue(dynGroupMemberships.contains(actual.getUDynMembership().getGroup()));
 
         // 4. delete the new user and verify that dynamic membership was updated
         userDAO.delete(newUserKey);
@@ -201,17 +199,17 @@ public class GroupTest extends AbstractTest {
         userDAO.flush();
 
         actual = groupDAO.find(actual.getKey());
-        assertEquals(1, actual.getDynMembership().getUsers().size());
-        assertEquals(4L, actual.getDynMembership().getUsers().get(0).getKey(), 0);
+        assertEquals(1, actual.getUDynMembership().getMembers().size());
+        assertEquals(4L, actual.getUDynMembership().getMembers().get(0).getKey(), 0);
 
         // 5. delete group and verify that dynamic membership was also removed
-        Long dynMembershipKey = actual.getDynMembership().getKey();
+        Long dynMembershipKey = actual.getUDynMembership().getKey();
 
         groupDAO.delete(actual);
 
         groupDAO.flush();
 
-        assertNull(entityManager.find(JPADynGroupMembership.class, dynMembershipKey));
+        assertNull(entityManager.find(JPAUDynGroupMembership.class, dynMembershipKey));
 
         dynGroupMemberships = findDynGroupMemberships(user);
         assertTrue(dynGroupMemberships.isEmpty());

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/MembershipTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/MembershipTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/MembershipTest.java
deleted file mode 100644
index 18fa39b..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/MembershipTest.java
+++ /dev/null
@@ -1,81 +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.assertTrue;
-
-import org.apache.syncope.core.persistence.api.dao.MembershipDAO;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.entity.membership.Membership;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-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 MembershipTest extends AbstractTest {
-
-    @Autowired
-    private MembershipDAO membershipDAO;
-
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Test
-    public void delete() {
-        Membership membership = membershipDAO.find(4L);
-        User user = membership.getUser();
-        Group group = membership.getGroup();
-
-        membershipDAO.delete(4L);
-
-        membershipDAO.flush();
-
-        for (Membership m : user.getMemberships()) {
-            assertTrue(m.getKey() != 4L);
-        }
-        for (Membership m : groupDAO.findMemberships(group)) {
-            assertTrue(m.getKey() != 4L);
-        }
-    }
-
-    @Test
-    public void deleteAndCreate() {
-        Membership membership = membershipDAO.find(3L);
-        User user = membership.getUser();
-        Group group = membership.getGroup();
-
-        // 1. delete that membership
-        membershipDAO.delete(membership.getKey());
-
-        // if not flushing here, the INSERT below will be executed
-        // before the DELETE above
-        membershipDAO.flush();
-
-        // 2. (in the same transaction) create new membership with same user
-        // and group (in order to check the UNIQE constraint on Membership)
-        membership = entityFactory.newEntity(Membership.class);
-        membership.setUser(user);
-        membership.setGroup(group);
-
-        membership = membershipDAO.save(membership);
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/PlainSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/PlainSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/PlainSchemaTest.java
index f697692..b92debb 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/PlainSchemaTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/PlainSchemaTest.java
@@ -26,15 +26,15 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.HashSet;
 import java.util.Set;
-import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
 import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
 import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.ExternalResource;
-import org.apache.syncope.core.persistence.api.entity.MappingItem;
+import org.apache.syncope.core.persistence.api.entity.PlainSchema;
+import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
+import org.apache.syncope.core.persistence.api.entity.resource.MappingItem;
 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainSchema;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +44,9 @@ import org.springframework.transaction.annotation.Transactional;
 public class PlainSchemaTest extends AbstractTest {
 
     @Autowired
+    private AnyTypeDAO anyTypeDAO;
+
+    @Autowired
     private UserDAO userDAO;
 
     @Autowired
@@ -57,25 +60,27 @@ public class PlainSchemaTest extends AbstractTest {
 
     @Test
     public void deleteFullname() {
-        // fullname is mapped as AccountId for ws-target-resource-2, need to swap it otherwise validation errors 
+        // fullname is mapped as ConnObjectKey for ws-target-resource-2, need to swap it otherwise validation errors 
         // will be raised
-        for (MappingItem item : resourceDAO.find("ws-target-resource-2").getUmapping().getItems()) {
+        for (MappingItem item : resourceDAO.find("ws-target-resource-2").
+                getProvision(anyTypeDAO.findUser()).getMapping().getItems()) {
+
             if ("fullname".equals(item.getIntAttrName())) {
-                item.setAccountid(false);
+                item.setConnObjectKey(false);
             } else if ("surname".equals(item.getIntAttrName())) {
-                item.setAccountid(true);
+                item.setConnObjectKey(true);
             }
         }
 
         // search for user schema fullname
-        UPlainSchema schema = plainSchemaDAO.find("fullname", UPlainSchema.class);
+        PlainSchema schema = plainSchemaDAO.find("fullname");
         assertNotNull(schema);
 
         // check for associated mappings
         Set<MappingItem> mapItems = new HashSet<>();
         for (ExternalResource resource : resourceDAO.findAll()) {
-            if (resource.getUmapping() != null) {
-                for (MappingItem mapItem : resource.getUmapping().getItems()) {
+            if (resource.getProvision(anyTypeDAO.findUser()).getMapping() != null) {
+                for (MappingItem mapItem : resource.getProvision(anyTypeDAO.findUser()).getMapping().getItems()) {
                     if (schema.getKey().equals(mapItem.getIntAttrName())) {
                         mapItems.add(mapItem);
                     }
@@ -85,12 +90,12 @@ public class PlainSchemaTest extends AbstractTest {
         assertFalse(mapItems.isEmpty());
 
         // delete user schema fullname
-        plainSchemaDAO.delete("fullname", attrUtilsFactory.getInstance(AttributableType.USER));
+        plainSchemaDAO.delete("fullname");
 
         plainSchemaDAO.flush();
 
         // check for schema deletion
-        schema = plainSchemaDAO.find("fullname", UPlainSchema.class);
+        schema = plainSchemaDAO.find("fullname");
         assertNull(schema);
 
         plainSchemaDAO.clear();
@@ -98,8 +103,8 @@ public class PlainSchemaTest extends AbstractTest {
         // check for mappings deletion
         mapItems = new HashSet<>();
         for (ExternalResource resource : resourceDAO.findAll()) {
-            if (resource.getUmapping() != null) {
-                for (MappingItem mapItem : resource.getUmapping().getItems()) {
+            if (resource.getProvision(anyTypeDAO.findUser()).getMapping() != null) {
+                for (MappingItem mapItem : resource.getProvision(anyTypeDAO.findUser()).getMapping().getItems()) {
                     if ("fullname".equals(mapItem.getIntAttrName())) {
                         mapItems.add(mapItem);
                     }
@@ -117,14 +122,14 @@ public class PlainSchemaTest extends AbstractTest {
     @Test
     public void deleteSurname() {
         // search for user schema fullname
-        UPlainSchema schema = plainSchemaDAO.find("surname", UPlainSchema.class);
+        PlainSchema schema = plainSchemaDAO.find("surname");
         assertNotNull(schema);
 
         // check for associated mappings
         Set<MappingItem> mappings = new HashSet<>();
         for (ExternalResource resource : resourceDAO.findAll()) {
-            if (resource.getUmapping() != null) {
-                for (MappingItem mapItem : resource.getUmapping().getItems()) {
+            if (resource.getProvision(anyTypeDAO.findUser()).getMapping() != null) {
+                for (MappingItem mapItem : resource.getProvision(anyTypeDAO.findUser()).getMapping().getItems()) {
                     if (schema.getKey().equals(mapItem.getIntAttrName())) {
                         mappings.add(mapItem);
                     }
@@ -134,24 +139,26 @@ public class PlainSchemaTest extends AbstractTest {
         assertFalse(mappings.isEmpty());
 
         // delete user schema fullname
-        plainSchemaDAO.delete("surname", attrUtilsFactory.getInstance(AttributableType.USER));
+        plainSchemaDAO.delete("surname");
 
         plainSchemaDAO.flush();
 
         // check for schema deletion
-        schema = plainSchemaDAO.find("surname", UPlainSchema.class);
+        schema = plainSchemaDAO.find("surname");
         assertNull(schema);
     }
 
     @Test
     public void deleteALong() {
-        assertEquals(6, resourceDAO.find("resource-db-sync").getUmapping().getItems().size());
+        assertEquals(6, resourceDAO.find("resource-db-sync").
+                getProvision(anyTypeDAO.findUser()).getMapping().getItems().size());
 
-        plainSchemaDAO.delete("aLong", attrUtilsFactory.getInstance(AttributableType.USER));
-        assertNull(plainSchemaDAO.find("aLong", UPlainSchema.class));
+        plainSchemaDAO.delete("aLong");
+        assertNull(plainSchemaDAO.find("aLong"));
 
         plainSchemaDAO.flush();
 
-        assertEquals(5, resourceDAO.find("resource-db-sync").getUmapping().getItems().size());
+        assertEquals(5, resourceDAO.find("resource-db-sync").
+                getProvision(anyTypeDAO.findUser()).getMapping().getItems().size());
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index 868f104..33e8669 100644
--- 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
@@ -32,21 +32,23 @@ 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.ExternalResource;
+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.group.GMappingItem;
+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.UMapping;
-import org.apache.syncope.core.persistence.api.entity.user.UMappingItem;
 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.group.JPAGMappingItem;
+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;
@@ -64,6 +66,9 @@ public class ResourceTest extends AbstractTest {
     private ConnInstanceDAO connInstanceDAO;
 
     @Autowired
+    private AnyTypeDAO anyTypeDAO;
+
+    @Autowired
     private UserDAO userDAO;
 
     @Autowired
@@ -109,43 +114,49 @@ public class ResourceTest extends AbstractTest {
 
         resource.setConnector(connector);
 
-        UMapping mapping = entityFactory.newEntity(UMapping.class);
-        mapping.setResource(resource);
-        resource.setUmapping(mapping);
+        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++) {
-            UMappingItem item = entityFactory.newEntity(UMappingItem.class);
+            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.addItem(item);
+            mapping.add(item);
             item.setMapping(mapping);
         }
-        UMappingItem accountId = entityFactory.newEntity(UMappingItem.class);
-        accountId.setExtAttrName("username");
-        accountId.setIntAttrName("username");
-        accountId.setIntMappingType(IntMappingType.UserId);
-        accountId.setPurpose(MappingPurpose.PROPAGATION);
-        mapping.setAccountIdItem(accountId);
-        accountId.setMapping(mapping);
+        MappingItem connObjectKey = entityFactory.newEntity(MappingItem.class);
+        connObjectKey.setExtAttrName("username");
+        connObjectKey.setIntAttrName("username");
+        connObjectKey.setIntMappingType(IntMappingType.UserId);
+        connObjectKey.setPurpose(MappingPurpose.PROPAGATION);
+        mapping.setConnObjectKeyItem(connObjectKey);
+        connObjectKey.setMapping(mapping);
 
         // map a derived attribute
-        UMappingItem derived = entityFactory.newEntity(UMappingItem.class);
-        derived.setAccountid(false);
+        MappingItem derived = entityFactory.newEntity(MappingItem.class);
+        derived.setConnObjectKey(false);
         derived.setExtAttrName("fullname");
         derived.setIntAttrName("cn");
         derived.setIntMappingType(IntMappingType.UserDerivedSchema);
         derived.setPurpose(MappingPurpose.PROPAGATION);
-        mapping.addItem(derived);
+        mapping.add(derived);
         derived.setMapping(mapping);
 
         // save the resource
         ExternalResource actual = resourceDAO.save(resource);
         assertNotNull(actual);
-        assertNotNull(actual.getUmapping());
+        assertNotNull(actual.getProvision(anyTypeDAO.findUser()).getMapping());
 
         resourceDAO.flush();
         resourceDAO.detach(actual);
@@ -155,13 +166,14 @@ public class ResourceTest extends AbstractTest {
         User user = userDAO.find(1L);
         assertNotNull("user not found", user);
 
-        user.addResource(actual);
+        user.add(actual);
 
         resourceDAO.flush();
 
         // retrieve resource
         resource = resourceDAO.find(actual.getKey());
         assertNotNull(resource);
+        resourceDAO.refresh(resource);
 
         // check connector
         connector = connInstanceDAO.find(100L);
@@ -172,7 +184,7 @@ public class ResourceTest extends AbstractTest {
         assertTrue(resource.getConnector().equals(connector));
 
         // check mappings
-        List<? extends UMappingItem> items = resource.getUmapping().getItems();
+        List<? extends MappingItem> items = resource.getProvision(anyTypeDAO.findUser()).getMapping().getItems();
         assertNotNull(items);
         assertEquals(5, items.size());
 
@@ -247,18 +259,18 @@ public class ResourceTest extends AbstractTest {
     public void emptyMapping() {
         ExternalResource ldap = resourceDAO.find("resource-ldap");
         assertNotNull(ldap);
-        assertNotNull(ldap.getUmapping());
-        assertNotNull(ldap.getGmapping());
+        assertNotNull(ldap.getProvision(anyTypeDAO.findUser()).getMapping());
+        assertNotNull(ldap.getProvision(anyTypeDAO.findGroup()).getMapping());
 
-        List<? extends GMappingItem> items = ldap.getGmapping().getItems();
+        List<? extends MappingItem> items = ldap.getProvision(anyTypeDAO.findGroup()).getMapping().getItems();
         assertNotNull(items);
         assertFalse(items.isEmpty());
-        List<Long> itemIds = new ArrayList<>(items.size());
-        for (GMappingItem item : items) {
-            itemIds.add(item.getKey());
+        List<Long> itemKeys = new ArrayList<>(items.size());
+        for (MappingItem item : items) {
+            itemKeys.add(item.getKey());
         }
 
-        ldap.setGmapping(null);
+        ldap.remove(ldap.getProvision(anyTypeDAO.findGroup()));
 
         // need to avoid any class not defined in this Maven module
         ldap.getPropagationActionsClassNames().clear();
@@ -266,8 +278,8 @@ public class ResourceTest extends AbstractTest {
         resourceDAO.save(ldap);
         resourceDAO.flush();
 
-        for (Long itemId : itemIds) {
-            assertNull(entityManager.find(JPAGMappingItem.class, itemId));
+        for (Long itemId : itemKeys) {
+            assertNull(entityManager.find(JPAMappingItem.class, itemId));
         }
     }
 
@@ -276,19 +288,19 @@ public class ResourceTest extends AbstractTest {
         ExternalResource csv = resourceDAO.find("resource-csv");
         assertNotNull(csv);
 
-        int origMapItems = csv.getUmapping().getItems().size();
+        int origMapItems = csv.getProvision(anyTypeDAO.findUser()).getMapping().getItems().size();
 
-        UMappingItem newMapItem = entityFactory.newEntity(UMappingItem.class);
+        MappingItem newMapItem = entityFactory.newEntity(MappingItem.class);
         newMapItem.setIntMappingType(IntMappingType.Username);
         newMapItem.setExtAttrName("TEST");
         newMapItem.setPurpose(MappingPurpose.PROPAGATION);
-        csv.getUmapping().addItem(newMapItem);
+        csv.getProvision(anyTypeDAO.findUser()).getMapping().add(newMapItem);
 
         resourceDAO.save(csv);
         resourceDAO.flush();
 
         csv = resourceDAO.find("resource-csv");
         assertNotNull(csv);
-        assertEquals(origMapItems + 1, csv.getUmapping().getItems().size());
+        assertEquals(origMapItems + 1, csv.getProvision(anyTypeDAO.findUser()).getMapping().getItems().size());
     }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index 52e3451..5f2504b 100644
--- 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
@@ -30,19 +30,18 @@ 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.AttributableType;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
 import org.apache.syncope.common.lib.types.Entitlement;
 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.DynRoleMembership;
+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.UPlainSchema;
 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.JPADynRoleMembership;
+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;
@@ -87,10 +86,10 @@ public class RoleTest extends AbstractTest {
         user.setRealm(realmDAO.find("/even/two"));
 
         UPlainAttr attribute = entityFactory.newEntity(UPlainAttr.class);
-        attribute.setSchema(plainSchemaDAO.find("cool", UPlainSchema.class));
+        attribute.setSchema(plainSchemaDAO.find("cool"));
         attribute.setOwner(user);
-        attribute.addValue("true", attrUtilsFactory.getInstance(AttributableType.USER));
-        user.addPlainAttr(attribute);
+        attribute.add("true", anyUtilsFactory.getInstance(AnyTypeKind.USER));
+        user.add(attribute);
 
         user = userDAO.save(user);
         Long newUserKey = user.getKey();
@@ -123,9 +122,9 @@ public class RoleTest extends AbstractTest {
         assertEquals(actual, actual.getDynMembership().getRole());
 
         // 3. verify that expected users have the created role dynamically assigned
-        assertEquals(2, actual.getDynMembership().getUsers().size());
+        assertEquals(2, actual.getDynMembership().getMembers().size());
         assertEquals(new HashSet<>(Arrays.asList(4L, newUserKey)),
-                CollectionUtils.collect(actual.getDynMembership().getUsers(), new Transformer<User, Long>() {
+                CollectionUtils.collect(actual.getDynMembership().getMembers(), new Transformer<User, Long>() {
 
                     @Override
                     public Long transform(final User input) {
@@ -145,8 +144,8 @@ public class RoleTest extends AbstractTest {
         userDAO.flush();
 
         actual = roleDAO.find(actual.getKey());
-        assertEquals(1, actual.getDynMembership().getUsers().size());
-        assertEquals(4L, actual.getDynMembership().getUsers().get(0).getKey(), 0);
+        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();

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SubjectSearchTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SubjectSearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SubjectSearchTest.java
deleted file mode 100644
index 025d7cc..0000000
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/relationship/SubjectSearchTest.java
+++ /dev/null
@@ -1,115 +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.assertTrue;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.types.Entitlement;
-import org.apache.syncope.common.lib.types.SubjectType;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-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.SubjectSearchDAO;
-import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
-import org.apache.syncope.core.persistence.api.dao.search.RoleCond;
-import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.apache.syncope.core.persistence.api.entity.DynRoleMembership;
-import org.apache.syncope.core.persistence.api.entity.Role;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-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 SubjectSearchTest extends AbstractTest {
-
-    @Autowired
-    private GroupDAO groupDAO;
-
-    @Autowired
-    private SubjectSearchDAO searchDAO;
-
-    @Autowired
-    private RealmDAO realmDAO;
-
-    @Autowired
-    private RoleDAO roleDAO;
-
-    @Test
-    public void issueSYNCOPE95() {
-        Set<Group> groups = new HashSet<>(groupDAO.findAll(SyncopeConstants.FULL_ADMIN_REALMS, 1, 100));
-        for (Group group : groups) {
-            groupDAO.delete(group.getKey());
-        }
-        groupDAO.flush();
-
-        AttributeCond coolLeafCond = new AttributeCond(AttributeCond.Type.EQ);
-        coolLeafCond.setSchema("cool");
-        coolLeafCond.setExpression("true");
-
-        SearchCond cond = SearchCond.getLeafCond(coolLeafCond);
-        assertTrue(cond.isValid());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS, cond, SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-
-        assertEquals(4L, users.get(0).getKey(), 0);
-    }
-
-    @Test
-    public void searchByDynMembership() {
-        // 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 = roleDAO.save(role);
-        assertNotNull(role);
-
-        roleDAO.flush();
-
-        // 2. search user by this dynamic role
-        RoleCond roleCond = new RoleCond();
-        roleCond.setRoleKey(role.getKey());
-
-        List<User> users = searchDAO.search(SyncopeConstants.FULL_ADMIN_REALMS,
-                SearchCond.getLeafCond(roleCond), SubjectType.USER);
-        assertNotNull(users);
-        assertEquals(1, users.size());
-        assertEquals(4L, users.get(0).getKey(), 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index e795a95..76621a1 100644
--- 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
@@ -28,7 +28,7 @@ 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.AttributableType;
+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;
@@ -40,11 +40,12 @@ 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.ExternalResource;
+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;
@@ -89,10 +90,10 @@ public class TaskTest extends AbstractTest {
 
         PropagationTask task = entityFactory.newEntity(PropagationTask.class);
         task.setResource(resource);
-        task.setSubjectType(AttributableType.USER);
+        task.setAnyTypeKind(AnyTypeKind.USER);
         task.setPropagationMode(PropagationMode.TWO_PHASES);
         task.setPropagationOperation(ResourceOperation.CREATE);
-        task.setAccountId("one@two.com");
+        task.setConnObjectKey("one@two.com");
 
         Set<Attribute> attributes = new HashSet<>();
         attributes.add(AttributeBuilder.build("testAttribute", "testValue1", "testValue2"));
@@ -207,10 +208,13 @@ public class TaskTest extends AbstractTest {
         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.setUserTemplate(new UserTO());
+        task.add(template);
         task.setCronExpression("BLA BLA");
         task.setMatchingRule(MatchingRule.UPDATE);
         task.setUnmatchingRule(UnmatchingRule.PROVISION);

http://git-wip-us.apache.org/repos/asf/syncope/blob/081d9a04/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
index ccfa33d..f038917 100644
--- 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
@@ -28,10 +28,9 @@ 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.membership.Membership;
+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.UPlainSchema;
 import org.apache.syncope.core.persistence.jpa.AbstractTest;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -64,9 +63,9 @@ public class UserTest extends AbstractTest {
         assertNull(userDAO.find(4L));
         assertNull(plainAttrDAO.find(550L, UPlainAttr.class));
         assertNull(plainAttrValueDAO.find(22L, UPlainAttrValue.class));
-        assertNotNull(plainSchemaDAO.find("loginDate", UPlainSchema.class));
+        assertNotNull(plainSchemaDAO.find("loginDate"));
 
-        List<Membership> memberships = groupDAO.findMemberships(groupDAO.find(7L));
+        List<UMembership> memberships = groupDAO.findUMemberships(groupDAO.find(7L));
         assertTrue(memberships.isEmpty());
     }
 }


Mime
View raw message