Now add the following basic test:
@Test
fun `Make sure that all cats are returned`() {
val response = get("/api/v1/cats")
assertEquals(response.statusCode(), 200)
val body = response.asJson()
assertTrue(body.size() > 0)
}
To make sure you understand how everything works together, here are some more assignments you may wish to do:
- Move the logic of adding a new cat to the CatVerticle.
- Implement getting a single cat. Notice how the code is very similar to the one that gets all the cats? Refactor it to use a local function, a cool feature in Kotlin, which we have already discussed.
- Implement deletion and update the cat, following the same principles.