syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [10/24] syncope git commit: [SYNCOPE-822] UUID keys
Date Tue, 19 Apr 2016 13:01:57 GMT
http://git-wip-us.apache.org/repos/asf/syncope/blob/550ee4f4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceTest.java
index 8d94adb..d536d66 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/ResourceTest.java
@@ -84,12 +84,12 @@ public class ResourceTest extends AbstractTest {
     public void createWithPasswordPolicy() {
         final String resourceName = "resourceWithPasswordPolicy";
 
-        PasswordPolicy policy = (PasswordPolicy) policyDAO.find(4L);
+        PasswordPolicy policy = policyDAO.find("986d1236-3ac5-4a19-810c-5ab21d79cba1");
         ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
         resource.setKey(resourceName);
         resource.setPasswordPolicy(policy);
 
-        ConnInstance connector = connInstanceDAO.find(100L);
+        ConnInstance connector = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
         assertNotNull("connector not found", connector);
         resource.setConnector(connector);
 
@@ -103,7 +103,7 @@ public class ResourceTest extends AbstractTest {
         resourceDAO.delete(resourceName);
         assertNull(resourceDAO.find(resourceName));
 
-        assertNotNull(policyDAO.find(4L));
+        assertNotNull(policyDAO.find("986d1236-3ac5-4a19-810c-5ab21d79cba1"));
     }
 
     @Test
@@ -112,7 +112,7 @@ public class ResourceTest extends AbstractTest {
         resource.setKey("ws-target-resource-save");
 
         // specify the connector
-        ConnInstance connector = connInstanceDAO.find(100L);
+        ConnInstance connector = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
         assertNotNull("connector not found", connector);
 
         resource.setConnector(connector);
@@ -166,7 +166,7 @@ public class ResourceTest extends AbstractTest {
         connInstanceDAO.detach(connector);
 
         // assign the new resource to an user
-        User user = userDAO.find(1L);
+        User user = userDAO.findByUsername("rossini");
         assertNotNull("user not found", user);
 
         user.add(actual);
@@ -179,7 +179,7 @@ public class ResourceTest extends AbstractTest {
         resourceDAO.refresh(resource);
 
         // check connector
-        connector = connInstanceDAO.find(100L);
+        connector = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
         assertNotNull(connector);
         assertNotNull(connector.getResources());
 
@@ -192,7 +192,7 @@ public class ResourceTest extends AbstractTest {
         assertEquals(5, items.size());
 
         // check user
-        user = userDAO.find(1L);
+        user = userDAO.findByUsername("rossini");
         assertNotNull(user);
         assertNotNull(user.getResources());
         assertTrue(user.getResources().contains(actual));
@@ -216,9 +216,9 @@ public class ResourceTest extends AbstractTest {
         List<User> users = userDAO.findByResource(resource);
         assertNotNull(users);
 
-        Set<Long> userIds = new HashSet<>();
+        Set<String> userKeys = new HashSet<>();
         for (User user : users) {
-            userIds.add(user.getKey());
+            userKeys.add(user.getKey());
         }
         // -------------------------------------
 
@@ -238,8 +238,8 @@ public class ResourceTest extends AbstractTest {
         assertNull("delete did not work", actual);
 
         // resource must be not referenced any more from users
-        for (Long id : userIds) {
-            User actualUser = userDAO.find(id);
+        for (String key : userKeys) {
+            User actualUser = userDAO.find(key);
             assertNotNull(actualUser);
             for (ExternalResource res : userDAO.findAllResources(actualUser)) {
                 assertFalse(res.getKey().equalsIgnoreCase(resource.getKey()));
@@ -269,7 +269,7 @@ public class ResourceTest extends AbstractTest {
         List<? extends MappingItem> items = ldap.getProvision(anyTypeDAO.findGroup()).getMapping().getItems();
         assertNotNull(items);
         assertFalse(items.isEmpty());
-        List<Long> itemKeys = new ArrayList<>(items.size());
+        List<String> itemKeys = new ArrayList<>(items.size());
         for (MappingItem item : items) {
             itemKeys.add(item.getKey());
         }
@@ -286,7 +286,7 @@ public class ResourceTest extends AbstractTest {
         resourceDAO.save(ldap);
         resourceDAO.flush();
 
-        for (Long itemKey : itemKeys) {
+        for (String itemKey : itemKeys) {
             assertNull(entityManager().find(JPAMappingItem.class, itemKey));
         }
     }

http://git-wip-us.apache.org/repos/asf/syncope/blob/550ee4f4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
index 544a470..04d3e39 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/RoleTest.java
@@ -83,7 +83,7 @@ public class RoleTest extends AbstractTest {
         // 0. create user matching the condition below
         User user = entityFactory.newEntity(User.class);
         user.setUsername("username");
-        user.setRealm(realmDAO.find("/even/two"));
+        user.setRealm(realmDAO.findByFullPath("/even/two"));
         user.add(anyTypeClassDAO.find("other"));
 
         UPlainAttr attr = entityFactory.newEntity(UPlainAttr.class);
@@ -93,14 +93,14 @@ public class RoleTest extends AbstractTest {
         user.add(attr);
 
         user = userDAO.save(user);
-        Long newUserKey = user.getKey();
+        String newUserKey = user.getKey();
         assertNotNull(newUserKey);
 
         // 1. create role with dynamic membership
         Role role = entityFactory.newEntity(Role.class);
         role.setKey("new");
         role.add(realmDAO.getRoot());
-        role.add(realmDAO.find("/even/two"));
+        role.add(realmDAO.findByFullPath("/even/two"));
         role.getEntitlements().add(StandardEntitlement.LOG_LIST);
         role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
 
@@ -124,12 +124,12 @@ public class RoleTest extends AbstractTest {
 
         // 3. verify that expected users have the created role dynamically assigned
         assertEquals(2, actual.getDynMembership().getMembers().size());
-        assertEquals(new HashSet<>(Arrays.asList(4L, newUserKey)),
+        assertEquals(new HashSet<>(Arrays.asList("c9b2dec2-00a7-4855-97c0-d854842b4b24",
newUserKey)),
                 CollectionUtils.collect(actual.getDynMembership().getMembers(),
-                        EntityUtils.<Long, User>keyTransformer(),
-                        new HashSet<Long>()));
+                        EntityUtils.<User>keyTransformer(),
+                        new HashSet<String>()));
 
-        user = userDAO.find(4L);
+        user = userDAO.find("c9b2dec2-00a7-4855-97c0-d854842b4b24");
         assertNotNull(user);
         Collection<Role> dynRoleMemberships = findDynRoleMemberships(user);
         assertEquals(1, dynRoleMemberships.size());
@@ -142,10 +142,10 @@ public class RoleTest extends AbstractTest {
 
         actual = roleDAO.find(actual.getKey());
         assertEquals(1, actual.getDynMembership().getMembers().size());
-        assertEquals(4L, actual.getDynMembership().getMembers().get(0).getKey(), 0);
+        assertEquals("c9b2dec2-00a7-4855-97c0-d854842b4b24", actual.getDynMembership().getMembers().get(0).getKey());
 
         // 5. delete role and verify that dynamic membership was also removed
-        Long dynMembershipKey = actual.getDynMembership().getKey();
+        String dynMembershipKey = actual.getDynMembership().getKey();
 
         roleDAO.delete(actual);
 
@@ -163,7 +163,7 @@ public class RoleTest extends AbstractTest {
         Role role = entityFactory.newEntity(Role.class);
         role.setKey("new");
         role.add(realmDAO.getRoot());
-        role.add(realmDAO.find("/even/two"));
+        role.add(realmDAO.findByFullPath("/even/two"));
         role.getEntitlements().add(StandardEntitlement.LOG_LIST);
         role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
 
@@ -173,7 +173,7 @@ public class RoleTest extends AbstractTest {
         // 1. create user and assign that role
         User user = entityFactory.newEntity(User.class);
         user.setUsername("username");
-        user.setRealm(realmDAO.find("/even/two"));
+        user.setRealm(realmDAO.findByFullPath("/even/two"));
         user.add(role);
 
         user = userDAO.save(user);

http://git-wip-us.apache.org/repos/asf/syncope/blob/550ee4f4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/SecurityQuestionTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/SecurityQuestionTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/SecurityQuestionTest.java
index 14c463c..84a8a31 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/SecurityQuestionTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/SecurityQuestionTest.java
@@ -39,21 +39,21 @@ public class SecurityQuestionTest extends AbstractTest {
 
     @Test
     public void test() {
-        User user = userDAO.find(4L);
+        User user = userDAO.findByUsername("bellini");
         assertNull(user.getSecurityQuestion());
         assertNull(user.getSecurityAnswer());
 
-        user.setSecurityQuestion(securityQuestionDAO.find(1L));
+        user.setSecurityQuestion(securityQuestionDAO.find("887028ea-66fc-41e7-b397-620d7ea6dfbb"));
         user.setSecurityAnswer("Rossi");
         userDAO.save(user);
 
         userDAO.flush();
 
-        securityQuestionDAO.delete(1L);
+        securityQuestionDAO.delete("887028ea-66fc-41e7-b397-620d7ea6dfbb");
 
         userDAO.flush();
 
-        user = userDAO.find(4L);
+        user = userDAO.findByUsername("bellini");
 
         assertNull(user.getSecurityQuestion());
         assertNull(user.getSecurityAnswer());

http://git-wip-us.apache.org/repos/asf/syncope/blob/550ee4f4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/TaskTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/TaskTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/TaskTest.java
index 715188d..fc47959 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/TaskTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/TaskTest.java
@@ -59,164 +59,164 @@ import org.apache.syncope.core.provisioning.api.pushpull.PullActions;
 
 @Transactional("Master")
 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);
+        PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
         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);
+        
+        User user = userDAO.findByUsername("verdi");
         assertNotNull(user);
-
+        
         PropagationTask task = entityFactory.newEntity(PropagationTask.class);
         task.setResource(resource);
         task.setAnyTypeKind(AnyTypeKind.USER);
         task.setAnyType(AnyTypeKind.USER.name());
         task.setOperation(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(
                 TaskType.PROPAGATION, resource, null, null, null, -1, -1, Collections.<OrderByClause>emptyList()).
                 contains(task));
     }
-
+    
     @Test
     public void addPropagationTaskExecution() {
-        PropagationTask task = taskDAO.find(1L);
+        PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
         assertNotNull(task);
-
+        
         int executionNumber = task.getExecs().size();
-
+        
         TaskExec execution = entityFactory.newEntity(TaskExec.class);
         execution.setTask(task);
         execution.setStatus(PropagationTaskExecStatus.CREATED.name());
         execution.setStart(new Date());
         task.add(execution);
-
+        
         taskDAO.save(task);
         taskDAO.flush();
-
-        task = taskDAO.find(1L);
+        
+        task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
         assertNotNull(task);
-
+        
         assertEquals(executionNumber + 1, task.getExecs().size());
     }
-
+    
     @Test
     public void addPullTaskExecution() {
-        PullTask task = taskDAO.find(4L);
+        PullTask task = taskDAO.find("c41b9b71-9bfa-4f90-89f2-84787def4c5c");
         assertNotNull(task);
-
+        
         int executionNumber = task.getExecs().size();
-
+        
         TaskExec execution = entityFactory.newEntity(TaskExec.class);
         execution.setStatus("Text-free status");
         execution.setTask(task);
         execution.setStart(new Date());
         execution.setMessage("A message");
         task.add(execution);
-
+        
         taskDAO.save(task);
         taskDAO.flush();
-
-        task = taskDAO.find(4L);
+        
+        task = taskDAO.find("c41b9b71-9bfa-4f90-89f2-84787def4c5c");
         assertNotNull(task);
-
+        
         assertEquals(executionNumber + 1, task.getExecs().size());
     }
-
+    
     @Test
     public void addPushTaskExecution() {
-        PushTask task = taskDAO.find(13L);
+        PushTask task = taskDAO.find("af558be4-9d2f-4359-bf85-a554e6e90be1");
         assertNotNull(task);
-
+        
         int executionNumber = task.getExecs().size();
-
+        
         TaskExec execution = entityFactory.newEntity(TaskExec.class);
         execution.setStatus("Text-free status");
         execution.setTask(task);
         execution.setStart(new Date());
         execution.setMessage("A message");
         task.add(execution);
-
+        
         taskDAO.save(task);
         taskDAO.flush();
-
-        task = taskDAO.find(13L);
+        
+        task = taskDAO.find("af558be4-9d2f-4359-bf85-a554e6e90be1");
         assertNotNull(task);
-
+        
         assertEquals(executionNumber + 1, task.getExecs().size());
     }
-
+    
     @Test
     public void deleteTask() {
-        taskDAO.delete(1L);
-
+        taskDAO.delete("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
+        
         taskDAO.flush();
-
-        assertNull(taskDAO.find(1L));
-        assertNull(taskExecDAO.find(1L));
+        
+        assertNull(taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c"));
+        assertNull(taskExecDAO.find("e58ca1c7-178a-4012-8a71-8aa14eaf0655"));
     }
-
+    
     @Test
     public void deleteTaskExecution() {
-        TaskExec execution = taskExecDAO.find(1L);
+        TaskExec execution = taskExecDAO.find("e58ca1c7-178a-4012-8a71-8aa14eaf0655");
         int executionNumber = execution.getTask().getExecs().size();
-
-        taskExecDAO.delete(1L);
-
+        
+        taskExecDAO.delete("e58ca1c7-178a-4012-8a71-8aa14eaf0655");
+        
         taskExecDAO.flush();
-
-        assertNull(taskExecDAO.find(1L));
-
-        PropagationTask task = taskDAO.find(1L);
+        
+        assertNull(taskExecDAO.find("e58ca1c7-178a-4012-8a71-8aa14eaf0655"));
+        
+        PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
         assertEquals(task.getExecs().size(), executionNumber - 1);
     }
-
+    
     @Test
     public void savePullTask() {
         ExternalResource resource = resourceDAO.find("ws-target-resource-1");
         assertNotNull(resource);
-
+        
         AnyTemplatePullTask template = entityFactory.newEntity(AnyTemplatePullTask.class);
         template.set(new UserTO());
-
+        
         PullTask task = entityFactory.newEntity(PullTask.class);
         task.setName("savePullTask");
         task.setDescription("PullTask description");
@@ -235,7 +235,7 @@ public class TaskTest extends AbstractTest {
             exception = e;
         }
         assertNotNull(exception);
-
+        
         task.setCronExpression(null);
         // this save() fails because a PullTask requires a target resource
         exception = null;
@@ -245,7 +245,7 @@ public class TaskTest extends AbstractTest {
             exception = e;
         }
         assertNotNull(exception);
-
+        
         task.setResource(resource);
         task.getActionsClassNames().add(getClass().getName());
 
@@ -258,24 +258,24 @@ public class TaskTest extends AbstractTest {
             exception = e;
         }
         assertNotNull(exception);
-
+        
         task.getActionsClassNames().clear();
         task.getActionsClassNames().add(PullActions.class.getName());
         // this save() finally works
         task = taskDAO.save(task);
         assertNotNull(task);
-
+        
         PullTask actual = taskDAO.find(task.getKey());
         assertEquals(task, actual);
     }
-
+    
     @Test
     public void issueSYNCOPE144() {
         ExternalResource resource = resourceDAO.find("ws-target-resource-1");
         assertNotNull(resource);
-
+        
         PullTask task = entityFactory.newEntity(PullTask.class);
-
+        
         task.setResource(resource);
         task.setName("issueSYNCOPE144");
         task.setDescription("issueSYNCOPE144 Description");
@@ -284,22 +284,22 @@ public class TaskTest extends AbstractTest {
         task.getActionsClassNames().add(PullActions.class.getName());
         task.setMatchingRule(MatchingRule.UPDATE);
         task.setUnmatchingRule(UnmatchingRule.PROVISION);
-
+        
         task = taskDAO.save(task);
         assertNotNull(task);
-
+        
         PullTask 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/550ee4f4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/UserTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/UserTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/UserTest.java
index 695f406..1a5a62d 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/UserTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/UserTest.java
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.List;
+import java.util.UUID;
 import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
 import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
 import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
@@ -73,65 +74,75 @@ public class UserTest extends AbstractTest {
 
     @Test
     public void delete() {
-        List<UMembership> memberships = groupDAO.findUMemberships(groupDAO.find(7L));
+        List<UMembership> memberships = groupDAO.findUMemberships(groupDAO.findByName("managingDirector"));
         assertFalse(memberships.isEmpty());
-        List<URelationship> relationships = anyObjectDAO.findURelationships(anyObjectDAO.find(1L));
+        List<URelationship> relationships = anyObjectDAO.findURelationships(
+                anyObjectDAO.find("fc6dbc3a-6c07-4965-8781-921e7401a4a5"));
         assertFalse(relationships.isEmpty());
 
-        userDAO.delete(4L);
+        userDAO.delete("c9b2dec2-00a7-4855-97c0-d854842b4b24");
 
         userDAO.flush();
 
-        assertNull(userDAO.find(4L));
-        assertNull(plainAttrDAO.find(550L, UPlainAttr.class));
-        assertNull(plainAttrValueDAO.find(22L, UPlainAttrValue.class));
+        assertNull(userDAO.findByUsername("bellini"));
+        assertNull(plainAttrDAO.find(UUID.randomUUID().toString(), UPlainAttr.class));
+        assertNull(plainAttrValueDAO.find(UUID.randomUUID().toString(), UPlainAttrValue.class));
         assertNotNull(plainSchemaDAO.find("loginDate"));
 
-        memberships = groupDAO.findUMemberships(groupDAO.find(7L));
+        memberships = groupDAO.findUMemberships(groupDAO.findByName("managingDirector"));
         assertTrue(memberships.isEmpty());
-        relationships = anyObjectDAO.findURelationships(anyObjectDAO.find(1L));
+        relationships = anyObjectDAO.findURelationships(
+                anyObjectDAO.find("fc6dbc3a-6c07-4965-8781-921e7401a4a5"));
         assertTrue(relationships.isEmpty());
     }
 
     @Test
     public void ships() {
-        User user = userDAO.find(4L);
+        User user = userDAO.findByUsername("bellini");
         assertNotNull(user);
         assertEquals(1, user.getMemberships().size());
-        assertEquals(7L, user.getMemberships().get(0).getRightEnd().getKey(), 0);
+        assertEquals(
+                "bf825fe1-7320-4a54-bd64-143b5c18ab97",
+                user.getMemberships().get(0).getRightEnd().getKey());
 
         user.getMemberships().remove(0);
 
         UMembership newM = entityFactory.newEntity(UMembership.class);
         newM.setLeftEnd(user);
-        newM.setRightEnd(groupDAO.find(13L));
+        newM.setRightEnd(groupDAO.find("ba9ed509-b1f5-48ab-a334-c8530a6422dc"));
         user.add(newM);
 
         userDAO.save(user);
 
         userDAO.flush();
 
-        user = userDAO.find(4L);
+        user = userDAO.findByUsername("bellini");
         assertEquals(1, user.getMemberships().size());
-        assertEquals(13L, user.getMemberships().get(0).getRightEnd().getKey(), 0);
+        assertEquals(
+                "ba9ed509-b1f5-48ab-a334-c8530a6422dc",
+                user.getMemberships().get(0).getRightEnd().getKey());
         assertEquals(1, user.getRelationships().size());
-        assertEquals(1L, user.getRelationships().get(0).getRightEnd().getKey(), 0);
+        assertEquals(
+                "fc6dbc3a-6c07-4965-8781-921e7401a4a5",
+                user.getRelationships().get(0).getRightEnd().getKey());
 
         user.getRelationships().remove(0);
 
         URelationship newR = entityFactory.newEntity(URelationship.class);
         newR.setType(relationshipTypeDAO.find("neighborhood"));
         newR.setLeftEnd(user);
-        newR.setRightEnd(anyObjectDAO.find(2L));
+        newR.setRightEnd(anyObjectDAO.find("8559d14d-58c2-46eb-a2d4-a7d35161e8f8"));
         user.add(newR);
 
         userDAO.save(user);
 
         userDAO.flush();
 
-        user = userDAO.find(4L);
+        user = userDAO.findByUsername("bellini");
         assertEquals(1, user.getRelationships().size());
-        assertEquals(2L, user.getRelationships().get(0).getRightEnd().getKey(), 0);
+        assertEquals(
+                "8559d14d-58c2-46eb-a2d4-a7d35161e8f8",
+                user.getRelationships().get(0).getRightEnd().getKey());
     }
 
     @Test // search by derived attribute
@@ -141,7 +152,7 @@ public class UserTest extends AbstractTest {
         prefix.setKey("kprefix");
         prefix.setExpression("'k' + firstname");
 
-        prefix = derSchemaDAO.save(prefix);
+        derSchemaDAO.save(prefix);
         derSchemaDAO.flush();
 
         // create derived attribute (literal as suffix)
@@ -149,11 +160,11 @@ public class UserTest extends AbstractTest {
         suffix.setKey("ksuffix");
         suffix.setExpression("firstname + 'k'");
 
-        suffix = derSchemaDAO.save(suffix);
+        derSchemaDAO.save(suffix);
         derSchemaDAO.flush();
 
         // add derived attributes to user
-        User owner = userDAO.find(3L);
+        User owner = userDAO.findByUsername("vivaldi");
         assertNotNull("did not get expected user", owner);
 
         String firstname = owner.getPlainAttr("firstname").getValuesAsStrings().iterator().next();

http://git-wip-us.apache.org/repos/asf/syncope/blob/550ee4f4/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/VirSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/VirSchemaTest.java
b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/VirSchemaTest.java
index bd68313..334f4a8 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/VirSchemaTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/outer/VirSchemaTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.UUID;
 import org.apache.syncope.common.lib.types.IntMappingType;
 import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
 import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
@@ -45,7 +46,7 @@ public class VirSchemaTest extends AbstractTest {
 
     @Test
     public void deal() {
-        Provision provision = resourceDAO.findProvision(15L);
+        Provision provision = resourceDAO.findProvision("209ea85f-f964-49c7-a498-6c9c2baa3bd8");
         assertNotNull(provision);
         assertTrue(virSchemaDAO.findByProvision(provision).isEmpty());
 
@@ -63,7 +64,7 @@ public class VirSchemaTest extends AbstractTest {
         assertTrue(virSchema.isReadonly());
         assertEquals("EXT_ATTR", virSchema.getExtAttrName());
 
-        provision = resourceDAO.findProvision(15L);
+        provision = resourceDAO.findProvision("209ea85f-f964-49c7-a498-6c9c2baa3bd8");
         assertNotNull(provision);
         assertFalse(virSchemaDAO.findByProvision(provision).isEmpty());
         assertTrue(virSchemaDAO.findByProvision(provision).contains(virSchema));

http://git-wip-us.apache.org/repos/asf/syncope/blob/550ee4f4/core/persistence-jpa/src/test/resources/META-INF/persistence-enhance.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/META-INF/persistence-enhance.xml b/core/persistence-jpa/src/test/resources/META-INF/persistence-enhance.xml
deleted file mode 100644
index 6b72247..0000000
--- a/core/persistence-jpa/src/test/resources/META-INF/persistence-enhance.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
-             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
-                                 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
-             version="2.0">
-  
-  <persistence-unit name="Master">
-    <mapping-file>META-INF/spring-orm.xml</mapping-file>
-    <validation-mode>NONE</validation-mode>    
-  </persistence-unit>
-  
-</persistence>


Mime
View raw message