As you might expect, most tests are no longer working. We will need to perform some refactoring here as well. We will refactor our former dao
to make it generic, and it will be used in integration tests (end-to-end tests).
Since we will create a generic dao system in memory for end-to-end testing purposes, we need to change our models a little bit. First, we need to create a base trait for all the models. This is needed so we can treat our models as equals.
Let's have a look at models.BaseModel.scala
:
package models trait BaseModel { def getId:Option[Long] def setId(id:Option[Long]):Unit }
We also need to make all our models implement this new trait. So we will need to change the Scala code for the product, image, and review. This is very trivial: we just add a getter and a setter for the id
field. You can also use scala.bean.BeanProperty
instead of writing one by yourself.
Your models.Product.scala
file should look something like this:
package...