@Test public void returnsTheRequestContent() throws Exception { String content = "data"; CallStub<String> request = CallStub.success(content); Try<String> response = underTest.execute(request); assertThat(response, isSuccess(equalTo(content))); }
public <T> Try<T> execute(Call<T> call) { try { Response<T> response = call.execute(); if (response.isSuccessful()) { T body = response.body(); return Try.success(body); } else { return handleUnsuccessful(call, response); } } catch (Exception e) { String msg = String.format(FORMAT_EXC, call.request().toString()); return Try.failure(new MapsApiFailure(msg, e)); } }
MapsRequestExecutor { public <T> Try<T> execute(Call<T> call) { try { Response<T> response = call.execute(); if (response.isSuccessful()) { T body = response.body(); return Try.success(body); } else { return handleUnsuccessful(call, response); } } catch (Exception e) { String msg = String.format(FORMAT_EXC, call.request().toString()); return Try.failure(new MapsApiFailure(msg, e)); } } }
MapsRequestExecutor { public <T> Try<T> execute(Call<T> call) { try { Response<T> response = call.execute(); if (response.isSuccessful()) { T body = response.body(); return Try.success(body); } else { return handleUnsuccessful(call, response); } } catch (Exception e) { String msg = String.format(FORMAT_EXC, call.request().toString()); return Try.failure(new MapsApiFailure(msg, e)); } }  }
MapsRequestExecutor { public <T> Try<T> execute(Call<T> call) { try { Response<T> response = call.execute(); if (response.isSuccessful()) { T body = response.body(); return Try.success(body); } else { return handleUnsuccessful(call, response); } } catch (Exception e) { String msg = String.format(FORMAT_EXC, call.request().toString()); return Try.failure(new MapsApiFailure(msg, e)); } }  Try<T> execute(Call<T> call); }
MapsRequestExecutor { public <T> Try<T> execute(Call<T> call) { try { Response<T> response = call.execute(); if (response.isSuccessful()) { T body = response.body(); return Try.success(body); } else { return handleUnsuccessful(call, response); } } catch (Exception e) { String msg = String.format(FORMAT_EXC, call.request().toString()); return Try.failure(new MapsApiFailure(msg, e)); } }  Try<T> execute(Call<T> call);  }