lundi 19 juin 2017

Joda Marshalling/Unmarshalling in scala

I'm trying to use akka.http.scaladsl.testkit.responseAs in order to test some endpoints, but I can't figure out how to handle the marshalling/unmarshalling process of a org.joda.time.DateTime object. For instance, consider the case class below:

case class ConfigEntity(id: Option[Int] = None, description: String, key: String, value: String, expirationDate: Option[DateTime] = None)

Also, consider the following route test:

"retrieve config by id" in new Context {
  val testConfig = testConfigs(4)
  Get(s"/configs/${testConfig.id.get}") ~> route ~> check {
    responseAs[ConfigEntity] should be(testConfig)
  }
}

When I run "sbt test", the code does not compile, throwing the following error: "could not find implicit value for evidence parameter of type akka.http.scaladsl.unmarshalling.FromResponseUnmarshaller[me.archdev.restapi.models.ConfigEntity]"

I know the message is very self explanatory, but I still don't know how to create the implicit FromResponseUnmarshaller that the code is complaining about.

My code is based in this example: http://ift.tt/1VjN9FG

I'm just creating some new entities and trying to play around...

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire