Implementing the API with persistence
In this chapter, we created the route for the API without an implementation. In the previous chapter, Chapter 6, Online Shopping – Persistence, we created the database to persist the carts. It is now time to bind the API with the persistence.
Completing the product tests
We want to check not only the HTTP status but the content received back; for example, for the list of products, we would like to make sure that we are receiving all of the default products:
"list all the products" in { val response = wsClient.url(productsURL).get().futureValue println(response.body) response.status mustBe OK response.body must include("PEPER") response.body must include("NAO") response.body must include("BEOBOT") }
In this test, we look at the body of the response and make sure that the three default products are present.
Similarly, to check the add a product
function, we first add the product, and then call the list of products...