FluentResponse implements HttpResponse { public boolean isSuccess() { int statusCode = response.getStatusLine().getStatusCode(); return statusCode >= 200 && statusCode < 300; }  boolean isSuccess(); FluentResponse ensureSuccess(); boolean equals(Object other);  }
@Test public void shouldBeValidTrueForSuccessfulResponse() { HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS); given(response.getStatusLine().getStatusCode()).willReturn(100); assertThat(new FluentResponse(response).isSuccess(), equalTo(false)); }
@Test public void shouldNotBeValidForFailedResponse() { HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS); given(response.getStatusLine().getStatusCode()).willReturn(200); assertThat(new FluentResponse(response).isSuccess(), equalTo(true)); }