Skip to content

Instantly share code, notes, and snippets.

@finsterthecat
Created January 16, 2018 21:16
Show Gist options
  • Save finsterthecat/c241ef32ec783b97e51f756884224855 to your computer and use it in GitHub Desktop.
Save finsterthecat/c241ef32ec783b97e51f756884224855 to your computer and use it in GitHub Desktop.
/*
* Used in our tests to make the RESTful calls
*/
private ResultActions invokeAllHeroes() throws Exception {
return mvc.perform(get(BASE_URL).accept(MediaType.APPLICATION_JSON));
}
private ResultActions invokeSearchHeroes(String term) throws Exception {
return mvc.perform(get(BASE_URL + "search/name?contains=" + term).accept(MediaType.APPLICATION_JSON));
}
private ResultActions invokeGetHero(Long id) throws Exception {
return mvc.perform(get(BASE_URL + id).accept(MediaType.APPLICATION_JSON));
}
private ResultActions invokeCreateHero(byte[] heroJson) throws Exception {
return mvc.perform(post(BASE_URL).content(heroJson).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON));
}
private ResultActions invokeUpdateHero(Long id, byte[] heroJson) throws Exception {
return mvc.perform(put(BASE_URL + id).content(heroJson).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON));
}
private ResultActions invokeDeleteHero(Long id) throws Exception {
return mvc.perform(delete(BASE_URL + id));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment