Skip to content

Instantly share code, notes, and snippets.

@eugenp
Created October 9, 2011 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eugenp/1274161 to your computer and use it in GitHub Desktop.
Save eugenp/1274161 to your computer and use it in GitHub Desktop.
Integration testing of a REST API - Testing the Json payload in the HTTP response
@Test
public void givenUserExists_whenUserInformationIsRetrieved_thenRetrievedResourceIsCorrect()
throws ClientProtocolException, IOException{
// Given
HttpUriRequest request = new HttpGet( "https://api.github.com/users/eugenp" );
// When
HttpResponse response = new DefaultHttpClient().execute( request );
// Then
GitHubUser resource =
RetrieveUtil.retrieveResourceFromResponse( response, GitHubUser.class );
assertThat( "eugenp", Matchers.is( resource.getLogin() ) );
}
@eugenp
Copy link
Author

eugenp commented Feb 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment