Created
January 17, 2012 21:17
-
-
Save eugenp/1628931 to your computer and use it in GitHub Desktop.
Pagination with REST - testing Discoverability - Pagination testing
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
@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() ); | |
} |
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/2012/01/18/rest-pagination-in-spring/