Package com.google.greaze.definition.rest

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


    RequestReceiver requestReceiver = new RequestReceiver(gsonBuilder.get(), requestSpec);
    WebServiceRequest webServiceRequest = requestReceiver.receive(req);

    ResourceQueryParams queryParams =
      (ResourceQueryParams) webServiceRequest.getUrlParameters().getParamsObject();
    WebContext context = new WebContextExtractor(webContextSpec).extract(webServiceRequest.getHeaders());
    List results = resourceQuery.query(queryParams, context);
    HeaderMapSpec headerSpec = new HeaderMapSpec.Builder().build();
    HeaderMap responseHeaders = new HeaderMap.Builder(headerSpec).build();
    ResponseBodySpec bodySpec = new ResponseBodySpec.Builder()
      .setListBody(resourceQuery.getResourceType())
View Full Code Here


    this.employees = new RepositoryInMemory<Employee>(Employee.class);
    RestResponseBuilder<Employee> responseBuilder = new RestResponseBuilder<Employee>(employees);
    RestClientStub stub =
      new RestClientStubFake<Employee>(responseBuilder, Employee.class, null, gson, RESOURCE_PATH);
    this.client = new ResourceDepotClient<Employee>(stub, RESOURCE_PATH, Employee.class, gson);
    this.context = new WebContext();
  }
View Full Code Here

    ResourceQueryClient<Employee, QueryEmployeeByName> queryClient =
        new ResourceQueryClient<Employee, QueryEmployeeByName>(
            stub, queryPath, QueryEmployeeByName.class, gsonBuilder, Employee.class, false);

    QueryEmployeeByName queryByName = new QueryEmployeeByName("foo");
    List<Employee> results = queryClient.query(queryByName, new WebContext());
    assertEquals(2, results.size());
    for (Employee employee : results) {
      assertEquals("foo", employee.getName());
    }
  }
View Full Code Here

      assertEquals("foo", employee.getName());
    }
  }

  public void testParamsRoundTripWithVersion() throws Exception {
    List<Employee> results = queryClient.query(new QueryEmployeeByName("foo"), new WebContext());
    assertEquals(2, results.size());
    for (Employee employee : results) {
      assertEquals("foo", employee.getName());
    }
  }
View Full Code Here

    ResourceQueryClient<Employee, QueryEmployeeByName> queryClient =
        new ResourceQueryClient<Employee, QueryEmployeeByName>(
            stub, queryPath, QueryEmployeeByName.class, gsonBuilder, Employee.class, true);

    QueryEmployeeByName queryByName = new QueryEmployeeByName("foo");
    List<Employee> results = queryClient.query(queryByName, new WebContext());
    assertEquals(2, results.size());
    for (Employee employee : results) {
      assertEquals("foo", employee.getName());
    }
  }
View Full Code Here

    }
  }

  public void testQueryWithAServerError() {
    try {
      queryClient.query(new QueryEmployeeByName(BAD_EMPLOYEE), new WebContext());
      fail();
    } catch (WebServiceSystemException expected) {
      assertEquals(ErrorReason.BAD_REQUEST, expected.getReason());
    }
  }
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.