Revision: 9316
Author: [email protected]
Date: Tue Nov 30 10:50:09 2010
Log: Add a definitive test for enum properties in RequestFactory.
Issue 5448.
Patch by: bobv
Review by: rchandia,rjrjr

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

http://code.google.com/p/google-web-toolkit/source/detail?r=9316

Modified:
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
 /trunk/user/test/com/google/gwt/requestfactory/shared/BaseFooProxy.java

=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Tue Nov 30 09:13:06 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Tue Nov 30 10:50:09 2010
@@ -516,6 +516,41 @@
       }
     });
   }
+
+  /**
+   * Check default value, a newly-set value, and a null value.
+   */
+  public void testEnumProperty() {
+    delayTestFinish(DELAY_TEST_FINISH);
+    simpleFooRequest().findSimpleFooById(999L).fire(
+        new Receiver<SimpleFooProxy>() {
+          @Override
+          public void onSuccess(SimpleFooProxy response) {
+            assertEquals(SimpleEnum.FOO, response.getEnumField());
+            SimpleFooRequest ctx = simpleFooRequest();
+            response = ctx.edit(response);
+            response.setEnumField(SimpleEnum.BAR);
+            ctx.persistAndReturnSelf().using(response).fire(
+                new Receiver<SimpleFooProxy>() {
+                  @Override
+                  public void onSuccess(SimpleFooProxy response) {
+                    assertEquals(SimpleEnum.BAR, response.getEnumField());
+                    SimpleFooRequest ctx = simpleFooRequest();
+                    response = ctx.edit(response);
+                    response.setEnumField(null);
+                    ctx.persistAndReturnSelf().using(response).fire(
+                        new Receiver<SimpleFooProxy>() {
+                          @Override
+                          public void onSuccess(SimpleFooProxy response) {
+                            assertNull(response.getEnumField());
+                            finishTestAndReset();
+                          }
+                        });
+                  }
+                });
+          }
+        });
+  }

   public void testFetchEntity() {
     delayTestFinish(DELAY_TEST_FINISH);
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/shared/BaseFooProxy.java Thu Nov 18 13:15:58 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/shared/BaseFooProxy.java Tue Nov 30 10:50:09 2010
@@ -97,6 +97,8 @@

   void setDoubleField(Double d);

+  void setEnumField(SimpleEnum value);
+
   void setFloatField(Float f);

   void setIntId(Integer intId);

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to