@Test public void testExecuteAndRetrieveBodyAndFailOtherError() throws Exception { Response<String> failure = createFailedResponse(500); doReturn(failure).when(call).execute(); String response = client.executeAndRetrieveBody(call, "failed"); assertThat(response, containsString("failed")); }
protected <T> T executeAndRetrieveBody(Call<T> call, T defaultFailResponse) throws UnauthorizedException { return Optional.ofNullable(executeCallInternalRetryIfUnauthorized(call)) .map(Response::body) .orElse(defaultFailResponse); }
AbstractRemoteClient implements RemoteClient { protected <T> T executeAndRetrieveBody(Call<T> call, T defaultFailResponse) throws UnauthorizedException { return Optional.ofNullable(executeCallInternalRetryIfUnauthorized(call)) .map(Response::body) .orElse(defaultFailResponse); } }
AbstractRemoteClient implements RemoteClient { protected <T> T executeAndRetrieveBody(Call<T> call, T defaultFailResponse) throws UnauthorizedException { return Optional.ofNullable(executeCallInternalRetryIfUnauthorized(call)) .map(Response::body) .orElse(defaultFailResponse); } protected  AbstractRemoteClient(EndpointConnector connector, Class<S> cls); }
AbstractRemoteClient implements RemoteClient { protected <T> T executeAndRetrieveBody(Call<T> call, T defaultFailResponse) throws UnauthorizedException { return Optional.ofNullable(executeCallInternalRetryIfUnauthorized(call)) .map(Response::body) .orElse(defaultFailResponse); } protected  AbstractRemoteClient(EndpointConnector connector, Class<S> cls); boolean authenticate(); static String prefixTokenHeader(byte[] token, @Nonnull String prefix); S svc(); static char[] byteToCharArray(byte[] bytes); final EndpointConnector connector(); @Override String endpoint(); }
AbstractRemoteClient implements RemoteClient { protected <T> T executeAndRetrieveBody(Call<T> call, T defaultFailResponse) throws UnauthorizedException { return Optional.ofNullable(executeCallInternalRetryIfUnauthorized(call)) .map(Response::body) .orElse(defaultFailResponse); } protected  AbstractRemoteClient(EndpointConnector connector, Class<S> cls); boolean authenticate(); static String prefixTokenHeader(byte[] token, @Nonnull String prefix); S svc(); static char[] byteToCharArray(byte[] bytes); final EndpointConnector connector(); @Override String endpoint();  }