Skip to content

Instantly share code, notes, and snippets.

@eugenp
Created January 17, 2012 21:17
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/1628931 to your computer and use it in GitHub Desktop.
Save eugenp/1628931 to your computer and use it in GitHub Desktop.
Pagination with REST - testing Discoverability - Pagination testing
@Test
public void whenResourcesAreRetrievedPaged_then200IsReceived(){
Response response = givenAuth().get( paths.getFooURL() + "?page=1&size=10" );
assertThat( response.getStatusCode(), is( 200 ) );
}
@Test
public void
whenPageOfResourcesAreRetrievedOutOfBounds_then404IsReceived(){
Response response = givenAuth().get(
paths.getFooURL() + "?page=" + randomNumeric( 5 ) + "&size=10" );
assertThat( response.getStatusCode(), is( 404 ) );
}
@Test
public void
givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources(){
restTemplate.createResource();
Response response = givenAuth().get( paths.getFooURL() + "?page=1&size=10" );
assertFalse( response.body().as( List.class ).isEmpty() );
}
@eugenp
Copy link
Author

eugenp commented Jan 29, 2012

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