Author: [email protected]
Date: Wed Aug 17 10:59:43 2011
New Revision: 1332

Log:
AMDATU-407 Fixed and added test to cover it

Modified:
   
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProvider.java
   
trunk/amdatu-core/useradminstore-fs/src/test/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProviderTest.java

Modified: 
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProvider.java
==============================================================================
--- 
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProvider.java
 (original)
+++ 
trunk/amdatu-core/useradminstore-fs/src/main/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProvider.java
 Wed Aug 17 10:59:43 2011
@@ -237,8 +237,19 @@
                 filter = FrameworkUtil.createFilter(filterString);
             }
             for (FSRole internalRole : internalRoles) {
-                if (filter == null || 
filter.match(internalRole.getProperties())) {
-                    matchingRoles.add(internalRole);
+                if (filter == null || 
filter.match(internalRole.getProperties())) {
+                    if (internalRole.getType() == Role.USER) {
+                        User newuser =
+                            
userAdminFactory.createUser(internalRole.getName(), 
dictionaryToMap(internalRole.getProperties()),
+                                dictionaryToMap(((User) 
internalRole).getCredentials()));
+                        matchingRoles.add(newuser);
+                    }
+                    else if (internalRole.getType() == Role.GROUP) {
+                        Group newgroup =
+                            
userAdminFactory.createGroup(internalRole.getName(), 
dictionaryToMap(internalRole.getProperties()),
+                                dictionaryToMap(((Group) 
internalRole).getCredentials()));
+                        matchingRoles.add(newgroup);
+                    }
                 }
             }
         }

Modified: 
trunk/amdatu-core/useradminstore-fs/src/test/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProviderTest.java
==============================================================================
--- 
trunk/amdatu-core/useradminstore-fs/src/test/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProviderTest.java
     (original)
+++ 
trunk/amdatu-core/useradminstore-fs/src/test/java/org/amdatu/core/useradminstore/fs/service/FSUserAdminStorageProviderTest.java
     Wed Aug 17 10:59:43 2011
@@ -22,6 +22,7 @@
 
 import junit.framework.Assert;
 
+import org.amdatu.core.useradminstore.fs.service.mock.MockRole;
 import org.amdatu.core.useradminstore.fs.service.mock.MockUserAdminFactory;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -237,6 +238,12 @@
         // AMDATU-404 check that null filter return all roles
         Collection<Role> matches4 = 
m_userAdminStorageProvider.findRoles(m_userAdminFactory, null);
         Assert.assertEquals("Find returned unexpected amount of roles", 2, 
matches4.size());
+        
+        // AMDATU-407 check that returned roles are created by factory
+        Collection<Role> matches5 = 
m_userAdminStorageProvider.findRoles(m_userAdminFactory, null);
+        for(Role match : matches5){
+            Assert.assertTrue("Roles returned are no created using provided 
factory", MockRole.class.isAssignableFrom(match.getClass()));
+        }
     }
 
     @Test
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to