Revision: 10116
Author: ncha...@google.com
Date: Fri Apr 29 13:15:53 2011
Log: Pass the root bean class to constraint violation from
validateValue
[JSR 303 TCK Result] 124 of 257 (48.25%) Pass with 8 Failures and 7 Errors.
Review at http://gwt-code-reviews.appspot.com/1428806
Review by: rchan...@google.com
http://code.google.com/p/google-web-toolkit/source/detail?r=10116
Modified:
/trunk/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java
/trunk/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
/trunk/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateValueGwtTest.java
=======================================
---
/trunk/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java
Fri Apr 29 07:05:45 2011
+++
/trunk/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java
Fri Apr 29 13:15:53 2011
@@ -36,6 +36,7 @@
private final BeanDescriptor beanDescriptor;
private PathImpl path = new PathImpl();
+ private final Class<T> rootBeanClass;
private final T rootBean;
private final MessageInterpolator messageInterpolator;
private final AbstractGwtValidator validator;
@@ -49,15 +50,18 @@
*/
private final Set<Object> validatedObjects;
- public GwtValidationContext(T rootBean, BeanDescriptor beanDescriptor,
+ public GwtValidationContext(Class<T> rootBeanClass, T rootBean,
+ BeanDescriptor beanDescriptor,
MessageInterpolator messageInterpolator, AbstractGwtValidator
validator) {
- this(rootBean, beanDescriptor, messageInterpolator, validator,
+ this(rootBeanClass, rootBean, beanDescriptor, messageInterpolator,
+ validator,
new HashSet<Object>());
}
- private GwtValidationContext(T rootBean, BeanDescriptor beanDescriptor,
+ private GwtValidationContext(Class<T> rootBeanClass, T rootBean,
BeanDescriptor beanDescriptor,
MessageInterpolator messageInterpolator, AbstractGwtValidator
validator,
Set<Object> validatedObjects) {
+ this.rootBeanClass = rootBeanClass;
this.rootBean = rootBean;
this.beanDescriptor = beanDescriptor;
this.messageInterpolator = messageInterpolator;
@@ -79,8 +83,9 @@
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> append(String name) {
- GwtValidationContext<T> temp = new GwtValidationContext<T>(rootBean,
- beanDescriptor, messageInterpolator, validator, validatedObjects);
+ GwtValidationContext<T> temp = new
GwtValidationContext<T>(rootBeanClass,
+ rootBean, beanDescriptor, messageInterpolator, validator,
+ validatedObjects);
temp.path = path.append(name);
return temp;
}
@@ -91,8 +96,9 @@
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> appendIndex(String name, int index) {
- GwtValidationContext<T> temp = new GwtValidationContext<T>(rootBean,
- beanDescriptor, messageInterpolator, validator, validatedObjects);
+ GwtValidationContext<T> temp = new
GwtValidationContext<T>(rootBeanClass,
+ rootBean, beanDescriptor, messageInterpolator, validator,
+ validatedObjects);
temp.path = path.appendIndex(name, index);
return temp;
}
@@ -103,8 +109,9 @@
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> appendIterable(String name) {
- GwtValidationContext<T> temp = new GwtValidationContext<T>(rootBean,
- beanDescriptor, messageInterpolator, validator, validatedObjects);
+ GwtValidationContext<T> temp = new
GwtValidationContext<T>(rootBeanClass,
+ rootBean, beanDescriptor, messageInterpolator, validator,
+ validatedObjects);
temp.path = path.appendIterable(name);
return temp;
}
@@ -115,8 +122,9 @@
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> appendKey(String name, Object key) {
- GwtValidationContext<T> temp = new GwtValidationContext<T>(rootBean,
- beanDescriptor, messageInterpolator, validator, validatedObjects);
+ GwtValidationContext<T> temp = new
GwtValidationContext<T>(rootBeanClass,
+ rootBean, beanDescriptor, messageInterpolator, validator,
+ validatedObjects);
temp.path = path.appendKey(name, key);
return temp;
}
@@ -134,9 +142,8 @@
return rootBean;
}
- @SuppressWarnings("unchecked")
public Class<T> getRootBeanClass() {
- return (Class<T>) rootBean.getClass();
+ return rootBeanClass;
}
public AbstractGwtValidator getValidator() {
=======================================
---
/trunk/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
Fri Apr 29 07:05:45 2011
+++
/trunk/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
Fri Apr 29 13:15:53 2011
@@ -1028,7 +1028,7 @@
* {@link javax.validation.ReportAsSingleViolation
ReportAsSingleViolation},
* then is called recursively and the {@code violationsVar} is changed to
* match the the {@code constraintDescriptorVar}.
- *
+ *
* @param sw the Source Writer
* @param p the property
* @param elementClass The class of the Element
@@ -1043,7 +1043,7 @@
String constraintDescriptorVar, String violationsVar)
throws UnableToCompleteException {
boolean isComposite = !constraint.getComposingConstraints().isEmpty();
- boolean firstReportAsSingleViolation =
+ boolean firstReportAsSingleViolation =
constraint.isReportAsSingleViolation()
&& violationsVar.equals(DEFAULT_VIOLATION_VAR) && isComposite;
boolean reportAsSingleViolation = firstReportAsSingleViolation
@@ -1393,6 +1393,10 @@
private void writeValidatePropertyCall(SourceWriter sw,
PropertyDescriptor property, boolean useValue) {
+ if (useValue) {
+ // boolean valueTypeMatches = false;
+ sw.println("boolean valueTypeMatches = false;");
+ }
if (beanHelper.hasGetter(property)) {
if (useValue) {
// if ( value == null || value instanceof propertyType) {
@@ -1401,13 +1405,16 @@
property, false)));
sw.println(") {");
sw.indent();
+
+ // valueTypeMatches = true;
+ sw.println("valueTypeMatches = true;");
}
// validate_getMyProperty
writeValidateGetterCall(sw, property, useValue);
if (useValue) {
- // } else
+ // }
sw.outdent();
- sw.print("} else ");
+ sw.println("}");
}
}
@@ -1419,19 +1426,22 @@
property, true)));
sw.println(") {");
sw.indent();
+
+ // valueTypeMatches = true;
+ sw.println("valueTypeMatches = true;");
}
// validate_myProperty
writeValidateFieldCall(sw, property, useValue);
if (useValue) {
// } else
sw.outdent();
- sw.print("} else ");
+ sw.println("}");
}
}
if (useValue & (beanHelper.hasGetter(property) ||
beanHelper.hasField(property))) {
- // {
- sw.println(" {");
+ // if(!valueTypeMatches) {
+ sw.println("if(!valueTypeMatches) {");
sw.indent();
// throw new ValidationException(value.getClass +
=======================================
--- /trunk/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java
Mon Mar 21 12:22:19 2011
+++ /trunk/user/src/com/google/gwt/validation/rebind/ValidatorCreator.java
Fri Apr 29 13:15:53 2011
@@ -120,12 +120,16 @@
private void writeContext(SourceWriter sw, BeanHelper bean, String
objectName) {
// GwtValidationContext<T> context = new GwtValidationContext<T>(
sw.print(GwtValidationContext.class.getSimpleName());
- sw.print("<T> context =");
- sw.print(" new " + GwtValidationContext.class.getSimpleName());
- sw.println("<T>" + "(");
+ sw.print("<T> context = new ");
+ sw.print(GwtValidationContext.class.getSimpleName());
+ sw.println("<T>(");
sw.indent();
sw.indent();
+ // (Class<T>) MyBean.class,
+ sw.print("(Class<T>) ");
+ sw.println(bean.getTypeCanonicalName() + ".class, ");
+
// object,
sw.println(objectName + ", ");
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateValueGwtTest.java
Tue Jan 25 07:30:57 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateValueGwtTest.java
Fri Apr 29 13:15:53 2011
@@ -15,7 +15,6 @@
*/
package org.hibernate.jsr303.tck.tests.validation;
-import org.hibernate.jsr303.tck.util.client.Failing;
/**
* Test wrapper for {@link ValidateValueTest}.
@@ -28,12 +27,10 @@
delegate.testExistingPropertyWoConstraintsNorCascaded();
}
- @Failing(issue = 5804)
public void testValidateValue() {
delegate.testValidateValue();
}
- @Failing(issue = 5804)
public void testValidateValueFailure() {
delegate.testValidateValueFailure();
}
@@ -62,7 +59,6 @@
delegate.testValidateValueWithNullPropertyName();
}
- // This passes but the desired behavior is still not working
public void testValidIsNotHonoredValidateValue() {
delegate.testValidIsNotHonoredValidateValue();
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors