HaloRequest { @Api(1.3) @NonNull public Response execute() throws HaloNetException { return mNetworkClient.request(this); } private  HaloRequest(@NonNull Builder builder); @Api(1.3) @NonNull static Builder builder(@NonNull HaloNetworkApi networkApi); @Api(1.3) @NonNull Response execute(); @Api(1.3) @NonNull T execute(Class<T> clazz); @Api(2.0) @NonNull @SuppressWarnings("unchecked") T execute(@NonNull TypeReference<T> type); @Api(2.0) @NonNull Request buildOkRequest(); @Api(2.0) @NonNull Parser.Factory getParser(); static final String SERVER_CACHE_HEADER; static final String CACHE_CONTROL_HEADER; static final String NO_CACHE; static final String USER_AGENT_HEADER; }
@Test public void thatMakeARequest() throws IOException { enqueueServerFile(mMockServer, GET_TEST_ITEM); HaloNetworkApi networkApi = givenAHaloNetWorkApi(mFramework, mEndpointURL); HaloRequest request = givenAGetRequest(networkApi); Response response = request.execute(); assertThat(response).isNotNull(); assertThat(response.isSuccessful()).isTrue(); }
@Test public void thatMakeARequestWithClass() throws IOException, HaloParsingException, JSONException { enqueueServerFile(mMockServer, GET_TEST_ITEM); HaloNetworkApi networkApi = givenAHaloNetWorkApi(mFramework, mEndpointURL); HaloRequest request = givenAGetRequestTyped(networkApi); String response = request.execute(String.class); assertThat(response).isNotNull(); assertThat(response).isEqualTo("ExampleResponseTestFromNetWork"); }
@Test public void thatMakeARequestWithTyped() throws IOException, HaloParsingException, JSONException { enqueueServerFile(mMockServer, GET_TEST_ITEM); HaloNetworkApi networkApi = givenAHaloNetWorkApi(mFramework, mEndpointURL); HaloRequest request = givenAGetRequestTyped(networkApi); String response = request.execute(new TypeReference<String>() { }); assertThat(response).isNotNull(); assertThat(response).isEqualTo("ExampleResponseTestFromNetWork"); }