Examples of SimpleFooRequest


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

  }

  public void testStableId() {
    delayTestFinish(DELAY_TEST_FINISH);

    SimpleFooRequest context = simpleFooRequest();
    final SimpleFooProxy foo = context.create(SimpleFooProxy.class);
    final Object futureId = foo.getId();
    assertTrue(((SimpleEntityProxyId<?>) foo.stableId()).isEphemeral());
    Request<SimpleFooProxy> fooReq = context.persistAndReturnSelf().using(foo);

    final SimpleFooProxy newFoo = context.edit(foo);
    assertEquals(futureId, foo.getId());
    assertTrue(((SimpleEntityProxyId<?>) foo.stableId()).isEphemeral());
    assertEquals(futureId, newFoo.getId());
    assertTrue(((SimpleEntityProxyId<?>) newFoo.stableId()).isEphemeral());

    newFoo.setUserName("GWT basic user");
    fooReq.fire(new Receiver<SimpleFooProxy>() {

      @Override
      public void onSuccess(SimpleFooProxy response) {
        final SimpleFooProxy returned = checkSerialization(response);
        assertEquals(futureId, foo.getId());
        assertFalse(((SimpleEntityProxyId<?>) foo.stableId()).isEphemeral());
        assertEquals(futureId, newFoo.getId());
        assertFalse(((SimpleEntityProxyId<?>) newFoo.stableId()).isEphemeral());

        assertFalse(((SimpleEntityProxyId<?>) returned.stableId()).isEphemeral());

        checkStableIdEquals(foo, returned);
        checkStableIdEquals(newFoo, returned);
        SimpleFooRequest context = simpleFooRequest();
        Request<SimpleFooProxy> editRequest = context.persistAndReturnSelf().using(returned);
        final SimpleFooProxy editableFoo = context.edit(returned);
        editableFoo.setUserName("GWT power user");
        editRequest.fire(new Receiver<SimpleFooProxy>() {

          @Override
          public void onSuccess(SimpleFooProxy response) {
View Full Code Here

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

   * Tests that no more proxies and property values than necessary are being sent.
   */
  public void testOperationPayload() throws Exception {
    delayTestFinish(5000);

    SimpleFooRequest context = factory.simpleFooRequest();
    context.findSimpleFooById(1L).with("barField", "oneToManyField").fire(
        new Receiver<SimpleFooProxy>() {
          @Override
          public void onSuccess(final SimpleFooProxy response) {
            SimpleFooRequest context = factory.simpleFooRequest();
            final SimpleFooProxy foo = context.edit(response);

            // simply casting 'factory' to AbstractRequestFactory would fail
            // when run as a JRE test.
            final AbstractRequestFactory abstractRequestFactory =
                AutoBeanUtils.getAutoBean(foo).<AbstractRequestContext.State> getTag(
                    Constants.REQUEST_CONTEXT_STATE).requestFactory;
            final String fooTypeToken = abstractRequestFactory.getTypeToken(SimpleFooProxy.class);
            final String valueTypeToken =
                abstractRequestFactory.getTypeToken(SimpleValueProxy.class);

            // Create
            final SimpleValueProxy created = context.create(SimpleValueProxy.class);
            created.setNumber(42);
            created.setString("Hello world!");
            created.setSimpleFoo(foo);
            // Test cycles in value
            created.setSimpleValue(Arrays.asList(created));

            // Set
            foo.setSimpleValue(created);
            foo.setSimpleValues(Collections.singletonList(created));

            context.persistAndReturnSelf().using(foo).with("barField", "oneToManyField",
                "oneToManySetField", "simpleValue", "simpleValues").fire(
                new Receiver<SimpleFooProxy>() {
                  @Override
                  public void onSuccess(SimpleFooProxy response) {
                    RequestMessage requestMessage =
View Full Code Here

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

  public void testUnpersistedEchoComplexGraph() {
    delayTestFinish(DELAY_TEST_FINISH);
    final SimpleFooEventHandler<SimpleFooProxy> handler =
        new SimpleFooEventHandler<SimpleFooProxy>();
    EntityProxyChange.registerForProxyType(req.getEventBus(), SimpleFooProxy.class, handler);
    SimpleFooRequest context = req.simpleFooRequest();
    final SimpleBarProxy simpleBar = context.create(SimpleBarProxy.class);
    simpleBar.setUnpersisted(true);
    final SimpleFooProxy simpleFoo = context.create(SimpleFooProxy.class);
    simpleFoo.setUnpersisted(true);
    simpleFoo.setBarField(simpleBar);
    context.echoComplex(simpleFoo, simpleBar).with("barField").fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
        // The reconstituted object may not have the same stable id
        checkStableIdEquals(simpleBar, response.getBarField());
        response = checkSerialization(response);
View Full Code Here

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

  public void testUnpersistedEchoObject() {
    delayTestFinish(DELAY_TEST_FINISH);
    final SimpleFooEventHandler<SimpleFooProxy> handler =
        new SimpleFooEventHandler<SimpleFooProxy>();
    EntityProxyChange.registerForProxyType(req.getEventBus(), SimpleFooProxy.class, handler);
    SimpleFooRequest context = req.simpleFooRequest();
    final SimpleFooProxy simpleFoo = context.create(SimpleFooProxy.class);
    simpleFoo.setUnpersisted(true);
    context.echo(simpleFoo).fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
        response = checkSerialization(response);
        assertEquals(0, handler.totalEventCount);
        checkStableIdEquals(simpleFoo, response);
View Full Code Here

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

    });
  }

  public void testValueObjectCreateSetRetrieveUpdate() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest req = simpleFooRequest();
    req.findSimpleFooById(1L).fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
        response = checkSerialization(response);
        SimpleFooRequest req = simpleFooRequest();

        // Create
        final SimpleValueProxy created = req.create(SimpleValueProxy.class);
        created.setNumber(42);
        created.setString("Hello world!");
        created.setSimpleFoo(response);
        // Test cycles in value
        created.setSimpleValue(Arrays.asList(created));

        // Set
        response = req.edit(response);
        response.setSimpleValue(created);

        // Retrieve
        req.persistAndReturnSelf().using(response).with("simpleValue.simpleFoo",
            "simpleValue.simpleValue").to(new Receiver<SimpleFooProxy>() {
          @Override
          public void onSuccess(SimpleFooProxy response) {
            response = checkSerialization(response);
            SimpleValueProxy value = response.getSimpleValue();
            assertEquals(42, value.getNumber());
            assertEquals("Hello world!", value.getString());
            assertSame(response, value.getSimpleFoo());
            assertSame(value, value.getSimpleValue().get(0));

            try {
              // Require owning object to be editable
              response.getSimpleValue().setNumber(43);
              fail("Should have thrown exception");
            } catch (IllegalStateException expected) {
            }

            // Update
            SimpleFooRequest req = simpleFooRequest();
            response = req.edit(response);
            response.getSimpleValue().setNumber(43);
            req.persistAndReturnSelf().using(response).with("simpleValue").to(
                new Receiver<SimpleFooProxy>() {
                  @Override
                  public void onSuccess(SimpleFooProxy response) {
                    response = checkSerialization(response);
                    assertEquals(43, response.getSimpleValue().getNumber());
View Full Code Here

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

    });
  }

  public void testValueObjectCreateSetRetrieveUpdateViaList() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest req = simpleFooRequest();
    req.findSimpleFooById(1L).fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
        response = checkSerialization(response);
        SimpleFooRequest req = simpleFooRequest();

        // Create
        final SimpleValueProxy created1 = req.create(SimpleValueProxy.class);
        created1.setNumber(42);
        created1.setString("Able");
        created1.setSimpleFoo(response);
        final SimpleValueProxy created2 = req.create(SimpleValueProxy.class);
        created2.setNumber(43);
        created2.setString("Baker");
        created2.setSimpleFoo(response);

        // Set
        response = req.edit(response);
        response.setSimpleValues(Arrays.asList(created1, created2));

        // Retrieve
        req.persistAndReturnSelf().using(response).with("simpleValues").to(
            new Receiver<SimpleFooProxy>() {
              @Override
              public void onSuccess(SimpleFooProxy response) {
                response = checkSerialization(response);
                assertEquals(2, response.getSimpleValues().size());
                SimpleValueProxy value1 = response.getSimpleValues().get(0);
                assertEquals(42, value1.getNumber());
                assertEquals("Able", value1.getString());
                assertSame(response, value1.getSimpleFoo());
                SimpleValueProxy value2 = response.getSimpleValues().get(1);
                assertEquals(43, value2.getNumber());
                assertEquals("Baker", value2.getString());
                assertSame(response, value2.getSimpleFoo());

                try {
                  // Require owning object to be editable
                  response.getSimpleValues().get(0).setNumber(44);
                  fail("Should have thrown exception");
                } catch (IllegalStateException expected) {
                }

                // Update
                SimpleFooRequest req = simpleFooRequest();
                response = req.edit(response);
                response.getSimpleValues().get(0).setNumber(44);
                req.persistAndReturnSelf().using(response).with("simpleValues").to(
                    new Receiver<SimpleFooProxy>() {
                      @Override
                      public void onSuccess(SimpleFooProxy response) {
                        response = checkSerialization(response);
                        assertEquals(44, response.getSimpleValues().get(0).getNumber());
View Full Code Here

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

      }
    });
  }

  public void testValueObjectEquality() {
    SimpleFooRequest req = simpleFooRequest();
    SimpleValueProxy a = req.create(SimpleValueProxy.class);
    SimpleValueProxy b = req.create(SimpleValueProxy.class);
    checkEqualityAndHashcode(a, b);

    a.setString("Hello");
    assertFalse(a.equals(b));
    assertFalse(b.equals(a));

    b.setString("Hello");
    checkEqualityAndHashcode(a, b);

    a.setSimpleValue(Collections.singletonList(req.create(SimpleValueProxy.class)));
    assertFalse(a.equals(b));
    assertFalse(b.equals(a));
    b.setSimpleValue(Collections.singletonList(req.create(SimpleValueProxy.class)));
    checkEqualityAndHashcode(a, b);

    a.getSimpleValue().get(0).setNumber(55);
    assertFalse(a.equals(b));
    assertFalse(b.equals(a));
View Full Code Here

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

          // Ensure Dates comply with ValueProxy mutation behaviors
          a.getDate().setTime(1);
          fail();
        } catch (IllegalStateException expected) {
        }
        SimpleFooRequest ctx = simpleFooRequest();
        final SimpleValueProxy toCheck = ctx.edit(a);
        toCheck.setNumber(77);
        toCheck.getDate().setTime(1);
        ctx.returnValueProxy().fire(new Receiver<SimpleValueProxy>() {
          @Override
          public void onSuccess(SimpleValueProxy b) {
            b = checkSerialization(b);
            b = simpleFooRequest().edit(b);
            // Now check that same value is equal across contexts
View Full Code Here

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

    });
  }

  public void testValueObjectViolationsOnCreate() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest req = simpleFooRequest();
    final SimpleValueProxy value = req.create(SimpleValueProxy.class);
    value.setShouldBeNull("Hello world");

    SimpleFooProxy foo = req.create(SimpleFooProxy.class);
    foo.setSimpleValue(value);
    req.echo(foo).fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onConstraintViolation(Set<ConstraintViolation<?>> errors) {
        assertEquals(1, errors.size());
        ConstraintViolation<?> v = errors.iterator().next();
        assertEquals(value, v.getRootBean());
View Full Code Here

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

    delayTestFinish(DELAY_TEST_FINISH);
    simpleFooRequest().returnValueProxy().fire(new Receiver<SimpleValueProxy>() {
      @Override
      public void onSuccess(SimpleValueProxy response) {
        final SimpleValueProxy original = checkSerialization(response);
        SimpleFooRequest req = simpleFooRequest();
        final SimpleValueProxy value = req.edit(response);
        value.setShouldBeNull("Hello world");
        SimpleFooProxy foo = req.create(SimpleFooProxy.class);
        foo.setSimpleValue(value);
        req.echo(foo).fire(new Receiver<SimpleFooProxy>() {
          @Override
          public void onConstraintViolation(Set<ConstraintViolation<?>> errors) {
            assertEquals(1, errors.size());
            ConstraintViolation<?> v = errors.iterator().next();
            assertEquals(value, v.getRootBean());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.