Created
October 12, 2011 22:31
-
-
Save eugenp/1282846 to your computer and use it in GitHub Desktop.
Integration testing of a REST API - conversion 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 < T >String convertResourceToJson( final T resource ) | |
throws IOException{ | |
Preconditions.checkNotNull( resource ); | |
return new ObjectMapper().writeValueAsString( resource ); | |
} | |
public static < T >T convertJsonToResource | |
( final String json, final Class< T > clazzOfResource ) throws IOException{ | |
Preconditions.checkNotNull( json ); | |
Preconditions.checkNotNull( clazzOfResource ); | |
return new ObjectMapper().readValue( json, clazzOfResource ); | |
} |
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/