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

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


                count[0]++;
              }
            });
    delayTestFinish(TEST_DELAY);
    SimpleFooRequest context = req.simpleFooRequest();
    SimpleFooProxy proxy = context.create(SimpleFooProxy.class);
    context.persistAndReturnSelf().using(proxy).fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
        // Persist and Update events
        assertEquals(2, count[0]);
View Full Code Here


  public void testGenericRequest() {
    TestRequestFactory rf = GWT.create(TestRequestFactory.class);
    EventBus eventBus = new SimpleEventBus();
    rf.initialize(eventBus);
    SimpleFooProxy simpleFoo = rf.testGenericRequest().create(SimpleFooProxy.class);
    assertNull(simpleFoo.getUserName());
  }
View Full Code Here

  }

  public void testServerFailureCheckedException() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest context = req.simpleFooRequest();
    SimpleFooProxy rayFoo = context.create(SimpleFooProxy.class);
    final Request<SimpleFooProxy> persistRay = context.persistAndReturnSelf().using(
        rayFoo);
    rayFoo = context.edit(rayFoo);
    // 42 is the crash causing magic number
    rayFoo.setPleaseCrash(42);
    persistRay.fire(new SimpleFooFailureReceiver(rayFoo, persistRay,
        "java.lang.UnsupportedOperationException"));
  }
View Full Code Here

  }

  public void testServerFailureRuntimeException() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest context = req.simpleFooRequest();
    SimpleFooProxy rayFoo = context.create(SimpleFooProxy.class);
    final Request<SimpleFooProxy> persistRay = context.persistAndReturnSelf().using(
        rayFoo);
    rayFoo = context.edit(rayFoo);
    // 43 is the crash causing magic number
    rayFoo.setPleaseCrash(43);
    persistRay.fire(new SimpleFooFailureReceiver(rayFoo, persistRay, "java.lang.Exception"));
  }
View Full Code Here

    final RuntimeException exception1 = new RuntimeException("first exception");
    final RuntimeException exception2 = new RuntimeException("second exception");
    final CountingReceiver count = new CountingReceiver();

    SimpleFooRequest context = req.simpleFooRequest();
    SimpleFooProxy newFoo = context.create(SimpleFooProxy.class);

    context.returnNullString().to(count);
    context.persist().using(newFoo).to(new ThrowingReceiver<Void>(exception1));
    context.returnNullString().to(count);

    final SimpleFooProxy mutableFoo = context.edit(newFoo);
    // 42 is the crash causing magic number for a runtime exception
    mutableFoo.setPleaseCrash(42);

    fireContextAndCatch(context, new ThrowingReceiver<Void>(exception2), new ExceptionVerifier() {
      @Override
      public void verify(Throwable e) {
        assertUmbrellaException(e, exception1, exception2);
View Full Code Here

    final RuntimeException exception1 = new RuntimeException("first exception");
    final RuntimeException exception2 = new RuntimeException("second exception");
    final CountingReceiver count = new CountingReceiver();

    SimpleFooRequest context = req.simpleFooRequest();
    SimpleFooProxy newFoo = context.create(SimpleFooProxy.class);
    newFoo.setUserName("a"); // too short

    context.returnNullString().to(count);
    context.persist().using(newFoo).to(new ThrowingReceiver<Void>(exception1));
    context.returnNullString().to(count);
View Full Code Here

   * Test that we can commit child objects.
   */
  public void testCascadingCommit() {
    delayTestFinish(DELAY_TEST_FINISH);
    SimpleFooRequest context = req.simpleFooRequest();
    final SimpleFooProxy foo = context.create(SimpleFooProxy.class);
    final SimpleBarProxy bar0 = context.create(SimpleBarProxy.class);
    final SimpleBarProxy bar1 = context.create(SimpleBarProxy.class);
    final SimpleBarProxy bar2 = context.create(SimpleBarProxy.class);
    final SimpleBarProxy bar3 = context.create(SimpleBarProxy.class);
    final SimpleBarProxy bar4 = context.create(SimpleBarProxy.class);
    List<SimpleBarProxy> bars = new ArrayList<SimpleBarProxy>();
    bars.add(bar0);
    bars.add(bar1);

    Map<SimpleBarProxy, Integer> barAsKeyMap = new HashMap<SimpleBarProxy, Integer>();
    barAsKeyMap.put(bar2, 4);
    barAsKeyMap.put(bar3, 21);

    Map<Integer, SimpleBarProxy> barAsValueMap = new HashMap<Integer, SimpleBarProxy>();
    barAsValueMap.put(41, bar2);
    barAsValueMap.put(141, bar3);
    barAsValueMap.put(43, bar4);

    final SimpleFooEventHandler<SimpleBarProxy> handler =
        new SimpleFooEventHandler<SimpleBarProxy>();
    EntityProxyChange.registerForProxyType(req.getEventBus(), SimpleBarProxy.class, handler);

    Request<SimpleFooProxy> request = context.persistCascadingAndReturnSelf().using(foo);
    SimpleFooProxy editFoo = context.edit(foo);
    editFoo.setOneToManyField(bars);
    editFoo.setSimpleBarKeyMap(barAsKeyMap);
    editFoo.setSimpleBarValueMap(barAsValueMap);

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

   */
  public void testCreatePersistCascadingAndReturnSelfEditWithReferences() {
    delayTestFinish(DELAY_TEST_FINISH);

    SimpleFooRequest context = simpleFooRequest();
    SimpleFooProxy foo = context.create(SimpleFooProxy.class);
    SimpleBarProxy bar = context.create(SimpleBarProxy.class);
    foo.setBarField(bar);
    Request<SimpleFooProxy> fooReq = context.persistCascadingAndReturnSelf()
        .using(foo).with("barField");
    fooReq.fire(new Receiver<SimpleFooProxy>() {

      @Override
View Full Code Here

    simpleFooRequest().findSimpleFooById(1L).fire(new Receiver<SimpleFooProxy>() {
      @Override
      public void onSuccess(SimpleFooProxy response) {
        SimpleFooRequest context = simpleFooRequest();
        SimpleFooProxy foo = context.edit(response);
        SimpleBarProxy bar = context.create(SimpleBarProxy.class);
        foo.setBarField(bar);
        Request<SimpleFooProxy> fooReq = context.persistCascadingAndReturnSelf()
            .using(foo).with("barField");
        fooReq.fire(new Receiver<SimpleFooProxy>() {

          @Override
View Full Code Here

  public void testChangedCreate() {
    SimpleFooRequest context = simpleFooRequest();

    // Creates don't cause a change
    SimpleFooProxy foo = context.create(SimpleFooProxy.class);
    assertFalse(context.isChanged());

    // Change
    foo.setCharField('c');
    assertTrue(context.isChanged());

    // Undo the change
    foo.setCharField(null);
    assertFalse(context.isChanged());
  }
View Full Code Here

TOP

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

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.