More testing

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:

  1. Move the logic of adding a new cat to the CatVerticle.
  2. 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.
  3. Implement deletion and update the cat, following the same principles.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.50.156