java unit test an api code example
Example: java unit test an api
@Test
public void
givenUserExists_whenUserInformationIsRetrieved_thenRetrievedResourceIsCorrect()
throws ClientProtocolException, IOException {
HttpUriRequest request = new HttpGet( "https://api.github.com/users/eugenp" );
HttpResponse response = HttpClientBuilder.create().build().execute( request );
GitHubUser resource = RetrieveUtil.retrieveResourceFromResponse(
response, GitHubUser.class);
assertThat( "eugenp", Matchers.is( resource.getLogin() ) );
}