Revision: 8922
Author: [email protected]
Date: Sun Oct  3 10:39:43 2010
Log: Add test to verify fix of ROO-1215
Patch by: bobv
Review by: rjrjr

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

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

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

=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Sat Oct 2 12:01:57 2010 +++ /trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java Sun Oct 3 10:39:43 2010
@@ -808,32 +808,54 @@
         });
   }

-  /*
- * TODO: all these tests should check the final values. It will be easy when
-   * we have better persistence than the singleton pattern.
-   */
   public void testPersistExistingEntityExistingRelation() {
     delayTestFinish(5000);

+    // Retrieve a Bar
     simpleBarRequest().findSimpleBarById("999L").fire(
         new Receiver<SimpleBarProxy>() {
           @Override
           public void onSuccess(final SimpleBarProxy barProxy) {
+            // Retrieve a Foo
             simpleFooRequest().findSimpleFooById(999L).fire(
                 new Receiver<SimpleFooProxy>() {
                   @Override
                   public void onSuccess(SimpleFooProxy fooProxy) {
                     SimpleFooRequest context = simpleFooRequest();
- Request<Void> updReq = context.persist().using(fooProxy);
                     fooProxy = context.edit(fooProxy);
+                    // Make the Foo point to the Bar
                     fooProxy.setBarField(barProxy);
-                    updReq.fire(new Receiver<Void>() {
-                      @Override
-                      public void onSuccess(Void response) {
-
-                        finishTestAndReset();
-                      }
-                    });
+                    fooProxy.setUserName("Hello");
+                    fooProxy.setByteField((byte) 55);
+                    context.persistAndReturnSelf().using(fooProxy).fire(
+                        new Receiver<SimpleFooProxy>() {
+                          @Override
+                          public void onSuccess(SimpleFooProxy received) {
+                            // Check that Foo points to Bar
+                            assertNotNull(received.getBarField());
+                            assertEquals(barProxy.stableId(),
+                                received.getBarField().stableId());
+                            assertEquals("Hello", received.getUserName());
+                            assertTrue(55 == received.getByteField());
+
+                            // Unset the association
+                            SimpleFooRequest context = simpleFooRequest();
+                            received = context.edit(received);
+                            received.setBarField(null);
+                            received.setUserName(null);
+                            received.setByteField(null);
+ context.persistAndReturnSelf().using(received).fire(
+                                new Receiver<SimpleFooProxy>() {
+                                  @Override
+ public void onSuccess(SimpleFooProxy response) {
+                                    assertNull(response.getBarField());
+                                    assertNull(response.getUserName());
+                                    assertNull(response.getByteField());
+                                    finishTestAndReset();
+                                  }
+                                });
+                          }
+                        });
                   }
                 });
           }

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

Reply via email to