You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2013/11/27 14:46:16 UTC

svn commit: r1546033 - in /syncope/trunk: ./ core/src/main/java/org/apache/syncope/core/connid/ core/src/main/java/org/apache/syncope/core/util/ core/src/test/java/org/apache/syncope/core/rest/

Author: fmartelli
Date: Wed Nov 27 13:46:15 2013
New Revision: 1546033

URL: http://svn.apache.org/r1546033
Log:
Fixes SYNCOPE-442 even onto the trunk

Added:
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java
      - copied, changed from r1546016, syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java
Modified:
    syncope/trunk/   (props changed)
    syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCache.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCacheValue.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_1_X:r1545714-1546016

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java Wed Nov 27 13:46:15 2013
@@ -63,6 +63,7 @@ import org.apache.syncope.core.util.Jexl
 import org.apache.syncope.core.util.MappingUtil;
 import org.apache.syncope.core.util.SecureRandomUtil;
 import org.apache.syncope.core.util.VirAttrCache;
+import org.apache.syncope.core.util.VirAttrCacheValue;
 import org.identityconnectors.common.security.GuardedByteArray;
 import org.identityconnectors.common.security.GuardedString;
 import org.identityconnectors.framework.common.objects.Attribute;
@@ -516,15 +517,22 @@ public class ConnObjectUtil {
             final ConnectorFactory connFactory) {
 
         final String schemaName = virAttr.getSchema().getName();
-        final List<String> values = virAttrCache.get(attrUtil.getType(), owner.getId(), schemaName);
+        final VirAttrCacheValue virAttrCacheValue = virAttrCache.get(attrUtil.getType(), owner.getId(), schemaName);
 
         LOG.debug("Retrieve values for virtual attribute {} ({})", schemaName, type);
 
-        if (values == null) {
-            // non cached ...
+        if (virAttrCache.isValidEntry(virAttrCacheValue)) {
+            // cached ...
+            LOG.debug("Values found in cache {}", virAttrCacheValue);
+            virAttr.setValues(new ArrayList<String>(virAttrCacheValue.getValues()));
+        } else {
+            // not cached ...
             LOG.debug("Need one or more remote connections");
+
+            final VirAttrCacheValue toBeCached = new VirAttrCacheValue();
+
             for (ExternalResource resource : getTargetResource(virAttr, type, attrUtil)) {
-                LOG.debug("Seach values into {}", resource.getName());
+                LOG.debug("Search values into {}", resource.getName());
                 try {
                     final List<AbstractMappingItem> mappings = attrUtil.getMappingItems(resource, MappingPurpose.BOTH);
 
@@ -569,19 +577,28 @@ public class ConnObjectUtil {
                                 }
                             }
                         }
-                    }
 
-                    LOG.debug("Retrieved values {}", virAttr.getValues());
+                        toBeCached.setResourceValues(resource.getName(), new HashSet<String>(virAttr.getValues()));
+
+                        LOG.debug("Retrieved values {}", virAttr.getValues());
+                    }
                 } catch (Exception e) {
                     LOG.error("Error reading connector object from {}", resource.getName(), e);
+
+                    if (virAttrCacheValue != null) {
+                        toBeCached.forceExpiring();
+                        LOG.debug("Search for a cached value (even expired!) ...");
+                        final Set<String> cachedValues = virAttrCacheValue.getValues(resource.getName());
+                        if (cachedValues != null) {
+                            LOG.debug("Use cached value {}", cachedValues);
+                            virAttr.getValues().addAll(cachedValues);
+                            toBeCached.setResourceValues(resource.getName(), new HashSet<String>(cachedValues));
+                        }
+                    }
                 }
             }
 
-            virAttrCache.put(attrUtil.getType(), owner.getId(), schemaName, virAttr.getValues());
-        } else {
-            // cached ...
-            LOG.debug("Values found in cache {}", values);
-            virAttr.setValues(values);
+            virAttrCache.put(attrUtil.getType(), owner.getId(), schemaName, toBeCached);
         }
     }
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCache.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCache.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCache.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCache.java Wed Nov 27 13:46:15 2013
@@ -21,7 +21,6 @@ package org.apache.syncope.core.util;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.apache.syncope.common.types.AttributableType;
@@ -59,14 +58,18 @@ public final class VirAttrCache {
      * @param schemaName virtual attribute name
      * @param values virtual attribute values
      */
-    public void put(final AttributableType type, final Long id, final String schemaName, final List<String> values) {
+    public void put(
+            final AttributableType type,
+            final Long id,
+            final String schemaName,
+            final VirAttrCacheValue value) {
         synchronized (cache) {
             // this operations (retrieve cache space and put entry on) have to be thread safe.
             if (this.cache.size() >= this.maxCacheSize) {
                 free();
             }
 
-            cache.put(new VirAttrCacheKey(type, id, schemaName), new VirAttrCacheValue(values));
+            cache.put(new VirAttrCacheKey(type, id, schemaName), value);
         }
     }
 
@@ -76,11 +79,10 @@ public final class VirAttrCache {
      * @param type user or role
      * @param id user or role id
      * @param schemaName virtual attribute schema name.
-     * @return cached values or null in case of virtual attribute not found.
+     * @return cached values or null if virtual attribute is not cached.
      */
-    public List<String> get(final AttributableType type, final Long id, final String schemaName) {
-        final VirAttrCacheValue value = cache.get(new VirAttrCacheKey(type, id, schemaName));
-        return isValidEntry(value) ? value.getValues() : null;
+    public VirAttrCacheValue get(final AttributableType type, final Long id, final String schemaName) {
+        return cache.get(new VirAttrCacheKey(type, id, schemaName));
     }
 
     /**
@@ -134,7 +136,7 @@ public final class VirAttrCache {
      * @param value cache entry value.
      * @return TRUE if the value is valid; FALSE otherwise.
      */
-    private boolean isValidEntry(final VirAttrCacheValue value) {
+    public boolean isValidEntry(final VirAttrCacheValue value) {
         final Date expiringDate = new Date(value == null ? 0 : value.getCreationDate().getTime() + ttl * 1000);
         return expiringDate.after(new Date());
     }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCacheValue.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCacheValue.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCacheValue.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/VirAttrCacheValue.java Wed Nov 27 13:46:15 2013
@@ -19,7 +19,10 @@
 package org.apache.syncope.core.util;
 
 import java.util.Date;
-import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * Cache entry value.
@@ -29,7 +32,7 @@ public class VirAttrCacheValue {
     /**
      * Virtual attribute values.
      */
-    private final List<String> values;
+    private final Map<String, Set<String>> values;
 
     /**
      * Entry creation date.
@@ -41,10 +44,14 @@ public class VirAttrCacheValue {
      */
     private Date lastAccessDate;
 
-    public VirAttrCacheValue(final List<String> values) {
-        this.values = values;
+    public VirAttrCacheValue() {
         this.creationDate = new Date();
         this.lastAccessDate = new Date();
+        values = new HashMap<String, Set<String>>();
+    }
+
+    public void setResourceValues(final String resourceName, final Set<String> values) {
+        this.values.put(resourceName, values);
     }
 
     public Date getCreationDate() {
@@ -55,8 +62,18 @@ public class VirAttrCacheValue {
         creationDate = new Date(0);
     }
 
-    public List<String> getValues() {
-        return values;
+    public Set<String> getValues(final String resourceName) {
+        return values.get(resourceName);
+    }
+
+    public Set<String> getValues() {
+        final Set<String> res = new HashSet<String>();
+
+        for (Set<String> value : values.values()) {
+            res.addAll(value);
+        }
+
+        return res;
     }
 
     public Date getLastAccessDate() {

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Wed Nov 27 13:46:15 2013
@@ -49,9 +49,10 @@ import org.apache.syncope.common.service
 import org.apache.syncope.common.services.UserService;
 import org.apache.syncope.common.services.UserWorkflowService;
 import org.apache.syncope.common.services.WorkflowService;
+import org.apache.syncope.common.to.AbstractPolicyTO;
 import org.apache.syncope.common.to.AbstractSchemaTO;
 import org.apache.syncope.common.to.AttributeTO;
-import org.apache.syncope.common.to.AbstractPolicyTO;
+import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
@@ -68,7 +69,7 @@ import org.springframework.test.context.
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:testJDBCContext.xml" })
+@ContextConfiguration(locations = {"classpath:testJDBCContext.xml"})
 public abstract class AbstractTest {
 
     /**
@@ -86,12 +87,48 @@ public abstract class AbstractTest {
 
     protected static final SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean().setAddress(ADDRESS);
 
+    protected static final String RESOURCE_NAME_WS1 = "ws-target-resource-1";
+
+    protected static final String RESOURCE_NAME_WS2 = "ws-target-resource-2";
+
     protected static final String RESOURCE_NAME_LDAP = "resource-ldap";
 
     protected static final String RESOURCE_NAME_TESTDB = "resource-testdb";
 
+    protected static final String RESOURCE_NAME_TESTDB2 = "resource-testdb2";
+
     protected static final String RESOURCE_NAME_CSV = "resource-csv";
 
+    protected static final String RESOURCE_NAME_DBSYNC = "resource-db-sync";
+
+    protected static final String RESOURCE_NAME_DBVIRATTR = "resource-db-virattr";
+
+    protected static final String RESOURCE_NAME_NOPROPAGATION = "ws-target-resource-nopropagation";
+
+    protected static final String RESOURCE_NAME_NOPROPAGATION2 = "ws-target-resource-nopropagation2";
+
+    protected static final String RESOURCE_NAME_NOPROPAGATION3 = "ws-target-resource-nopropagation3";
+
+    protected static final String RESOURCE_NAME_NOPROPAGATION4 = "ws-target-resource-nopropagation4";
+
+    protected static final String RESOURCE_NAME_RESETSYNCTOKEN = "ws-target-resource-update-resetsynctoken";
+
+    protected static final String RESOURCE_NAME_TIMEOUT = "ws-target-resource-timeout";
+
+    protected static final String RESOURCE_NAME_MAPPINGS1 = "ws-target-resource-list-mappings-1";
+
+    protected static final String RESOURCE_NAME_MAPPINGS2 = "ws-target-resource-list-mappings-2";
+
+    protected static final String RESOURCE_NAME_CREATE = "ws-target-resource-create";
+
+    protected static final String RESOURCE_NAME_CREATE_SINGLE = "ws-target-resource-create-single";
+
+    protected static final String RESOURCE_NAME_CREATE_WRONG = "ws-target-resource-create-wrong";
+
+    protected static final String RESOURCE_NAME_DELETE = "ws-target-resource-delete";
+
+    protected static final String RESOURCE_NAME_UPDATE = "ws-target-resource-update";
+
     protected static String ANONYMOUS_UNAME;
 
     protected static String ANONYMOUS_KEY;
@@ -178,6 +215,10 @@ public abstract class AbstractTest {
         schemaService = adminClient.getService(SchemaService.class);
     }
 
+//    protected ConnObjectTO readConnectorObject(final String resourceName, final Long userId, AttributableType type) {
+//        return resourceService.getConnectorObject(resourceName, type, userId);
+//    }
+
     protected static String getUUIDString() {
         return UUID.randomUUID().toString().substring(0, 8);
     }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java Wed Nov 27 13:46:15 2013
@@ -169,7 +169,7 @@ public class LoggerTestITCase extends Ab
         found = false;
         for (EventCategoryTO eventCategoryTO : events) {
             if (AttributableType.USER.name().toLowerCase().equals(eventCategoryTO.getCategory())) {
-                if ("resource-ldap".equals(eventCategoryTO.getSubcategory())
+                if (RESOURCE_NAME_LDAP.equals(eventCategoryTO.getSubcategory())
                         && EventCategoryType.SYNCHRONIZATION == eventCategoryTO.getType()) {
                     assertTrue(eventCategoryTO.getEvents().contains(ResourceOperation.CREATE.name().toLowerCase()));
                     assertTrue(eventCategoryTO.getEvents().contains(ResourceOperation.UPDATE.name().toLowerCase()));
@@ -183,7 +183,7 @@ public class LoggerTestITCase extends Ab
         found = false;
         for (EventCategoryTO eventCategoryTO : events) {
             if (AttributableType.USER.name().toLowerCase().equals(eventCategoryTO.getCategory())) {
-                if ("resource-csv".equals(eventCategoryTO.getSubcategory())
+                if (RESOURCE_NAME_CSV.equals(eventCategoryTO.getSubcategory())
                         && EventCategoryType.PROPAGATION == eventCategoryTO.getType()) {
                     assertTrue(eventCategoryTO.getEvents().contains(ResourceOperation.CREATE.name().toLowerCase()));
                     assertTrue(eventCategoryTO.getEvents().contains(ResourceOperation.UPDATE.name().toLowerCase()));

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java Wed Nov 27 13:46:15 2013
@@ -97,7 +97,7 @@ public class ResourceTestITCase extends 
 
     @Test
     public void create() {
-        String resourceName = "ws-target-resource-create";
+        String resourceName = RESOURCE_NAME_CREATE;
         ResourceTO resourceTO = buildResourceTO(resourceName);
 
         Response response = resourceService.create(resourceTO);
@@ -166,7 +166,7 @@ public class ResourceTestITCase extends 
 
     @Test
     public void createWithSingleMappingItem() {
-        String resourceName = "ws-target-resource-create-single";
+        String resourceName = RESOURCE_NAME_CREATE_SINGLE;
         ResourceTO resourceTO = new ResourceTO();
         resourceTO.setName(resourceName);
         resourceTO.setConnectorId(102L);
@@ -205,7 +205,7 @@ public class ResourceTestITCase extends 
 
     @Test
     public void createWithInvalidMapping() {
-        String resourceName = "ws-target-resource-create-wrong";
+        String resourceName = RESOURCE_NAME_CREATE_WRONG;
         ResourceTO resourceTO = new ResourceTO();
         resourceTO.setName(resourceName);
         resourceTO.setConnectorId(102L);
@@ -236,7 +236,7 @@ public class ResourceTestITCase extends 
 
     @Test(expected = SyncopeClientException.class)
     public void createWithoutExtAttr() {
-        String resourceName = "ws-target-resource-create-wrong";
+        String resourceName = RESOURCE_NAME_CREATE_WRONG;
         ResourceTO resourceTO = new ResourceTO();
         resourceTO.setName(resourceName);
         resourceTO.setConnectorId(102L);
@@ -304,7 +304,7 @@ public class ResourceTestITCase extends 
 
     @Test
     public void update() {
-        String resourceName = "ws-target-resource-update";
+        String resourceName = RESOURCE_NAME_UPDATE;
         ResourceTO resourceTO = new ResourceTO();
         resourceTO.setName(resourceName);
         resourceTO.setConnectorId(101L);
@@ -361,7 +361,7 @@ public class ResourceTestITCase extends 
     @Test
     public void updateResetSyncToken() {
         // create resource with sync token
-        String resourceName = "ws-target-resource-update-resetsynctoken" + getUUIDString();
+        String resourceName = RESOURCE_NAME_RESETSYNCTOKEN + getUUIDString();
         ResourceTO pre = buildResourceTO(resourceName);
         pre.setUsyncToken("test");
         resourceService.create(pre);
@@ -414,13 +414,13 @@ public class ResourceTestITCase extends 
 
     @Test
     public void read() {
-        ResourceTO actual = resourceService.read("resource-testdb");
+        ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
         assertNotNull(actual);
     }
 
     @Test
     public void issueSYNCOPE323() {
-        ResourceTO actual = resourceService.read("resource-testdb");
+        ResourceTO actual = resourceService.read(RESOURCE_NAME_TESTDB);
         assertNotNull(actual);
 
         try {

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java Wed Nov 27 13:46:15 2013
@@ -71,14 +71,10 @@ public class RoleTestITCase extends Abst
         roleTO.getRAttrTemplates().add("icon");
         roleTO.getAttrs().add(attributeTO("icon", "anIcon"));
 
-        roleTO.getResources().add("resource-ldap");
+        roleTO.getResources().add(RESOURCE_NAME_LDAP);
         return roleTO;
     }
 
-    private ConnObjectTO readConnectorObject(final String resourceName, final Long roleId) {
-        return resourceService.getConnectorObject(resourceName, AttributableType.ROLE, roleId);
-    }
-
     @Test
     public void createWithException() {
         RoleTO newRoleTO = new RoleTO();
@@ -113,9 +109,10 @@ public class RoleTestITCase extends Abst
         assertNotNull(roleTO.getPasswordPolicy());
         assertEquals(4L, (long) roleTO.getPasswordPolicy());
 
-        assertTrue(roleTO.getResources().contains("resource-ldap"));
+        assertTrue(roleTO.getResources().contains(RESOURCE_NAME_LDAP));
 
-        ConnObjectTO connObjectTO = readConnectorObject("resource-ldap", roleTO.getId());
+        ConnObjectTO connObjectTO =
+                resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, roleTO.getId());
         assertNotNull(connObjectTO);
         assertNotNull(connObjectTO.getAttrMap().get("owner"));
     }
@@ -148,7 +145,7 @@ public class RoleTestITCase extends Abst
         roleTO.setName("toBeDeleted" + getUUIDString());
         roleTO.setParent(8L);
 
-        roleTO.getResources().add("resource-ldap");
+        roleTO.getResources().add(RESOURCE_NAME_LDAP);
 
         roleTO = createRole(roleTO);
         assertNotNull(roleTO);
@@ -395,7 +392,7 @@ public class RoleTestITCase extends Abst
         RoleTO actual = createRole(buildRoleTO("unlink"));
         assertNotNull(actual);
 
-        assertNotNull(readConnectorObject("resource-ldap", actual.getId()));
+        assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, actual.getId()));
 
         actual = roleService.associate(actual.getId(),
                 ResourceAssociationActionType.UNLINK,
@@ -409,7 +406,7 @@ public class RoleTestITCase extends Abst
 
         assertTrue(actual.getResources().isEmpty());
 
-        assertNotNull(readConnectorObject("resource-ldap", actual.getId()));
+        assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, actual.getId()));
     }
 
     @Test
@@ -417,7 +414,7 @@ public class RoleTestITCase extends Abst
         RoleTO actual = createRole(buildRoleTO("unassign"));
         assertNotNull(actual);
 
-        assertNotNull(readConnectorObject("resource-ldap", actual.getId()));
+        assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, actual.getId()));
 
         actual = roleService.associate(actual.getId(),
                 ResourceAssociationActionType.UNASSIGN,
@@ -431,7 +428,7 @@ public class RoleTestITCase extends Abst
         assertTrue(actual.getResources().isEmpty());
 
         try {
-            readConnectorObject("resource-ldap", actual.getId());
+            resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, actual.getId());
             fail();
         } catch (Exception e) {
             assertNotNull(e);
@@ -443,7 +440,7 @@ public class RoleTestITCase extends Abst
         RoleTO actual = createRole(buildRoleTO("deprovision"));
         assertNotNull(actual);
 
-        assertNotNull(readConnectorObject("resource-ldap", actual.getId()));
+        assertNotNull(resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, actual.getId()));
 
         actual = roleService.associate(actual.getId(),
                 ResourceAssociationActionType.DEPROVISION,
@@ -457,7 +454,7 @@ public class RoleTestITCase extends Abst
         assertFalse(actual.getResources().isEmpty());
 
         try {
-            readConnectorObject("resource-ldap", actual.getId());
+            resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.ROLE, actual.getId());
             fail();
         } catch (Exception e) {
             assertNotNull(e);

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SearchTestITCase.java Wed Nov 27 13:46:15 2013
@@ -135,7 +135,7 @@ public class SearchTestITCase extends Ab
         ws2.setResourceName("ws-target-resource2");
 
         ResourceCond ws1 = new ResourceCond();
-        ws1.setResourceName("ws-target-resource-list-mappings-2");
+        ws1.setResourceName(RESOURCE_NAME_MAPPINGS2);
 
         NodeCond searchCondition = NodeCond.getAndCond(NodeCond.getNotLeafCond(ws2), NodeCond.getLeafCond(ws1));
 

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Wed Nov 27 13:46:15 2013
@@ -107,17 +107,18 @@ public class TaskTestITCase extends Abst
     public void create() {
         SyncTaskTO task = new SyncTaskTO();
         task.setName("Test create Sync");
-        task.setResource("ws-target-resource-2");
+        task.setResource(RESOURCE_NAME_WS2);
 
         UserTO userTemplate = new UserTO();
-        userTemplate.getResources().add("ws-target-resource-2");
+        userTemplate.getResources().add(RESOURCE_NAME_WS2);
+
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(8L);
         userTemplate.getMemberships().add(membershipTO);
         task.setUserTemplate(userTemplate);
 
         RoleTO roleTemplate = new RoleTO();
-        roleTemplate.getResources().add("resource-ldap");
+        roleTemplate.getResources().add(RESOURCE_NAME_LDAP);
         task.setRoleTemplate(roleTemplate);
 
         Response response = taskService.create(task);
@@ -275,7 +276,7 @@ public class TaskTestITCase extends Abst
             template.getAttrs().add(attributeTO("type",
                     "email == 'test8@syncope.apache.org'? 'TYPE_8': 'TYPE_OTHER'"));
             template.getDerAttrs().add(attributeTO("cn", null));
-            template.getResources().add("resource-testdb");
+            template.getResources().add(RESOURCE_NAME_TESTDB);
 
             MembershipTO membershipTO = new MembershipTO();
             membershipTO.setRoleId(8L);
@@ -307,8 +308,8 @@ public class TaskTestITCase extends Abst
             assertNotNull(userTO);
             assertEquals("TYPE_OTHER", userTO.getAttrMap().get("type").getValues().get(0));
             assertEquals(2, userTO.getResources().size());
-            assertTrue(userTO.getResources().contains("resource-testdb"));
-            assertTrue(userTO.getResources().contains("ws-target-resource-2"));
+            assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
+            assertTrue(userTO.getResources().contains(RESOURCE_NAME_WS2));
             assertEquals(1, userTO.getMemberships().size());
             assertTrue(userTO.getMemberships().get(0).getAttrMap().containsKey("subscriptionDate"));
 
@@ -394,7 +395,7 @@ public class TaskTestITCase extends Abst
 
         //  add user template
         final UserTO userTemplate = task.getUserTemplate();
-        userTemplate.getResources().add("resource-ldap");
+        userTemplate.getResources().add(RESOURCE_NAME_LDAP);
         userTemplate.getVirAttrs().add(attributeTO("virtualReadOnly", ""));
 
         task.setUserTemplate(userTemplate);
@@ -601,8 +602,8 @@ public class TaskTestITCase extends Abst
         userTO.getAttrs().add(attributeTO("userId", "testuser2@syncope.apache.org"));
         userTO.getAttrs().add(attributeTO("email", "testuser2@syncope.apache.org"));
 
-        userTO.getResources().add("ws-target-resource-nopropagation2");
-        userTO.getResources().add("ws-target-resource-nopropagation4");
+        userTO.getResources().add(RESOURCE_NAME_NOPROPAGATION2);
+        userTO.getResources().add(RESOURCE_NAME_NOPROPAGATION4);
 
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(7L);
@@ -627,7 +628,7 @@ public class TaskTestITCase extends Abst
 
             template.getMemberships().add(membershipTO);
 
-            template.getResources().add("ws-target-resource-nopropagation4");
+            template.getResources().add(RESOURCE_NAME_NOPROPAGATION4);
             //-----------------------------
 
             // Update sync task
@@ -753,7 +754,7 @@ public class TaskTestITCase extends Abst
 
         // create user with testdb resource
         UserTO userTO = UserTestITCase.getUniqueSampleTO("syncope272@syncope.apache.org");
-        userTO.getResources().add("resource-testdb");
+        userTO.getResources().add(RESOURCE_NAME_TESTDB);
 
         userTO = createUser(userTO);
         try {
@@ -775,7 +776,7 @@ public class TaskTestITCase extends Abst
             template.getAttrs().add(attributeTO("userId", "'test'"));
             template.getAttrs().add(attributeTO("fullname", "'test'"));
             template.getAttrs().add(attributeTO("surname", "'test'"));
-            template.getResources().add("resource-testdb");
+            template.getResources().add(RESOURCE_NAME_TESTDB);
 
             task.setUserTemplate(template);
 
@@ -812,7 +813,7 @@ public class TaskTestITCase extends Abst
 
         SyncTaskTO task = new SyncTaskTO();
         task.setName("Test Sync Rule");
-        task.setResource("ws-target-resource-2");
+        task.setResource(RESOURCE_NAME_WS2);
         task.setFullReconciliation(true);
         task.setPerformCreate(true);
         task.setPerformDelete(true);
@@ -824,13 +825,13 @@ public class TaskTestITCase extends Abst
 
         UserTO userTO = UserTestITCase.getUniqueSampleTO("s258_1@apache.org");
         userTO.getResources().clear();
-        userTO.getResources().add("ws-target-resource-2");
+        userTO.getResources().add(RESOURCE_NAME_WS2);
 
-        userTO = createUser(userTO);
+        createUser(userTO);
 
         userTO = UserTestITCase.getUniqueSampleTO("s258_2@apache.org");
         userTO.getResources().clear();
-        userTO.getResources().add("ws-target-resource-2");
+        userTO.getResources().add(RESOURCE_NAME_WS2);
 
         userTO = createUser(userTO);
 
@@ -861,8 +862,8 @@ public class TaskTestITCase extends Abst
         userTO.getDerAttrs().add(csvuserid);
 
         userTO.getResources().clear();
-        userTO.getResources().add("ws-target-resource-2");
-        userTO.getResources().add("resource-csv");
+        userTO.getResources().add(RESOURCE_NAME_WS2);
+        userTO.getResources().add(RESOURCE_NAME_CSV);
 
         userTO = createUser(userTO);
         assertNotNull(userTO);
@@ -876,7 +877,7 @@ public class TaskTestITCase extends Abst
 
         //  add user template
         UserTO template = new UserTO();
-        template.getResources().add("resource-db-virattr");
+        template.getResources().add(RESOURCE_NAME_DBVIRATTR);
 
         AttributeTO userId = attributeTO("userId", "'s307@apache.org'");
         template.getAttrs().add(userId);
@@ -910,7 +911,7 @@ public class TaskTestITCase extends Abst
 
         // create user with testdb resource
         final UserTO userTO = UserTestITCase.getUniqueSampleTO("taskBulk@apache.org");
-        userTO.getResources().add("resource-testdb");
+        userTO.getResources().add(RESOURCE_NAME_TESTDB);
         createUser(userTO);
 
         final List<PropagationTaskTO> after = new ArrayList<PropagationTaskTO>(

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1546033&r1=1546032&r2=1546033&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Wed Nov 27 13:46:15 2013
@@ -33,7 +33,6 @@ import java.util.Date;
 import java.util.List;
 
 import javax.ws.rs.core.Response;
-import org.apache.commons.lang3.SerializationUtils;
 
 import org.apache.syncope.common.mod.AttributeMod;
 import org.apache.syncope.common.mod.MembershipMod;
@@ -49,7 +48,6 @@ import org.apache.syncope.common.to.Bulk
 import org.apache.syncope.common.to.ConfigurationTO;
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.to.MappingItemTO;
-import org.apache.syncope.common.to.MappingTO;
 import org.apache.syncope.common.to.MembershipTO;
 import org.apache.syncope.common.to.PasswordPolicyTO;
 import org.apache.syncope.common.to.PropagationStatusTO;
@@ -60,8 +58,6 @@ import org.apache.syncope.common.to.Role
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.CipherAlgorithm;
-import org.apache.syncope.common.types.IntMappingType;
-import org.apache.syncope.common.types.MappingPurpose;
 import org.apache.syncope.common.types.PolicyType;
 import org.apache.syncope.common.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.types.ClientExceptionType;
@@ -143,7 +139,7 @@ public class UserTestITCase extends Abst
         UserTO userTO = getUniqueSampleTO("xxx@xxx.xxx");
 
         userTO.setPassword("password123");
-        userTO.getResources().add("ws-target-resource-nopropagation");
+        userTO.getResources().add(RESOURCE_NAME_NOPROPAGATION);
 
         createUser(userTO);
 
@@ -203,7 +199,7 @@ public class UserTestITCase extends Abst
         UserMod userMod = new UserMod();
         userMod.setId(userTO.getId());
         userMod.setPassword("newPassword");
-        userMod.getResourcesToAdd().add("ws-target-resource-2");
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_WS2);
 
         try {
             userTO = updateUser(userMod);
@@ -217,7 +213,7 @@ public class UserTestITCase extends Abst
         userMod = new UserMod();
         userMod.setId(userTO.getId());
         userMod.setPassword("newPassword");
-        userMod.getResourcesToAdd().add("ws-target-resource-1");
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_WS1);
 
         userTO = updateUser(userMod);
         assertNotNull(userTO.getPropagationStatusTOs().get(0).getFailureReason());
@@ -240,7 +236,7 @@ public class UserTestITCase extends Abst
     @Test
     public void testEnforceMandatoryCondition() {
         UserTO userTO = getUniqueSampleTO("enforce@apache.org");
-        userTO.getResources().add("ws-target-resource-2");
+        userTO.getResources().add(RESOURCE_NAME_WS2);
         userTO.setPassword("newPassword");
 
         AttributeTO type = null;
@@ -329,9 +325,7 @@ public class UserTestITCase extends Abst
 
         // configured to be minLength=16
         userTO.setPassword("password1");
-
-        userTO.getResources().add("ws-target-resource-nopropagation");
-
+        userTO.getResources().add(RESOURCE_NAME_NOPROPAGATION);
         createUser(userTO);
     }
 
@@ -1203,38 +1197,6 @@ public class UserTestITCase extends Abst
     }
 
     @Test
-    public void issueSYNCOPE16() {
-        UserTO userTO = getUniqueSampleTO("issue16@apache.org");
-
-        MembershipTO membershipTO = new MembershipTO();
-        membershipTO.setRoleId(8L);
-        userTO.getMemberships().add(membershipTO);
-
-        // 1. create user
-        UserTO actual = createUser(userTO);
-        assertNotNull(actual);
-
-        // 2. check for virtual attribute value
-        actual = userService.read(actual.getId());
-        assertNotNull(actual);
-        assertEquals("virtualvalue", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
-
-        UserMod userMod = new UserMod();
-        userMod.setId(actual.getId());
-        userMod.getVirAttrsToRemove().add("virtualdata");
-        userMod.getVirAttrsToUpdate().add(attributeMod("virtualdata", "virtualupdated"));
-
-        // 3. update virtual attribute
-        actual = updateUser(userMod);
-        assertNotNull(actual);
-
-        // 4. check for virtual attribute value
-        actual = userService.read(actual.getId());
-        assertNotNull(actual);
-        assertEquals("virtualupdated", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
-    }
-
-    @Test
     public void issueSYNCOPE108() {
         UserTO userTO = getUniqueSampleTO("syncope108@syncope.apache.org");
         userTO.getResources().clear();
@@ -1276,8 +1238,7 @@ public class UserTestITCase extends Abst
         assertNotNull(actual);
         assertEquals(1, actual.getMemberships().size());
 
-        connObjectTO =
-                resourceService.getConnectorObject(RESOURCE_NAME_CSV, AttributableType.USER, actual.getId());
+        connObjectTO = resourceService.getConnectorObject(RESOURCE_NAME_CSV, AttributableType.USER, actual.getId());
         assertNotNull(connObjectTO);
         // -----------------------------------
 
@@ -1294,8 +1255,7 @@ public class UserTestITCase extends Abst
         assertEquals(1, actual.getMemberships().size());
         assertFalse(actual.getResources().isEmpty());
 
-        connObjectTO =
-                resourceService.getConnectorObject(RESOURCE_NAME_CSV, AttributableType.USER, actual.getId());
+        connObjectTO = resourceService.getConnectorObject(RESOURCE_NAME_CSV, AttributableType.USER, actual.getId());
         assertNotNull(connObjectTO);
         // -----------------------------------
 
@@ -1374,8 +1334,7 @@ public class UserTestITCase extends Abst
         assertNotNull(actual);
         assertEquals(1, actual.getMemberships().size());
 
-        connObjectTO =
-                resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.USER, actual.getId());
+        connObjectTO = resourceService.getConnectorObject(RESOURCE_NAME_LDAP, AttributableType.USER, actual.getId());
         assertNotNull(connObjectTO);
 
         postalAddress = connObjectTO.getAttrMap().get("postalAddress");
@@ -1445,142 +1404,18 @@ public class UserTestITCase extends Abst
     }
 
     @Test
-    public void issueSYNCOPE260() {
-        // ----------------------------------
-        // create user and check virtual attribute value propagation
-        // ----------------------------------
-        UserTO userTO = getUniqueSampleTO("260@a.com");
-        userTO.getResources().add("ws-target-resource-2");
-
-        userTO = createUser(userTO);
-        assertNotNull(userTO);
-        assertFalse(userTO.getPropagationStatusTOs().isEmpty());
-        assertEquals("ws-target-resource-2", userTO.getPropagationStatusTOs().get(0).getResource());
-        assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
-
-        ConnObjectTO connObjectTO =
-                resourceService.getConnectorObject("ws-target-resource-2", AttributableType.USER, userTO.getId());
-        assertNotNull(connObjectTO);
-        assertEquals("virtualvalue", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
-        // ----------------------------------
-
-        // ----------------------------------
-        // update user virtual attribute and check virtual attribute value update propagation
-        // ----------------------------------
-        UserMod userMod = new UserMod();
-        userMod.setId(userTO.getId());
-
-        AttributeMod attrMod = new AttributeMod();
-        attrMod.setSchema("virtualdata");
-        attrMod.getValuesToBeRemoved().add("virtualvalue");
-        attrMod.getValuesToBeAdded().add("virtualvalue2");
-
-        userMod.getVirAttrsToUpdate().add(attrMod);
-
-        userTO = updateUser(userMod);
-        assertNotNull(userTO);
-        assertFalse(userTO.getPropagationStatusTOs().isEmpty());
-        assertEquals("ws-target-resource-2", userTO.getPropagationStatusTOs().get(0).getResource());
-        assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
-
-        connObjectTO =
-                resourceService.getConnectorObject("ws-target-resource-2", AttributableType.USER, userTO.getId());
-        assertNotNull(connObjectTO);
-        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
-        // ----------------------------------
-
-        // ----------------------------------
-        // suspend/reactivate user and check virtual attribute value (unchanged)
-        // ----------------------------------
-        StatusMod statusMod = new StatusMod();
-        statusMod.setType(StatusMod.ModType.SUSPEND);
-        userTO = userService.status(userTO.getId(), statusMod).readEntity(UserTO.class);
-        assertEquals("suspended", userTO.getStatus());
-
-        connObjectTO =
-                resourceService.getConnectorObject("ws-target-resource-2", AttributableType.USER, userTO.getId());
-        assertNotNull(connObjectTO);
-        assertFalse(connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
-        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
-
-        statusMod = new StatusMod();
-        statusMod.setType(StatusMod.ModType.REACTIVATE);
-        userTO = userService.status(userTO.getId(), statusMod).readEntity(UserTO.class);
-        assertEquals("active", userTO.getStatus());
-
-        connObjectTO =
-                resourceService.getConnectorObject("ws-target-resource-2", AttributableType.USER, userTO.getId());
-        assertNotNull(connObjectTO);
-        assertFalse(connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
-        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
-        // ----------------------------------
-
-        // ----------------------------------
-        // update user attribute and check virtual attribute value (unchanged)
-        // ----------------------------------
-        userMod = new UserMod();
-        userMod.setId(userTO.getId());
-
-        attrMod = new AttributeMod();
-        attrMod.setSchema("surname");
-        attrMod.getValuesToBeRemoved().add("Surname");
-        attrMod.getValuesToBeAdded().add("Surname2");
-
-        userMod.getAttrsToUpdate().add(attrMod);
-
-        userTO = updateUser(userMod);
-        assertNotNull(userTO);
-        assertFalse(userTO.getPropagationStatusTOs().isEmpty());
-        assertEquals("ws-target-resource-2", userTO.getPropagationStatusTOs().get(0).getResource());
-        assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
-
-        connObjectTO =
-                resourceService.getConnectorObject("ws-target-resource-2", AttributableType.USER, userTO.getId());
-        assertNotNull(connObjectTO);
-        assertEquals("Surname2", connObjectTO.getAttrMap().get("SURNAME").getValues().get(0));
-
-        // attribute "name" mapped on virtual attribute "virtualdata" shouldn't be changed
-        assertFalse(connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
-        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
-        // ----------------------------------
-
-        // ----------------------------------
-        // remove user virtual attribute and check virtual attribute value (reset)
-        // ----------------------------------
-        userMod = new UserMod();
-        userMod.setId(userTO.getId());
-        userMod.getVirAttrsToRemove().add("virtualdata");
-
-        userTO = updateUser(userMod);
-        assertNotNull(userTO);
-        assertTrue(userTO.getVirAttrs().isEmpty());
-        assertFalse(userTO.getPropagationStatusTOs().isEmpty());
-        assertEquals("ws-target-resource-2", userTO.getPropagationStatusTOs().get(0).getResource());
-        assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
-
-        connObjectTO =
-                resourceService.getConnectorObject("ws-target-resource-2", AttributableType.USER, userTO.getId());
-        assertNotNull(connObjectTO);
-
-        // attribute "name" mapped on virtual attribute "virtualdata" should be reset
-        assertTrue(connObjectTO.getAttrMap().get("NAME").getValues() == null
-                || connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
-        // ----------------------------------
-    }
-
-    @Test
     public void issueSYNCOPE267() {
         // ----------------------------------
         // create user and check virtual attribute value propagation
         // ----------------------------------
         UserTO userTO = getUniqueSampleTO("syncope267@apache.org");
         userTO.getResources().clear();
-        userTO.getResources().add("resource-db-virattr");
+        userTO.getResources().add(RESOURCE_NAME_DBVIRATTR);
 
         userTO = createUser(userTO);
         assertNotNull(userTO);
         assertFalse(userTO.getPropagationStatusTOs().isEmpty());
-        assertEquals("resource-db-virattr", userTO.getPropagationStatusTOs().get(0).getResource());
+        assertEquals(RESOURCE_NAME_DBVIRATTR, userTO.getPropagationStatusTOs().get(0).getResource());
         assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
 
         ConnObjectTO connObjectTO =
@@ -1608,7 +1443,7 @@ public class UserTestITCase extends Abst
         userMod.setId(userTO.getId());
 
         // this resource has not a mapping for Password
-        userMod.getResourcesToAdd().add("ws-target-resource-update");
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_UPDATE);
 
         userTO = updateUser(userMod);
         assertNotNull(userTO);
@@ -1618,9 +1453,9 @@ public class UserTestITCase extends Abst
     public void issueSYNCOPE279() {
         UserTO userTO = getUniqueSampleTO("syncope279@apache.org");
         userTO.getResources().clear();
-        userTO.getResources().add("ws-target-resource-timeout");
+        userTO.getResources().add(RESOURCE_NAME_TIMEOUT);
         userTO = createUser(userTO);
-        assertEquals("ws-target-resource-timeout", userTO.getPropagationStatusTOs().get(0).getResource());
+        assertEquals(RESOURCE_NAME_TIMEOUT, userTO.getPropagationStatusTOs().get(0).getResource());
         assertNotNull(userTO.getPropagationStatusTOs().get(0).getFailureReason());
         assertEquals(PropagationTaskExecStatus.UNSUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
     }
@@ -1630,13 +1465,14 @@ public class UserTestITCase extends Abst
         // 1. create user on testdb and testdb2
         UserTO userTO = getUniqueSampleTO("syncope122@apache.org");
         userTO.getResources().clear();
+
         userTO.getResources().add(RESOURCE_NAME_TESTDB);
-        userTO.getResources().add("resource-testdb2");
+        userTO.getResources().add(RESOURCE_NAME_TESTDB2);
 
         userTO = createUser(userTO);
         assertNotNull(userTO);
         assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
-        assertTrue(userTO.getResources().contains("resource-testdb2"));
+        assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB2));
 
         final String pwdOnSyncope = userTO.getPassword();
 
@@ -1649,7 +1485,7 @@ public class UserTestITCase extends Abst
         final String pwdOnTestDb = pwdOnTestDbAttr.getValues().iterator().next();
 
         ConnObjectTO userOnDb2 = resourceService.getConnectorObject(
-                "resource-testdb2", AttributableType.USER, userTO.getId());
+                RESOURCE_NAME_TESTDB2, AttributableType.USER, userTO.getId());
         final AttributeTO pwdOnTestDb2Attr = userOnDb2.getAttrMap().get(OperationalAttributes.PASSWORD_NAME);
         assertNotNull(pwdOnTestDb2Attr);
         assertNotNull(pwdOnTestDb2Attr.getValues());
@@ -1684,7 +1520,7 @@ public class UserTestITCase extends Abst
         assertNotEquals(pwdOnTestDb, pwdOnTestDbAttrAfter.getValues().iterator().next());
 
         // 3d. verify that password hasn't changed on testdb2
-        userOnDb2 = resourceService.getConnectorObject("resource-testdb2", AttributableType.USER, userTO.getId());
+        userOnDb2 = resourceService.getConnectorObject(RESOURCE_NAME_TESTDB2, AttributableType.USER, userTO.getId());
         final AttributeTO pwdOnTestDb2AttrAfter = userOnDb2.getAttrMap().get(OperationalAttributes.PASSWORD_NAME);
         assertNotNull(pwdOnTestDb2AttrAfter);
         assertNotNull(pwdOnTestDb2AttrAfter.getValues());
@@ -1712,7 +1548,7 @@ public class UserTestITCase extends Abst
         // 4. update user, assign a propagation primary resource but don't provide any password
         UserMod userMod = new UserMod();
         userMod.setId(userTO.getId());
-        userMod.getResourcesToAdd().add("ws-target-resource-1");
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_WS1);
 
         userTO = updateUser(userMod);
         assertNotNull(userTO);
@@ -1723,7 +1559,7 @@ public class UserTestITCase extends Abst
         assertEquals(1, props.size());
         PropagationStatusTO prop = props.iterator().next();
         assertNotNull(prop);
-        assertEquals("ws-target-resource-1", prop.getResource());
+        assertEquals(RESOURCE_NAME_WS1, prop.getResource());
         assertEquals(PropagationTaskExecStatus.SUBMITTED, prop.getStatus());
 
         // 6. restore initial cipher algorithm
@@ -1759,71 +1595,6 @@ public class UserTestITCase extends Abst
     }
 
     @Test
-    public void virAttrCache() {
-        UserTO userTO = getUniqueSampleTO("virattrcache@apache.org");
-        userTO.getVirAttrs().clear();
-
-        AttributeTO virAttrTO = new AttributeTO();
-        virAttrTO.setSchema("virtualdata");
-        virAttrTO.getValues().add("virattrcache");
-        userTO.getVirAttrs().add(virAttrTO);
-
-        userTO.getMemberships().clear();
-        userTO.getResources().clear();
-        userTO.getResources().add("resource-db-virattr");
-
-        // 1. create user
-        UserTO actual = createUser(userTO);
-        assertNotNull(actual);
-
-        // 2. check for virtual attribute value
-        actual = userService.read(actual.getId());
-        assertEquals("virattrcache", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
-
-        Exception exception = null;
-        try {
-            final JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
-
-            String value = jdbcTemplate.queryForObject(
-                    "SELECT USERNAME FROM testsync WHERE ID=?", String.class, actual.getId());
-            assertEquals("virattrcache", value);
-
-            jdbcTemplate.update("UPDATE testsync set USERNAME='virattrcache2' WHERE ID=?", userTO.getId());
-
-            value = jdbcTemplate.queryForObject(
-                    "SELECT USERNAME FROM testsync WHERE ID=?", String.class, userTO.getId());
-            assertEquals("virattrcache2", value);
-
-        } catch (EmptyResultDataAccessException e) {
-            exception = e;
-        }
-        assertNotNull(exception);
-
-        // 2. check for cached attribute value
-        actual = userService.read(actual.getId());
-        assertEquals("virattrcache", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
-
-        UserMod userMod = new UserMod();
-        userMod.setId(actual.getId());
-
-        AttributeMod virtualdata = new AttributeMod();
-        virtualdata.setSchema("virtualdata");
-        virtualdata.getValuesToBeAdded().add("virtualupdated");
-
-        userMod.getVirAttrsToRemove().add("virtualdata");
-        userMod.getVirAttrsToUpdate().add(virtualdata);
-
-        // 3. update virtual attribute
-        actual = updateUser(userMod);
-        assertNotNull(actual);
-
-        // 4. check for virtual attribute value
-        actual = userService.read(actual.getId());
-        assertNotNull(actual);
-        assertEquals("virtualupdated", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
-    }
-
-    @Test
     public void mappingPurpose() {
         UserTO userTO = getUniqueSampleTO("mpurpose@apache.org");
 
@@ -2022,79 +1793,6 @@ public class UserTestITCase extends Abst
     }
 
     @Test
-    public void issueSYNCOPE397() {
-        ResourceTO csv = resourceService.read(RESOURCE_NAME_CSV);
-        // change mapping of resource-csv
-        MappingTO origMapping = SerializationUtils.clone(csv.getUmapping());
-        assertNotNull(origMapping);
-        for (MappingItemTO item : csv.getUmapping().getItems()) {
-            if ("email".equals(item.getIntAttrName())) {
-                // unset internal attribute mail and set virtual attribute virtualdata as mapped to external email
-                item.setIntMappingType(IntMappingType.UserVirtualSchema);
-                item.setIntAttrName("virtualdata");
-                item.setPurpose(MappingPurpose.BOTH);
-                item.setExtAttrName("email");
-            }
-        }
-
-        resourceService.update(csv.getName(), csv);
-        csv = resourceService.read(RESOURCE_NAME_CSV);
-        assertNotNull(csv.getUmapping());
-
-        boolean found = false;
-        for (MappingItemTO item : csv.getUmapping().getItems()) {
-            if ("email".equals(item.getExtAttrName()) && "virtualdata".equals(item.getIntAttrName())) {
-                found = true;
-            }
-        }
-
-        assertTrue(found);
-
-        // create a new user
-        UserTO userTO = getUniqueSampleTO("syncope397@syncope.apache.org");
-        userTO.getResources().clear();
-        userTO.getMemberships().clear();
-        userTO.getDerAttrs().clear();
-        userTO.getVirAttrs().clear();
-
-        userTO.getDerAttrs().add(attributeTO("csvuserid", null));
-        userTO.getDerAttrs().add(attributeTO("cn", null));
-        userTO.getVirAttrs().add(attributeTO("virtualdata", "test@testone.org"));
-        // assign resource-csv to user
-        userTO.getResources().add(RESOURCE_NAME_CSV);
-        // save user
-        UserTO created = createUser(userTO);
-        // make std controls about user
-        assertNotNull(created);
-        assertTrue(RESOURCE_NAME_CSV.equals(created.getResources().iterator().next()));
-        // update user
-        UserTO toBeUpdated = userService.read(created.getId());
-        UserMod userMod = new UserMod();
-        userMod.setId(toBeUpdated.getId());
-        userMod.setPassword("password2");
-        // assign new resource to user
-        userMod.getResourcesToAdd().add("ws-target-resource-2");
-        //modify virtual attribute
-        userMod.getVirAttrsToRemove().add("virtualdata");
-        userMod.getVirAttrsToUpdate().add(attributeMod("virtualdata", "test@testoneone.com"));
-
-        // check Syncope change password
-        StatusMod pwdPropRequest = new StatusMod();
-        pwdPropRequest.setOnSyncope(true);
-        pwdPropRequest.getResourceNames().add("ws-target-resource-2");
-        userMod.setPwdPropRequest(pwdPropRequest);
-
-        toBeUpdated = updateUser(userMod);
-        assertNotNull(toBeUpdated);
-        assertEquals("test@testoneone.com", toBeUpdated.getVirAttrs().get(0).getValues().get(0));
-        // check if propagates correctly with assertEquals on size of tasks list
-        assertEquals(2, toBeUpdated.getPropagationStatusTOs().size());
-        // restore mapping of resource-csv
-        csv.setUmapping(origMapping);
-        resourceService.update(csv.getName(), csv);
-    }
-
-    @Test
     public void issueSYNCOPE402() {
         // 1. create an user with strict mandatory attributes only
         UserTO userTO = new UserTO();
@@ -2115,10 +1813,11 @@ public class UserTestITCase extends Abst
         UserMod userMod = new UserMod();
         userMod.setId(userTO.getId());
         userMod.setPassword("newPassword");
-        userMod.getResourcesToAdd().add("ws-target-resource-1");
-        userMod.getResourcesToAdd().add("resource-testdb");
+
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_WS1);
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_TESTDB);
         userTO = updateUser(userMod);
-        assertEquals("ws-target-resource-1", userTO.getPropagationStatusTOs().get(1).getResource());
+        assertEquals(RESOURCE_NAME_WS1, userTO.getPropagationStatusTOs().get(1).getResource());
         assertNotNull(userTO.getPropagationStatusTOs().get(1).getFailureReason());
         assertEquals(PropagationTaskExecStatus.UNSUBMITTED, userTO.getPropagationStatusTOs().get(1).getStatus());
     }
@@ -2277,24 +1976,12 @@ public class UserTestITCase extends Abst
 
         // 2. try to update user by subscribing a resource - works but propagation is not even attempted
         UserMod userMod = new UserMod();
-        userMod.getResourcesToAdd().add("ws-target-resource-1");
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_WS1);
 
         userTO = userService.update(userTO.getId(), userMod).readEntity(UserTO.class);
-        assertEquals(Collections.singleton("ws-target-resource-1"), userTO.getResources());
+        assertEquals(Collections.singleton(RESOURCE_NAME_WS1), userTO.getResources());
         assertFalse(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());
         assertTrue(userTO.getPropagationStatusTOs().get(0).getFailureReason().
                 startsWith("Not attempted because there are mandatory attributes without value(s): [__PASSWORD__]"));
     }
-
-    @Test
-    public void issueSYNCOPE436() {
-        UserTO userTO = getUniqueSampleTO("syncope436@syncope.apache.org");
-        userTO.getMemberships().clear();
-        userTO.getResources().clear();
-        userTO.getResources().add(RESOURCE_NAME_LDAP);
-        userTO.getVirAttrs().add(attributeTO("virtualReadOnly", "readOnly"));
-        userTO = createUser(userTO);
-        //Finding no values because the virtual attribute is readonly 
-        assertTrue(userTO.getVirAttrMap().get("virtualReadOnly").getValues().isEmpty());
-    }
 }

Copied: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java (from r1546016, syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java?p2=syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java&p1=syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java&r1=1546016&r2=1546033&rev=1546033&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/VirAttrTestITCase.java Wed Nov 27 13:46:15 2013
@@ -26,15 +26,16 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.util.Collections;
+import org.apache.commons.lang3.SerializationUtils;
 import org.apache.syncope.common.mod.AttributeMod;
+import org.apache.syncope.common.mod.StatusMod;
 import org.apache.syncope.common.mod.UserMod;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.common.to.ConnInstanceTO;
 import org.apache.syncope.common.to.ConnObjectTO;
 import org.apache.syncope.common.to.MappingItemTO;
+import org.apache.syncope.common.to.MappingTO;
 import org.apache.syncope.common.to.MembershipTO;
-import org.apache.syncope.common.to.PropagationRequestTO;
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.AttributableType;
@@ -56,7 +57,7 @@ public class VirAttrTestITCase extends A
 
         MembershipTO membershipTO = new MembershipTO();
         membershipTO.setRoleId(8L);
-        userTO.addMembership(membershipTO);
+        userTO.getMemberships().add(membershipTO);
 
         // 1. create user
         UserTO actual = createUser(userTO);
@@ -65,21 +66,21 @@ public class VirAttrTestITCase extends A
         // 2. check for virtual attribute value
         actual = userService.read(actual.getId());
         assertNotNull(actual);
-        assertEquals("virtualvalue", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virtualvalue", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
 
         UserMod userMod = new UserMod();
         userMod.setId(actual.getId());
-        userMod.addVirtualAttributeToBeRemoved("virtualdata");
-        userMod.addVirtualAttributeToBeUpdated(attributeMod("virtualdata", "virtualupdated"));
+        userMod.getVirAttrsToRemove().add("virtualdata");
+        userMod.getVirAttrsToUpdate().add(attributeMod("virtualdata", "virtualupdated"));
 
         // 3. update virtual attribute
-        actual = userService.update(userMod.getId(), userMod);
+        actual = updateUser(userMod);
         assertNotNull(actual);
 
         // 4. check for virtual attribute value
         actual = userService.read(actual.getId());
         assertNotNull(actual);
-        assertEquals("virtualupdated", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virtualupdated", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
     }
 
     @Test
@@ -88,7 +89,7 @@ public class VirAttrTestITCase extends A
         // create user and check virtual attribute value propagation
         // ----------------------------------
         UserTO userTO = getUniqueSampleTO("260@a.com");
-        userTO.addResource(RESOURCE_NAME_WS2);
+        userTO.getResources().add(RESOURCE_NAME_WS2);
 
         userTO = createUser(userTO);
         assertNotNull(userTO);
@@ -96,9 +97,10 @@ public class VirAttrTestITCase extends A
         assertEquals(RESOURCE_NAME_WS2, userTO.getPropagationStatusTOs().get(0).getResource());
         assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
 
-        ConnObjectTO connObjectTO = readConnectorObject(RESOURCE_NAME_WS2, userTO.getId(), AttributableType.USER);
+        ConnObjectTO connObjectTO =
+                resourceService.getConnectorObject(RESOURCE_NAME_WS2, AttributableType.USER, userTO.getId());
         assertNotNull(connObjectTO);
-        assertEquals("virtualvalue", connObjectTO.getAttributeMap().get("NAME").getValues().get(0));
+        assertEquals("virtualvalue", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
         // ----------------------------------
 
         // ----------------------------------
@@ -109,40 +111,46 @@ public class VirAttrTestITCase extends A
 
         AttributeMod attrMod = new AttributeMod();
         attrMod.setSchema("virtualdata");
-        attrMod.addValueToBeRemoved("virtualvalue");
-        attrMod.addValueToBeAdded("virtualvalue2");
+        attrMod.getValuesToBeRemoved().add("virtualvalue");
+        attrMod.getValuesToBeAdded().add("virtualvalue2");
 
-        userMod.addVirtualAttributeToBeUpdated(attrMod);
+        userMod.getVirAttrsToUpdate().add(attrMod);
 
-        userTO = userService.update(userMod.getId(), userMod);
+        userTO = updateUser(userMod);
         assertNotNull(userTO);
         assertFalse(userTO.getPropagationStatusTOs().isEmpty());
-        assertEquals(RESOURCE_NAME_WS2, userTO.getPropagationStatusTOs().get(0).getResource());
+        assertEquals("ws-target-resource-2", userTO.getPropagationStatusTOs().get(0).getResource());
         assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
 
-        connObjectTO = readConnectorObject(RESOURCE_NAME_WS2, userTO.getId(), AttributableType.USER);
+        connObjectTO = resourceService.getConnectorObject(RESOURCE_NAME_WS2, AttributableType.USER, userTO.getId());
         assertNotNull(connObjectTO);
-        assertEquals("virtualvalue2", connObjectTO.getAttributeMap().get("NAME").getValues().get(0));
+        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
         // ----------------------------------
 
         // ----------------------------------
         // suspend/reactivate user and check virtual attribute value (unchanged)
         // ----------------------------------
-        userTO = userService.suspend(userTO.getId());
+        StatusMod statusMod = new StatusMod();
+        statusMod.setType(StatusMod.ModType.SUSPEND);
+        userTO = userService.status(userTO.getId(), statusMod).readEntity(UserTO.class);
         assertEquals("suspended", userTO.getStatus());
 
-        connObjectTO = readConnectorObject(RESOURCE_NAME_WS2, userTO.getId(), AttributableType.USER);
+        connObjectTO =
+                resourceService.getConnectorObject(RESOURCE_NAME_WS2, AttributableType.USER, userTO.getId());
         assertNotNull(connObjectTO);
-        assertFalse(connObjectTO.getAttributeMap().get("NAME").getValues().isEmpty());
-        assertEquals("virtualvalue2", connObjectTO.getAttributeMap().get("NAME").getValues().get(0));
+        assertFalse(connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
+        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
 
-        userTO = userService.reactivate(userTO.getId());
+        statusMod = new StatusMod();
+        statusMod.setType(StatusMod.ModType.REACTIVATE);
+        userTO = userService.status(userTO.getId(), statusMod).readEntity(UserTO.class);
         assertEquals("active", userTO.getStatus());
 
-        connObjectTO = readConnectorObject(RESOURCE_NAME_WS2, userTO.getId(), AttributableType.USER);
+        connObjectTO =
+                resourceService.getConnectorObject(RESOURCE_NAME_WS2, AttributableType.USER, userTO.getId());
         assertNotNull(connObjectTO);
-        assertFalse(connObjectTO.getAttributeMap().get("NAME").getValues().isEmpty());
-        assertEquals("virtualvalue2", connObjectTO.getAttributeMap().get("NAME").getValues().get(0));
+        assertFalse(connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
+        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
         // ----------------------------------
 
         // ----------------------------------
@@ -153,24 +161,24 @@ public class VirAttrTestITCase extends A
 
         attrMod = new AttributeMod();
         attrMod.setSchema("surname");
-        attrMod.addValueToBeRemoved("Surname");
-        attrMod.addValueToBeAdded("Surname2");
+        attrMod.getValuesToBeRemoved().add("Surname");
+        attrMod.getValuesToBeAdded().add("Surname2");
 
-        userMod.addAttributeToBeUpdated(attrMod);
+        userMod.getAttrsToUpdate().add(attrMod);
 
-        userTO = userService.update(userMod.getId(), userMod);
+        userTO = updateUser(userMod);
         assertNotNull(userTO);
         assertFalse(userTO.getPropagationStatusTOs().isEmpty());
         assertEquals(RESOURCE_NAME_WS2, userTO.getPropagationStatusTOs().get(0).getResource());
         assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
 
-        connObjectTO = readConnectorObject(RESOURCE_NAME_WS2, userTO.getId(), AttributableType.USER);
+        connObjectTO = resourceService.getConnectorObject(RESOURCE_NAME_WS2, AttributableType.USER, userTO.getId());
         assertNotNull(connObjectTO);
-        assertEquals("Surname2", connObjectTO.getAttributeMap().get("SURNAME").getValues().get(0));
+        assertEquals("Surname2", connObjectTO.getAttrMap().get("SURNAME").getValues().get(0));
 
         // attribute "name" mapped on virtual attribute "virtualdata" shouldn't be changed
-        assertFalse(connObjectTO.getAttributeMap().get("NAME").getValues().isEmpty());
-        assertEquals("virtualvalue2", connObjectTO.getAttributeMap().get("NAME").getValues().get(0));
+        assertFalse(connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
+        assertEquals("virtualvalue2", connObjectTO.getAttrMap().get("NAME").getValues().get(0));
         // ----------------------------------
 
         // ----------------------------------
@@ -178,37 +186,37 @@ public class VirAttrTestITCase extends A
         // ----------------------------------
         userMod = new UserMod();
         userMod.setId(userTO.getId());
-        userMod.addVirtualAttributeToBeRemoved("virtualdata");
+        userMod.getVirAttrsToRemove().add("virtualdata");
 
-        userTO = userService.update(userMod.getId(), userMod);
+        userTO = updateUser(userMod);
         assertNotNull(userTO);
-        assertTrue(userTO.getVirtualAttributes().isEmpty());
+        assertTrue(userTO.getVirAttrs().isEmpty());
         assertFalse(userTO.getPropagationStatusTOs().isEmpty());
         assertEquals(RESOURCE_NAME_WS2, userTO.getPropagationStatusTOs().get(0).getResource());
         assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());
 
-        connObjectTO = readConnectorObject(RESOURCE_NAME_WS2, userTO.getId(), AttributableType.USER);
+        connObjectTO = resourceService.getConnectorObject(RESOURCE_NAME_WS2, AttributableType.USER, userTO.getId());
         assertNotNull(connObjectTO);
 
         // attribute "name" mapped on virtual attribute "virtualdata" should be reset
-        assertTrue(connObjectTO.getAttributeMap().get("NAME").getValues() == null
-                || connObjectTO.getAttributeMap().get("NAME").getValues().isEmpty());
+        assertTrue(connObjectTO.getAttrMap().get("NAME").getValues() == null
+                || connObjectTO.getAttrMap().get("NAME").getValues().isEmpty());
         // ----------------------------------
     }
 
     @Test
     public void virAttrCache() {
         UserTO userTO = getUniqueSampleTO("virattrcache@apache.org");
-        userTO.getVirtualAttributes().clear();
+        userTO.getVirAttrs().clear();
 
         AttributeTO virAttrTO = new AttributeTO();
         virAttrTO.setSchema("virtualdata");
-        virAttrTO.addValue("virattrcache");
-        userTO.addVirtualAttribute(virAttrTO);
+        virAttrTO.getValues().add("virattrcache");
+        userTO.getVirAttrs().add(virAttrTO);
 
         userTO.getMemberships().clear();
         userTO.getResources().clear();
-        userTO.addResource(RESOURCE_NAME_DBVIRATTR);
+        userTO.getResources().add(RESOURCE_NAME_DBVIRATTR);
 
         // 1. create user
         UserTO actual = createUser(userTO);
@@ -216,11 +224,9 @@ public class VirAttrTestITCase extends A
 
         // 2. check for virtual attribute value
         actual = userService.read(actual.getId());
-        assertEquals("virattrcache", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virattrcache", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
 
-        // ----------------------------------------
-        // 3. update virtual attribute
-        // ----------------------------------------
+        // 3. update virtual attribute directly
         final JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
 
         String value = jdbcTemplate.queryForObject(
@@ -232,36 +238,37 @@ public class VirAttrTestITCase extends A
         value = jdbcTemplate.queryForObject(
                 "SELECT USERNAME FROM testsync WHERE ID=?", String.class, actual.getId());
         assertEquals("virattrcache2", value);
-        // ----------------------------------------
 
         // 4. check for cached attribute value
         actual = userService.read(actual.getId());
-        assertEquals("virattrcache", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virattrcache", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
 
         UserMod userMod = new UserMod();
         userMod.setId(actual.getId());
 
         AttributeMod virtualdata = new AttributeMod();
         virtualdata.setSchema("virtualdata");
-        virtualdata.addValueToBeAdded("virtualupdated");
+        virtualdata.getValuesToBeAdded().add("virtualupdated");
 
-        userMod.addVirtualAttributeToBeRemoved("virtualdata");
-        userMod.addVirtualAttributeToBeUpdated(virtualdata);
+        userMod.getVirAttrsToRemove().add("virtualdata");
+        userMod.getVirAttrsToUpdate().add(virtualdata);
 
         // 5. update virtual attribute
-        actual = userService.update(actual.getId(), userMod);
+        actual = updateUser(userMod);
         assertNotNull(actual);
 
         // 6. check for virtual attribute value
         actual = userService.read(actual.getId());
         assertNotNull(actual);
-        assertEquals("virtualupdated", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virtualupdated", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
     }
 
     @Test
     public void issueSYNCOPE397() {
         ResourceTO csv = resourceService.read(RESOURCE_NAME_CSV);
-
+        // change mapping of resource-csv
+        MappingTO origMapping = SerializationUtils.clone(csv.getUmapping());
+        assertNotNull(origMapping);
         for (MappingItemTO item : csv.getUmapping().getItems()) {
             if ("email".equals(item.getIntAttrName())) {
                 // unset internal attribute mail and set virtual attribute virtualdata as mapped to external email
@@ -289,14 +296,14 @@ public class VirAttrTestITCase extends A
         UserTO userTO = getUniqueSampleTO("syncope397@syncope.apache.org");
         userTO.getResources().clear();
         userTO.getMemberships().clear();
-        userTO.getDerivedAttributes().clear();
-        userTO.getVirtualAttributes().clear();
+        userTO.getDerAttrs().clear();
+        userTO.getVirAttrs().clear();
 
-        userTO.addDerivedAttribute(attributeTO("csvuserid", null));
-        userTO.addDerivedAttribute(attributeTO("cn", null));
-        userTO.addVirtualAttribute(attributeTO("virtualdata", "test@testone.org"));
+        userTO.getDerAttrs().add(attributeTO("csvuserid", null));
+        userTO.getDerAttrs().add(attributeTO("cn", null));
+        userTO.getVirAttrs().add(attributeTO("virtualdata", "test@testone.org"));
         // assign resource-csv to user
-        userTO.addResource(RESOURCE_NAME_CSV);
+        userTO.getResources().add(RESOURCE_NAME_CSV);
         // save user
         UserTO created = createUser(userTO);
         // make std controls about user
@@ -308,37 +315,40 @@ public class VirAttrTestITCase extends A
         userMod.setId(toBeUpdated.getId());
         userMod.setPassword("password2");
         // assign new resource to user
-        userMod.addResourceToBeAdded(RESOURCE_NAME_WS2);
+        userMod.getResourcesToAdd().add(RESOURCE_NAME_WS2);
         //modify virtual attribute
-        userMod.addVirtualAttributeToBeRemoved("virtualdata");
-        userMod.addVirtualAttributeToBeUpdated(attributeMod("virtualdata", "test@testoneone.com"));
+        userMod.getVirAttrsToRemove().add("virtualdata");
+        userMod.getVirAttrsToUpdate().add(attributeMod("virtualdata", "test@testoneone.com"));
 
         // check Syncope change password
-        PropagationRequestTO pwdPropRequest = new PropagationRequestTO();
+        StatusMod pwdPropRequest = new StatusMod();
         pwdPropRequest.setOnSyncope(true);
-        pwdPropRequest.addResource(RESOURCE_NAME_WS2);
+        pwdPropRequest.getResourceNames().add(RESOURCE_NAME_WS2);
         userMod.setPwdPropRequest(pwdPropRequest);
 
-        toBeUpdated = userService.update(userMod.getId(), userMod);
+        toBeUpdated = updateUser(userMod);
         assertNotNull(toBeUpdated);
-        assertEquals("test@testoneone.com", toBeUpdated.getVirtualAttributes().get(0).getValues().get(0));
+        assertEquals("test@testoneone.com", toBeUpdated.getVirAttrs().get(0).getValues().get(0));
         // check if propagates correctly with assertEquals on size of tasks list
         assertEquals(2, toBeUpdated.getPropagationStatusTOs().size());
+        // restore mapping of resource-csv
+        csv.setUmapping(origMapping);
+        resourceService.update(csv.getName(), csv);
     }
 
     @Test
     public void issueSYNCOPE442() {
         UserTO userTO = getUniqueSampleTO("syncope442@apache.org");
-        userTO.getVirtualAttributes().clear();
+        userTO.getVirAttrs().clear();
 
         AttributeTO virAttrTO = new AttributeTO();
         virAttrTO.setSchema("virtualdata");
-        virAttrTO.addValue("virattrcache");
-        userTO.addVirtualAttribute(virAttrTO);
+        virAttrTO.getValues().add("virattrcache");
+        userTO.getVirAttrs().add(virAttrTO);
 
         userTO.getMemberships().clear();
         userTO.getResources().clear();
-        userTO.addResource(RESOURCE_NAME_DBVIRATTR);
+        userTO.getResources().add(RESOURCE_NAME_DBVIRATTR);
 
         // 1. create user
         UserTO actual = createUser(userTO);
@@ -346,7 +356,7 @@ public class VirAttrTestITCase extends A
 
         // 2. check for virtual attribute value
         actual = userService.read(actual.getId());
-        assertEquals("virattrcache", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virattrcache", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
 
         // ----------------------------------------
         // 3. force cache expiring without any modification
@@ -356,7 +366,8 @@ public class VirAttrTestITCase extends A
         for (ConnConfProperty prop : connInstanceBean.getConfiguration()) {
             if ("jdbcUrlTemplate".equals(prop.getSchema().getName())) {
                 jdbcURL = prop.getValues().iterator().next().toString();
-                prop.setValues(Collections.singletonList("jdbc:h2:tcp://localhost:9092/xxx"));
+                prop.getValues().clear();
+                prop.getValues().add("jdbc:h2:tcp://localhost:9092/xxx");
             }
         }
 
@@ -367,12 +378,12 @@ public class VirAttrTestITCase extends A
 
         AttributeMod virtualdata = new AttributeMod();
         virtualdata.setSchema("virtualdata");
-        virtualdata.addValueToBeAdded("virtualupdated");
+        virtualdata.getValuesToBeAdded().add("virtualupdated");
 
-        userMod.addVirtualAttributeToBeRemoved("virtualdata");
-        userMod.addVirtualAttributeToBeUpdated(virtualdata);
+        userMod.getVirAttrsToRemove().add("virtualdata");
+        userMod.getVirAttrsToUpdate().add(virtualdata);
 
-        actual = userService.update(actual.getId(), userMod);
+        actual = updateUser(userMod);
         assertNotNull(actual);
         // ----------------------------------------
 
@@ -393,14 +404,15 @@ public class VirAttrTestITCase extends A
         // ----------------------------------------
 
         actual = userService.read(actual.getId());
-        assertEquals("virattrcache", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virattrcache", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
 
         // ----------------------------------------
         // 5. restore connector
         // ----------------------------------------
         for (ConnConfProperty prop : connInstanceBean.getConfiguration()) {
             if ("jdbcUrlTemplate".equals(prop.getSchema().getName())) {
-                prop.setValues(Collections.singletonList(jdbcURL));
+                prop.getValues().clear();
+                prop.getValues().add(jdbcURL);
             }
         }
 
@@ -408,7 +420,7 @@ public class VirAttrTestITCase extends A
         // ----------------------------------------
 
         actual = userService.read(actual.getId());
-        assertEquals("virattrcache2", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));
+        assertEquals("virattrcache2", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
     }
 
     @Test
@@ -416,10 +428,10 @@ public class VirAttrTestITCase extends A
         UserTO userTO = getUniqueSampleTO("syncope436@syncope.apache.org");
         userTO.getMemberships().clear();
         userTO.getResources().clear();
-        userTO.addResource(RESOURCE_NAME_LDAP);
-        userTO.addVirtualAttribute(attributeTO("virtualReadOnly", "readOnly"));
+        userTO.getResources().add(RESOURCE_NAME_LDAP);
+        userTO.getVirAttrs().add(attributeTO("virtualReadOnly", "readOnly"));
         userTO = createUser(userTO);
         //Finding no values because the virtual attribute is readonly 
-        assertTrue(userTO.getVirtualAttributeMap().get("virtualReadOnly").getValues().isEmpty());
+        assertTrue(userTO.getVirAttrMap().get("virtualReadOnly").getValues().isEmpty());
     }
 }