Package com.google.greaze.definition.webservice

Examples of com.google.greaze.definition.webservice.RequestBodySpec


  private String bodyToJson(WebServiceRequestInlined inlinedBody) {
    return gson.toJson(inlinedBody);
  }

  private String bodyToJson(RequestBody requestBody) {
    RequestBodySpec spec = requestBody.getSpec();
    switch (spec.getContentBodyType()) {
      case SIMPLE:
        return gson.toJson(requestBody.getSimpleBody(), spec.getBodyJavaType());
      case LIST:
        return gson.toJson(requestBody.getListBody(), spec.getBodyJavaType());
      case MAP:
        return gson.toJson(requestBody, spec.getBodyJavaType());
      default:
        throw new UnsupportedOperationException();
    }
  }
View Full Code Here


public class RequestReceiverTest extends TestCase {
 
  public void testUrlParams() {
    HeaderMapSpec headersSpec = new HeaderMapSpec.Builder().build();
    UrlParamsSpec urlParamSpec = new UrlParamsSpec.Builder().put("foo", String.class).build();
    RequestBodySpec bodySpec = new RequestBodySpec.Builder().build();
    RequestSpec spec = new RequestSpec(headersSpec, urlParamSpec, bodySpec);
    RequestReceiver receiver = new RequestReceiver(new GsonBuilder(), spec);
    HttpServletRequest req = new HttpServletRequestFake()
      .setRequestMethod("GET")
      .setUrlParam("foo", "bar");
View Full Code Here

  }

  public void testContentTypeHeaderSkippedForGetAndDelete() {
    HeaderMapSpec requestHeaderSpec = new HeaderMapSpec.Builder().build();
    HeaderMap requestHeaders = new HeaderMap.Builder(requestHeaderSpec).build();
    RequestBodySpec requestBodySpec = new RequestBodySpec.Builder()
      .setSimpleBody(String.class)
      .build();
    RequestBody requestBody = new RequestBody.Builder(requestBodySpec).build();
    for (HttpMethod method : new HttpMethod[]{HttpMethod.GET, HttpMethod.DELETE}) {
      HttpUrlConnectionMock conn = new HttpUrlConnectionMock();
View Full Code Here

  }

  public void testBodyAndContentTypeHeaderForPostAndPut() {
    HeaderMapSpec requestHeaderSpec = new HeaderMapSpec.Builder().build();
    HeaderMap requestHeaders = new HeaderMap.Builder(requestHeaderSpec).build();
    RequestBodySpec requestBodySpec = new RequestBodySpec.Builder()
      .setSimpleBody(String.class)
      .build();
    RequestBody requestBody = new RequestBody.Builder(requestBodySpec)
      .setSimpleBody("hello world")
      .build();
View Full Code Here

    CallPath callPath = new CallPathParser(null, false, "/resource").parse(CALL_PATH);
    callSpec = new WebServiceCallSpec.Builder(callPath).build();
    HeaderMapSpec headerSpec = new HeaderMapSpec.Builder().build();
    requestHeaders = new HeaderMap.Builder(headerSpec).build();
    RequestBodySpec requestBodySpec = new RequestBodySpec.Builder().build();
    requestBody = new RequestBody.Builder(requestBodySpec).build();
  }
View Full Code Here

      new RestRequestSpec(requestHeaders.getSpec(), resourceType), inlined);
    this.id = resourceId;
  }

  private static<R> RequestBody createBody(R resource, Type resourceType) {
    RequestBodySpec spec = new RequestBodySpec(ContentBodyType.SIMPLE, null, resourceType);
    return new RequestBody.Builder(spec)
        .setSimpleBody(resource)
        .build();
  }
View Full Code Here

TOP

Related Classes of com.google.greaze.definition.webservice.RequestBodySpec

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.