Fixed testValidIsNotHonoredValidateProperty by allowing shallow property validation (not honoring the @Valid annotation) in the bean-specific validateProperty methods.

Fixes issues: 5804

Review at http://gwt-code-reviews.appspot.com/1727806

Review by: nchalko@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11037 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
index 1a875b5..9cff540 100644
--- a/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
+++ b/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
@@ -996,7 +996,7 @@
     Set<PropertyDescriptor> properties = beanHelper.getBeanDescriptor().getConstrainedProperties();
 
     for (PropertyDescriptor p : properties) {
-      writeValidatePropertyCall(sw, p, false);
+      writeValidatePropertyCall(sw, p, false, true);
     }
 
     // all class level constraints
@@ -1186,7 +1186,7 @@
   }
 
   private void writeValidateFieldCall(SourceWriter sw, PropertyDescriptor p,
-      boolean useValue) {
+      boolean useValue, boolean honorValid) {
     String propertyName = p.getPropertyName();
 
     // validateProperty_<<field>>(context,
@@ -1216,12 +1216,13 @@
     }
     sw.print(", ");
 
-    // groups));
-    sw.println("groups);");
+    // honorValid, groups);
+    sw.print(Boolean.toString(honorValid));
+    sw.println(", groups);");
   }
 
   private void writeValidateGetterCall(SourceWriter sw, PropertyDescriptor p,
-      boolean useValue) {
+      boolean useValue, boolean honorValid) {
     // validateProperty_get<<field>>(context, violations,
     sw.print(validateMethodGetterName(p));
     sw.print("(context, ");
@@ -1250,8 +1251,9 @@
     }
     sw.print(", ");
 
-    // groups);
-    sw.println("groups);");
+    // honorValid, groups);
+    sw.print(Boolean.toString(honorValid));
+    sw.println(", groups);");
   }
 
   private void writeValidateInheritance(SourceWriter sw, Class<?> clazz,
@@ -1397,7 +1399,7 @@
       sw.println("\")) {");
       sw.indent();
 
-      writeValidatePropertyCall(sw, property, false);
+      writeValidatePropertyCall(sw, property, false, false);
 
       // validate all super classes and interfaces
       writeValidateInheritance(sw, beanHelper.getClazz(), Stage.PROPERTY,
@@ -1424,7 +1426,7 @@
   }
 
   private void writeValidatePropertyCall(SourceWriter sw,
-      PropertyDescriptor property, boolean useValue) {
+      PropertyDescriptor property, boolean useValue, boolean honorValid) {
     if (useValue) {
       // boolean valueTypeMatches = false;
       sw.println("boolean valueTypeMatches = false;");
@@ -1442,7 +1444,7 @@
         sw.println("valueTypeMatches = true;");
       }
       // validate_getMyProperty
-      writeValidateGetterCall(sw, property, useValue);
+      writeValidateGetterCall(sw, property, useValue, honorValid);
       if (useValue) {
         // }
         sw.outdent();
@@ -1463,7 +1465,7 @@
         sw.println("valueTypeMatches = true;");
       }
       // validate_myProperty
-      writeValidateFieldCall(sw, property, useValue);
+      writeValidateFieldCall(sw, property, useValue, honorValid);
       if (useValue) {
         // } else
         sw.outdent();
@@ -1511,12 +1513,15 @@
 
     // BeanType object,
     sw.println(beanHelper.getTypeCanonicalName() + " object,");
-
+    
     // final <Type> value,
     sw.print("final ");
     sw.print(elementType.getParameterizedQualifiedSourceName());
     sw.println(" value,");
-
+    
+    // boolean honorValid,
+    sw.println("boolean honorValid,");
+    
     // Class<?>... groups) {
     sw.println("Class<?>... groups) {");
     sw.outdent();
@@ -1529,20 +1534,18 @@
     // TODO(nchalko) move this out of here to the Validate method
     if (p.isCascaded() && hasValid(p, useField)) {
 
-      // if(value != null) {
-      sw.println("if(value != null) {");
+      // if(honorValid && value != null) {
+      sw.println("if(honorValid && value != null) {");
       sw.indent();
 
       if (isIterableOrMap(elementClass)) {
-        if (hasValid(p, useField)) {
-          JClassType associationType = beanHelper.getAssociationType(p,
-              useField);
-          createBeanHelper(associationType);
-          if (Map.class.isAssignableFrom(elementClass)) {
-            writeValidateMap(sw, p);
-          } else {
-            writeValidateIterable(sw, p);
-          }
+        JClassType associationType = beanHelper.getAssociationType(p,
+            useField);
+        createBeanHelper(associationType);
+        if (Map.class.isAssignableFrom(elementClass)) {
+          writeValidateMap(sw, p);
+        } else {
+          writeValidateIterable(sw, p);
         }
       } else {
         createBeanHelper(elementClass);
@@ -1621,7 +1624,7 @@
       sw.indent();
 
       if (!isIterableOrMap(property.getElementClass())) {
-        writeValidatePropertyCall(sw, property, true);
+        writeValidatePropertyCall(sw, property, true, true);
       }
 
       // validate all super classes and interfaces
diff --git a/user/test/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyGwtTest.java b/user/test/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyGwtTest.java
index f4b340b..c7a21b4 100644
--- a/user/test/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyGwtTest.java
+++ b/user/test/org/hibernate/jsr303/tck/tests/validation/ValidatePropertyGwtTest.java
@@ -15,8 +15,6 @@
  */
 package org.hibernate.jsr303.tck.tests.validation;
 
-import org.hibernate.jsr303.tck.util.client.Failing;
-
 import javax.validation.ValidationException;
 
 /**
@@ -62,7 +60,6 @@
     delegate.testValidatePropertyWithNullProperty();
   }
 
-  @Failing(issue = 5804)
   public void testValidIsNotHonoredValidateProperty() {
     delegate.testValidIsNotHonoredValidateProperty();
   }