Package com.google.greaze.definition.rest

Examples of com.google.greaze.definition.rest.WebContext


        stub, MyResource.CALL_PATH, MyResource.class, new GsonBuilder(), false);
  }

  public void testPost() throws Exception {
    MyResource sent = new MyResource(10);
    MyResource received = client.post(sent, new WebContext());
    assertEquals(sent.value, received.value);
  }
View Full Code Here


  }

  public void testGet() throws Exception {
    Id<Employee> id = Id.get("1");
    employees.put(new Employee(id, "bob"));
    Employee e = client.get(id, new WebContext());
    assertEquals("bob", e.getName());
  }
View Full Code Here

    assertEquals("bob", e.getName());
  }

  public void testServerErrorOnGet() throws Exception {
    try {
      client.get(ERROR_ID, new WebContext());
      fail();
    } catch (WebServiceSystemException expected) {
      assertEquals(ErrorReason.BAD_REQUEST, expected.getReason());
    }
  }
View Full Code Here

      assertEquals(ErrorReason.BAD_REQUEST, expected.getReason());
    }
  }

  public void testPost() throws Exception {
    Employee e = client.post(new Employee("bob"), new WebContext());
    assertEquals("bob", e.getName());
    assertTrue(Id.isValid(e.getId()));
  }
View Full Code Here

    assertEquals("bob", e.getName());
    assertTrue(Id.isValid(e.getId()));
  }

  public void testPut() throws Exception {
    Employee bob = client.post(new Employee("bob"), new WebContext());
    assertEquals("bob", bob.getName());
    Employee sam = client.put(new Employee(bob.getId(), "sam"), new WebContext());
    assertEquals("sam", sam.getName());
    assertEquals(bob.getId(), sam.getId());
  }
View Full Code Here

    assertEquals("sam", sam.getName());
    assertEquals(bob.getId(), sam.getId());
  }

  public void testDelete() throws Exception {
    Employee bob = client.post(new Employee("bob"), new WebContext());
    assertEquals("bob", bob.getName());
    client.delete(bob.getId(), new WebContext());
    assertNull(client.get(bob.getId(), new WebContext()));
  }
View Full Code Here

    Preconditions.checkNotNull(callSpec);
    Gson gson = injector.getInstance(Gson.class);
    RestRequestBase<?, ?> restRequest = injector.getInstance(RestRequestBase.class);
    RestResponseBase.Builder response = new RestResponseBase.Builder(callSpec.getResponseSpec());
    RestResponseBaseBuilder responseBuilder = injector.getInstance(RestResponseBaseBuilder.class);
    WebContext context = injector.getInstance(WebContext.class);
    responseBuilder.buildResponse(context, restRequest, response);
    RestResponseBase webServiceResponse = response.build();
    RestResponseSender responseSender = new RestResponseSender(gson);
    responseSender.send(res, webServiceResponse);
  }
View Full Code Here

        new WebServiceClient(serverConfig), ServicePaths.ORDER.getCallPath(),
        QueryOrdersByItemName.class, gsonBuilder, Order.class, false);
  }

  private Cart createCart(Cart cart) {
    return cartRestClient.post(cart, new WebContext());
  }
View Full Code Here

    return cartRestClient.post(cart, new WebContext());
  }

  public Order placeOrder(Cart cart) {
    Order order = new Order(cart, cart.getId().getValue());
    return orderRestClient.post(order, new WebContext());
  }
View Full Code Here

    Order order = new Order(cart, cart.getId().getValue());
    return orderRestClient.post(order, new WebContext());
  }

  private List<Order> query(String itemName) {
    return queryClient.query(new QueryOrdersByItemName(itemName), new WebContext());
  }
View Full Code Here

TOP

Related Classes of com.google.greaze.definition.rest.WebContext

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.