Created
October 9, 2011 20:08
-
-
Save eugenp/1274091 to your computer and use it in GitHub Desktop.
Integration testing of a REST API - retrieve utilities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String retrieveJsonFromResponse( final HttpResponse response ) | |
throws IOException{ | |
Preconditions.checkNotNull( response ); | |
return IOUtils.toString( response.getEntity().getContent() ); | |
} | |
public static < T >T retrieveResourceFromResponse | |
( final HttpResponse response, final Class< T > clazz ) throws IOException{ | |
Preconditions.checkNotNull( response ); | |
Preconditions.checkNotNull( clazz ); | |
final String jsonFromResponse = retrieveJsonFromResponse( response ); | |
return ConvertUtil.convertJsonToResource( jsonFromResponse, clazz ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist is used in:
http://www.baeldung.com/2011/10/13/integration-testing-a-rest-api/