You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by co...@apache.org on 2012/08/15 14:53:28 UTC

svn commit: r1373381 - in /incubator/syncope/trunk: ./ core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Author: coheigea
Date: Wed Aug 15 12:53:27 2012
New Revision: 1373381

URL: http://svn.apache.org/viewvc?rev=1373381&view=rev
Log:
[SYNCOPE-183] - 'Enforce mandatory constraints' not working

Modified:
    incubator/syncope/trunk/   (props changed)
    incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
    incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Propchange: incubator/syncope/trunk/
------------------------------------------------------------------------------
  Merged /incubator/syncope/branches/1_0_X:r1373378

Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java?rev=1373381&r1=1373380&r2=1373381&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java Wed Aug 15 12:53:27 2012
@@ -263,7 +263,7 @@ public abstract class AbstractAttributab
                     attributableUtil))) {
 
                 LOG.error("Mandatory schema " + schema.getName() + " not provided with values");
-
+                
                 requiredValuesMissing.addElement(schema.getName());
             }
         }
@@ -661,11 +661,6 @@ public abstract class AbstractAttributab
             compositeErrorException.addException(invalidValues);
         }
 
-        SyncopeClientException requiredValuesMissing = checkMandatory(attributableUtil, attributable);
-        if (!requiredValuesMissing.isEmpty()) {
-            compositeErrorException.addException(requiredValuesMissing);
-        }
-
         // 2. derived attributes
         AbstractDerSchema derivedSchema;
         AbstractDerAttr derivedAttribute;
@@ -707,6 +702,11 @@ public abstract class AbstractAttributab
                 attributable.addResource(resource);
             }
         }
+        
+        SyncopeClientException requiredValuesMissing = checkMandatory(attributableUtil, attributable);
+        if (!requiredValuesMissing.isEmpty()) {
+            compositeErrorException.addException(requiredValuesMissing);
+        }
 
         // Throw composite exception if there is at least one element set
         // in the composing exceptions

Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1373381&r1=1373380&r2=1373381&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Wed Aug 15 12:53:27 2012
@@ -308,6 +308,35 @@ public class UserTestITCase extends Abst
         }
         assertNull(sce);
     }
+    
+    @Test
+    public void testMandatoryContraintsUserCreation() {
+        UserTO userTO = getSampleTO("issue183@apache.org");
+        userTO.addResource("ws-target-resource-2");
+        userTO.setPassword("newPassword");
+        
+        AttributeTO type = null;
+        for (AttributeTO attr : userTO.getAttributes()) {
+            if ("type".equals(attr.getSchema())) {
+                type = attr;
+            }
+        }
+        assertNotNull(type);
+        userTO.removeAttribute(type);
+
+        SyncopeClientException sce = null;
+        try {
+            userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
+        } catch (SyncopeClientCompositeErrorException scce) {
+            sce = scce.getException(SyncopeClientExceptionType.RequiredValuesMissing);
+        }
+        assertNotNull(sce);
+        
+        userTO.addAttribute(type);
+        
+        userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
+        assertNotNull(userTO);
+    }
 
     @Test
     public void issue147() {