@Test public void anImplementation() throws IOException, InterruptedException, ExecutionException { server.enqueue(new MockResponse().setBody("{\"theName\":\"value\"}")); GsonRequest<AnImplementation> request = new GsonRequest<AnImplementation>(Request.Method.POST, server.url("").toString(), AnImplementation.class) .setRequestData(new AnImplementation("value"), gson); AnImplementation body = queue.add(request) .getFuture().get(); assertThat(body.theName).isEqualTo("value"); RecordedRequest sRequest = server.takeRequest(); assertThat(sRequest.getBody().readUtf8()).isEqualTo("{\"theName\":\"value\"}"); assertThat(sRequest.getHeader("Content-Type")).isEqualTo("application/json; charset=UTF-8"); assertThat(sRequest.getHeader("Accept")).isEqualTo("application/json"); }
public <R> GsonRequest<T> setRequestData(R requestData, Gson gson, TypeAdapter adapter) { try { super.setRequestData(requestData, new GsonRequestConverter<>(gson, adapter)); } catch (IOException e) { throw new RuntimeException("Unable to convert " + requestData + " to NetworkRequest", e); } setNetworkRequest(NetworkRequest.Builder.from(getNetworkRequest()) .setHeader("Accept", "application/json") .build()); return this; }
GsonRequest extends Request<T> { public <R> GsonRequest<T> setRequestData(R requestData, Gson gson, TypeAdapter adapter) { try { super.setRequestData(requestData, new GsonRequestConverter<>(gson, adapter)); } catch (IOException e) { throw new RuntimeException("Unable to convert " + requestData + " to NetworkRequest", e); } setNetworkRequest(NetworkRequest.Builder.from(getNetworkRequest()) .setHeader("Accept", "application/json") .build()); return this; } }
GsonRequest extends Request<T> { public <R> GsonRequest<T> setRequestData(R requestData, Gson gson, TypeAdapter adapter) { try { super.setRequestData(requestData, new GsonRequestConverter<>(gson, adapter)); } catch (IOException e) { throw new RuntimeException("Unable to convert " + requestData + " to NetworkRequest", e); } setNetworkRequest(NetworkRequest.Builder.from(getNetworkRequest()) .setHeader("Accept", "application/json") .build()); return this; } GsonRequest(String method, HttpUrl url, TypeAdapter<T> typeAdapter);  GsonRequest(String method, HttpUrl url, Class<T> tClass, Gson gson);  GsonRequest(String method, HttpUrl url, Class<T> tClass);  GsonRequest(String method, String url, TypeAdapter<T> typeAdapter);  GsonRequest(String method, String url, Class<T> tClass, Gson gson);  GsonRequest(String method, String url, Class<T> tClass); }
GsonRequest extends Request<T> { public <R> GsonRequest<T> setRequestData(R requestData, Gson gson, TypeAdapter adapter) { try { super.setRequestData(requestData, new GsonRequestConverter<>(gson, adapter)); } catch (IOException e) { throw new RuntimeException("Unable to convert " + requestData + " to NetworkRequest", e); } setNetworkRequest(NetworkRequest.Builder.from(getNetworkRequest()) .setHeader("Accept", "application/json") .build()); return this; } GsonRequest(String method, HttpUrl url, TypeAdapter<T> typeAdapter);  GsonRequest(String method, HttpUrl url, Class<T> tClass, Gson gson);  GsonRequest(String method, HttpUrl url, Class<T> tClass);  GsonRequest(String method, String url, TypeAdapter<T> typeAdapter);  GsonRequest(String method, String url, Class<T> tClass, Gson gson);  GsonRequest(String method, String url, Class<T> tClass); GsonRequest<T> setRequestData(R requestData, Gson gson, TypeAdapter adapter); GsonRequest<T> setRequestData(R requestData, Gson gson); GsonRequest<T> setRequestData(R requestData); }
GsonRequest extends Request<T> { public <R> GsonRequest<T> setRequestData(R requestData, Gson gson, TypeAdapter adapter) { try { super.setRequestData(requestData, new GsonRequestConverter<>(gson, adapter)); } catch (IOException e) { throw new RuntimeException("Unable to convert " + requestData + " to NetworkRequest", e); } setNetworkRequest(NetworkRequest.Builder.from(getNetworkRequest()) .setHeader("Accept", "application/json") .build()); return this; } GsonRequest(String method, HttpUrl url, TypeAdapter<T> typeAdapter);  GsonRequest(String method, HttpUrl url, Class<T> tClass, Gson gson);  GsonRequest(String method, HttpUrl url, Class<T> tClass);  GsonRequest(String method, String url, TypeAdapter<T> typeAdapter);  GsonRequest(String method, String url, Class<T> tClass, Gson gson);  GsonRequest(String method, String url, Class<T> tClass); GsonRequest<T> setRequestData(R requestData, Gson gson, TypeAdapter adapter); GsonRequest<T> setRequestData(R requestData, Gson gson); GsonRequest<T> setRequestData(R requestData);  }