Revision: 9837
Author: [email protected]
Date: Thu Mar 10 05:54:28 2011
Log: Support paths for iterables without a key or an index.
[JSR 303 TCK Result] 116 of 257 (45.14%) Pass with 14 Failures and 9 Errors.
Review at http://gwt-code-reviews.appspot.com/1369810
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9837
Modified:
/trunk/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java
/trunk/user/src/com/google/gwt/validation/client/impl/NodeImpl.java
/trunk/user/src/com/google/gwt/validation/client/impl/PathImpl.java
/trunk/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
/trunk/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/PropertyPathGwtTest.java
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateGwtTest.java
=======================================
---
/trunk/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java
Wed Mar 9 07:47:09 2011
+++
/trunk/user/src/com/google/gwt/validation/client/impl/GwtValidationContext.java
Thu Mar 10 05:54:28 2011
@@ -76,7 +76,6 @@
/**
* Append a node named name to the path..
*
- * @param name
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> append(String name) {
@@ -87,9 +86,8 @@
}
/**
- * Append a indexed node to the path.
+ * Append an indexed node to the path.
*
- * @param name
* @return the new GwtValidationContext.
*/
public GwtValidationContext<T> appendIndex(String name, int index) {
@@ -98,6 +96,18 @@
temp.path = path.appendIndex(name, index);
return temp;
}
+
+ /**
+ * Append an iterable node to the path.
+ *
+ * @return the new GwtValidationContext.
+ */
+ public GwtValidationContext<T> appendIterable(String name) {
+ GwtValidationContext<T> temp = new GwtValidationContext<T>(rootBean,
+ beanDescriptor, messageInterpolator, validator, validatedObjects);
+ temp.path = path.appendIterable(name);
+ return temp;
+ }
/**
* Append a keyed node to the path.
=======================================
--- /trunk/user/src/com/google/gwt/validation/client/impl/NodeImpl.java Thu
Sep 16 04:46:26 2010
+++ /trunk/user/src/com/google/gwt/validation/client/impl/NodeImpl.java Thu
Mar 10 05:54:28 2011
@@ -25,51 +25,36 @@
class NodeImpl implements Node, Serializable {
private static final long serialVersionUID = 1L;
- public static final Node ROOT_NODE = new NodeImpl(null);
-
+ public static final Node ROOT_NODE = new NodeImpl(null, null, null,
false);
+
+ static Node createIndexedNode(String name, Integer index) {
+ return new NodeImpl(name, null, index, true);
+ }
+
+ static Node createIterableNode(String name) {
+ return new NodeImpl(name, null, null, true);
+ }
+
+ static Node createKeyedNode(String name, Object key) {
+ return new NodeImpl(name, key, null, true);
+ }
+
+ static Node createNode(String name) {
+ return new NodeImpl(name, null, null, false);
+ }
+
+ private final boolean isInIterable;
private final String name;
private final Integer index;
+
private final Object key;
- /**
- * Create a non iterable node.
- *
- * @param name the possibly <code>null</code> name.
- */
- public NodeImpl(String name) {
- this.name = name;
- this.index = null;
- this.key = null;
- }
-
- /**
- * Create an iterable node with an index.
- *
- * @param name the possibly <code>null</code> name.
- * @param index the zero based index.
- */
- public NodeImpl(String name, int index) {
- if (index < 0) {
- throw new IllegalArgumentException("Index can not be negative.");
- }
+
+ private NodeImpl(String name, Object key, Integer index, boolean
iterable) {
this.name = name;
- this.index = Integer.valueOf(index);
- this.key = null;
- }
-
- /**
- * Create an iterable node with a key.
- *
- * @param name the possibly <code>null</code> name.
- * @param key the lookup key for this node.
- */
- public NodeImpl(String name, Object key) {
- if (key == null) {
- throw new NullPointerException();
- }
- this.name = name;
- this.index = null;
this.key = key;
+ this.index = index;
+ this.isInIterable = iterable;
}
@Override
@@ -81,9 +66,11 @@
return false;
}
NodeImpl that = (NodeImpl) obj;
- return (this.name == null ? that.name == null : this.name == that.name)
- && (this.index == null ? that.index == null : this.index ==
that.index)
- && (this.key == null ? that.key == null : this.key == that.key);
+ return (this.name == null ? that.name == null :
this.name.equals(that.name))
+ && (this.index == null ? that.index == null : this.index
+ .equals(that.index))
+ && (this.key == null ? that.key == null :
this.key.equals(that.key))
+ && this.isInIterable == that.isInIterable;
}
public Integer getIndex() {
@@ -105,11 +92,12 @@
result = prime * result + ((index == null) ? 0 : index.hashCode());
result = prime * result + ((key == null) ? 0 : key.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + (isInIterable ? 0 : 1);
return result;
}
public boolean isInIterable() {
- return index != null || key != null;
+ return isInIterable;
}
@Override
@@ -122,7 +110,7 @@
sb.append('[');
if (key != null) {
sb.append(key);
- } else {
+ } else if (index != null) {
sb.append(index);
}
sb.append(']');
=======================================
--- /trunk/user/src/com/google/gwt/validation/client/impl/PathImpl.java Wed
Jan 12 17:43:21 2011
+++ /trunk/user/src/com/google/gwt/validation/client/impl/PathImpl.java Thu
Mar 10 05:54:28 2011
@@ -54,11 +54,11 @@
* @return The new path with appended node.
*/
public PathImpl append(String name) {
- return new PathImpl(this, new NodeImpl(name));
+ return new PathImpl(this, NodeImpl.createNode(name));
}
/**
- * Create a new path with a indexed node named <code>name</code>
appended to
+ * Create a new path with an indexed node named <code>name</code>
appended to
* the existing path.
*
* @param name
@@ -66,7 +66,18 @@
* @return The new path with appended node.
*/
public PathImpl appendIndex(String name, int index) {
- return new PathImpl(this, new NodeImpl(name, index));
+ return new PathImpl(this, NodeImpl.createIndexedNode(name, index));
+ }
+
+ /**
+ * Create a new path with an iterable node named <code>name</code>
appended to
+ * the existing path.
+ *
+ * @param name
+ * @return The new path with appended node.
+ */
+ public PathImpl appendIterable(String name) {
+ return new PathImpl(this, NodeImpl.createIterableNode(name));
}
/**
@@ -78,7 +89,7 @@
* @return The new path with appended node.
*/
public PathImpl appendKey(String name, Object key) {
- return new PathImpl(this, new NodeImpl(name, key));
+ return new PathImpl(this, NodeImpl.createKeyedNode(name, key));
}
@Override
=======================================
---
/trunk/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
Wed Mar 9 07:47:09 2011
+++
/trunk/user/src/com/google/gwt/validation/rebind/GwtSpecificValidatorCreator.java
Thu Mar 10 05:54:28 2011
@@ -1139,10 +1139,18 @@
sw.indent();
sw.indent();
- // context.appendIndex("myProperty",i++),
- sw.print("context.appendIndex(\"");
- sw.print(p.getPropertyName());
- sw.println("\",i++),");
+ Class<?> elementClass = p.getElementClass();
+ if (elementClass.isArray() ||
List.class.isAssignableFrom(elementClass)) {
+ // context.appendIndex("myProperty",i++),
+ sw.print("context.appendIndex(\"");
+ sw.print(p.getPropertyName());
+ sw.println("\",i),");
+ } else {
+ // context.appendIterable("myProperty"),
+ sw.print("context.appendIterable(\"");
+ sw.print(p.getPropertyName());
+ sw.println("\"),");
+ }
// instance, groups));
sw.println("instance, groups));");
@@ -1155,6 +1163,9 @@
sw.outdent();
sw.println("}");
+ // i++;
+ sw.println("i++;");
+
// }
sw.outdent();
sw.println("}");
=======================================
---
/trunk/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java
Fri Sep 3 12:24:52 2010
+++
/trunk/user/test/com/google/gwt/validation/client/impl/NodeImplTest.java
Thu Mar 10 05:54:28 2011
@@ -24,21 +24,25 @@
*/
public class NodeImplTest extends TestCase {
- public void testRoot() throws Exception {
- assertNode(NodeImpl.ROOT_NODE, null, false, null, null);
+ public void testFoo() throws Exception {
+ assertNode(NodeImpl.createNode("foo"), "foo", false, null, null);
}
- public void testFoo() throws Exception {
- assertNode(new NodeImpl("foo"), "foo", false, null, null);
+ public void testFoo_iterable() throws Exception {
+ assertNode(NodeImpl.createIterableNode("foo"), "foo", true, null,
null);
}
public void testFoo1() throws Exception {
- assertNode(new NodeImpl("foo", 1), "foo", true, null,
+ assertNode(NodeImpl.createIndexedNode("foo", 1), "foo", true, null,
Integer.valueOf(1));
}
public void testFooBar() throws Exception {
- assertNode(new NodeImpl("foo", "bar"), "foo", true, "bar", null);
+ assertNode(NodeImpl.createKeyedNode("foo", "bar"), "foo", true, "bar",
null);
+ }
+
+ public void testRoot() throws Exception {
+ assertNode(NodeImpl.ROOT_NODE, null, false, null, null);
}
protected void assertNode(Node node, String expectedName,
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java
Wed Mar 9 12:43:13 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionGwtTest.java
Thu Mar 10 05:54:28 2011
@@ -43,7 +43,6 @@
delegate.testComposedConstraintsAreRecursive();
}
- @Failing(issue = 5799)
public void testEachFailingConstraintCreatesConstraintViolation() {
delegate.testEachFailingConstraintCreatesConstraintViolation();
}
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/PropertyPathGwtTest.java
Wed Mar 9 07:47:09 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/PropertyPathGwtTest.java
Thu Mar 10 05:54:28 2011
@@ -32,9 +32,7 @@
delegate.testPropertyPathTraversedObject();
}
- @Failing(issue = 5982)
public void testPropertyPathWithArray() {
- fail("Force an early failure for Issue 5982 to prevent all following
tests from failing.");
delegate.testPropertyPathWithArray();
}
@@ -42,9 +40,7 @@
delegate.testPropertyPathWithConstraintViolationForRootObject();
}
- @Failing(issue = 5982)
public void testPropertyPathWithList() {
- fail("Force an early failure for Issue 5982 to prevent all following
tests from failing.");
delegate.testPropertyPathWithList();
}
=======================================
---
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateGwtTest.java
Tue Feb 22 10:50:07 2011
+++
/trunk/user/test/org/hibernate/jsr303/tck/tests/validation/ValidateGwtTest.java
Thu Mar 10 05:54:28 2011
@@ -34,15 +34,13 @@
delegate.testConstraintViolation();
}
- @Failing(issue = 5982)
+ @Failing(issue = 5930)
public void testGraphValidationWithArray() {
- fail("Force an early failure for Issue 5982 to prevent all following
tests from failing.");
delegate.testGraphValidationWithArray();
}
- @Failing(issue = 5982)
+ @Failing(issue = 5930)
public void testGraphValidationWithList() {
- fail("Force an early failure for Issue 5982 to prevent all following
tests from failing.");
delegate.testGraphValidationWithList();
}
@@ -103,7 +101,6 @@
}
}
- @Failing(issue = 5930)
public void testValidationIsPolymorphic() {
delegate.testValidationIsPolymorphic();
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors