Package com.google.web.bindery.requestfactory.shared

Examples of com.google.web.bindery.requestfactory.shared.SimpleFooRequest


    context.persistAndReturnSelf().using(bar).fire(new Receiver<SimpleBarProxy>() {
      @Override
      public void onSuccess(SimpleBarProxy persistentBar) {
        persistentBar = checkSerialization(persistentBar);
        // Persist foo with bar as a child.
        SimpleFooRequest context = req.simpleFooRequest();
        SimpleFooProxy foo = context.create(SimpleFooProxy.class);
        final Request<SimpleFooProxy> persistRequest =
            context.persistAndReturnSelf().using(foo).with("barField");
        foo = context.edit(foo);
        foo.setUserName("John");
        foo.setBarField(bar);
        persistRequest.fire(new Receiver<SimpleFooProxy>() {
          @Override
          public void onSuccess(SimpleFooProxy persistentFoo) {
            persistentFoo = checkSerialization(persistentFoo);

            // Delete bar.
            SimpleFooRequest context = req.simpleFooRequest();
            final Request<Void> deleteRequest = context.deleteBar().using(persistentFoo);
            deleteRequest.fire(new Receiver<Void>() {
              @Override
              public void onSuccess(Void response) {
                assertEquals(1, fooHandler.persistEventCount);
                assertEquals(2, fooHandler.updateEventCount);
View Full Code Here


      @Override
      public void onSuccess(SimpleFooProxy newFoo) {
        newFoo = checkSerialization(newFoo);
        assertEquals(1, handler.updateEventCount);
        assertEquals(1, handler.totalEventCount);
        SimpleFooRequest context = simpleFooRequest();
        final Request<Long> mutateRequest =
            context.countSimpleFooWithUserNameSideEffect().using(newFoo);
        newFoo = context.edit(newFoo);
        newFoo.setUserName("Ray");
        mutateRequest.fire(new Receiver<Long>() {
          @Override
          public void onSuccess(Long response) {
            assertCannotFire(mutateRequest);
View Full Code Here

  }

  public void testPersistAllValueTypes() {
    delayTestFinish(DELAY_TEST_FINISH);

    SimpleFooRequest r = simpleFooRequest();
    SimpleFooProxy f = r.create(SimpleFooProxy.class);

    f.setUserName("user name");
    f.setByteField((byte) 100);
    f.setShortField((short) 12345);
    f.setFloatField(1234.56f);
    f.setDoubleField(1.2345);
    f.setLongField(1234L);
    f.setBoolField(false);
    f.setOtherBoolField(true);
    f.setCreated(new Date(397387389L));

    r.persistAndReturnSelf().using(f).fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy f) {
        f = checkSerialization(f);
        assertEquals("user name", f.getUserName());
        assertEquals(Byte.valueOf((byte) 100), f.getByteField());
View Full Code Here

        // Retrieve a Foo
        simpleFooRequest().findSimpleFooById(999L).fire(new Receiver<SimpleFooProxy>() {
          @Override
          public void onSuccess(SimpleFooProxy fooProxy) {
            fooProxy = checkSerialization(fooProxy);
            SimpleFooRequest context = simpleFooRequest();
            fooProxy = context.edit(fooProxy);
            // Make the Foo point to the Bar
            fooProxy.setBarField(barProxy);
            fooProxy.setUserName("Hello");
            fooProxy.setByteField((byte) 55);
            context.persistAndReturnSelf().using(fooProxy).with("barField").fire(
                new Receiver<SimpleFooProxy>() {
                  @Override
                  public void onSuccess(SimpleFooProxy received) {
                    received = checkSerialization(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) {
                            response = checkSerialization(response);
                            assertNull(response.getBarField());
View Full Code Here

          @Override
          public void onSuccess(SimpleFooProxy response) {
            response = checkSerialization(response);

            // Found the foo, edit it
            SimpleFooRequest context = simpleFooRequest();
            Request<Void> fooReq = context.persist().using(response);
            response = context.edit(response);
            response.setBarField(persistedBar);
            fooReq.fire(new Receiver<Void>() {
              @Override
              public void onSuccess(Void response) {
View Full Code Here

  /**
   * Ensure that a relationship can be set up between two newly-created objects.
   */
  public void testPersistFutureToFuture() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest context = simpleFooRequest();
    SimpleFooProxy newFoo = context.create(SimpleFooProxy.class);
    final SimpleBarProxy newBar = context.create(SimpleBarProxy.class);

    Request<SimpleFooProxy> fooReq = context.persistAndReturnSelf().using(newFoo).with("barField");
    newFoo = context.edit(newFoo);
    newFoo.setBarField(newBar);

    fooReq.fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
View Full Code Here

   * Entity
   */
  public void testPersistNewEntityExistingRelation() {
    delayTestFinish(DELAY_TEST_FINISH);

    SimpleFooRequest context = simpleFooRequest();
    SimpleFooProxy newFoo = context.edit(context.create(SimpleFooProxy.class));
    final Request<Void> fooReq = context.persist().using(newFoo);

    newFoo.setUserName("Ray");

    final SimpleFooProxy finalFoo = newFoo;
    simpleBarRequest().findSimpleBarById("999L").fire(new Receiver<SimpleBarProxy>() {
View Full Code Here

   * Create Entity, Persist Entity Create Entity2, Perist Entity2 relate Entity2
   * to Entity Persist
   */
  public void testPersistNewEntityNewRelation() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest context = simpleFooRequest();
    SimpleFooProxy newFoo = context.create(SimpleFooProxy.class);

    final Request<SimpleFooProxy> fooReq = context.persistAndReturnSelf().using(newFoo);
    newFoo = context.edit(newFoo);
    newFoo.setUserName("Ray");

    SimpleBarRequest context2 = simpleBarRequest();
    SimpleBarProxy newBar = context2.create(SimpleBarProxy.class);
    final Request<SimpleBarProxy> barReq = context2.persistAndReturnSelf().using(newBar);
    newBar = context2.edit(newBar);
    newBar.setUserName("Amit");

    fooReq.fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(final SimpleFooProxy response) {
        final SimpleFooProxy persistedFoo = checkSerialization(response);
        barReq.fire(new Receiver<SimpleBarProxy>() {
          @Override
          public void onSuccess(SimpleBarProxy response) {
            final SimpleBarProxy persistedBar = checkSerialization(response);

            assertEquals("Ray", persistedFoo.getUserName());
            SimpleFooRequest context = simpleFooRequest();
            final Request<Void> fooReq2 = context.persist().using(persistedFoo);
            SimpleFooProxy editablePersistedFoo = context.edit(persistedFoo);
            editablePersistedFoo.setBarField(persistedBar);
            fooReq2.fire(new Receiver<Void>() {
              @Override
              public void onSuccess(Void response) {
                req.simpleFooRequest().findSimpleFooById(persistedFoo.getId()).with(
View Full Code Here

            new Receiver<SimpleFooProxy>() {
              @Override
              public void onSuccess(SimpleFooProxy fooProxy) {
                fooProxy = checkSerialization(fooProxy);

                SimpleFooRequest context = simpleFooRequest();
                Request<SimpleFooProxy> updReq =
                    context.persistAndReturnSelf().using(fooProxy).with("oneToManyField");
                fooProxy = context.edit(fooProxy);

                List<SimpleBarProxy> barProxyList = fooProxy.getOneToManyField();
                final int listCount = barProxyList.size();
                barProxyList.add(barProxy);
                updReq.fire(new Receiver<SimpleFooProxy>() {
View Full Code Here

  }

  public void testPersistRecursiveRelation() {
    delayTestFinish(DELAY_TEST_FINISH);

    SimpleFooRequest context = simpleFooRequest();
    SimpleFooProxy rayFoo = context.create(SimpleFooProxy.class);
    final Request<SimpleFooProxy> persistRay = context.persistAndReturnSelf().using(rayFoo);
    rayFoo = context.edit(rayFoo);
    rayFoo.setUserName("Ray");
    rayFoo.setFooField(rayFoo);
    persistRay.fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
View Full Code Here

TOP

Related Classes of com.google.web.bindery.requestfactory.shared.SimpleFooRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.