Java Code Examples for com.google.android.agera.Result#get()

The following examples show how to use com.google.android.agera.Result#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SupplierTest.java    From retrofit-agera-call-adapter with Apache License 2.0 5 votes vote down vote up
@Test public void bodySuccess404() throws Exception {
    server.enqueue(new MockResponse().setResponseCode(404));

    Result<String> result = service.body().get();
    try {
        result.get();
        fail();
    } catch (FailedResultException e) {
        assertThat(e.getCause(), instanceOf(HttpException.class));
        assertThat(e.getCause(), hasMessage(containsString("HTTP 404 Client Error")));
    }
}
 
Example 2
Source File: SupplierTest.java    From retrofit-agera-call-adapter with Apache License 2.0 5 votes vote down vote up
@Test public void bodyFailure() throws Exception {
    server.enqueue(new MockResponse().setSocketPolicy(DISCONNECT_AFTER_REQUEST));

    Result<String> result = service.body().get();
    try {
        result.get();
        fail();
    } catch (FailedResultException e) {
        assertThat(e.getCause(), instanceOf(IOException.class));
    }
}
 
Example 3
Source File: SupplierTest.java    From retrofit-agera-call-adapter with Apache License 2.0 5 votes vote down vote up
@Test public void shouldReturnSuccessWithNullBodyResponse() throws Exception {
    MockResponse mockResponse = new MockResponse().setStatus(STATUS_NO_CONTENT);
    assertNull(mockResponse.getBody());
    server.enqueue(mockResponse);

    Supplier<Result<Response<Void>>> supplier = service.responseOfDeleteXXX();
    Result<Response<Void>> responseResult = supplier.get();
    assertTrue(responseResult.succeeded());

    Response<Void> response = responseResult.get();
    assertEquals(response.code(), 204);
    assertNull(response.body());
}