Skip to content

Instantly share code, notes, and snippets.

@AlexeySoshin
Created October 22, 2017 18:58
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 AlexeySoshin/aba55007f545dd47d5356eeb6575b533 to your computer and use it in GitHub Desktop.
Save AlexeySoshin/aba55007f545dd47d5356eeb6575b533 to your computer and use it in GitHub Desktop.
val fionaTheCat = Cat(name="Fiona", age=2.6f, weight=5.3f)
@Before
fun createCat() {
restTemplate.postForLocation("/", HttpEntity(fionaTheCat))
}
@Test
fun indexShouldReturnSingleCat() {
val response = restTemplate.getForEntity("/", CatsList::class.java)
assertThat(response.statusCode).isEqualTo(HttpStatus.OK)
assertThat(response.body).isNotEmpty
assertThat(response.body.size).isEqualTo(1)
// We would like to ignore id of the cat here
assertThat(response.body[0]).isEqualToComparingOnlyGivenFields(fionaTheCat, "name", "age", "weight")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment