我正在尝试使用 akka.http.scaladsl.testkit.responseAs 来测试一些端点,但我不知道如何处理 org.joda.time.DateTime 对象的编组/解组过程。例如,考虑下面的案例类:
case class ConfigEntity(id: Option[Int] = None, description: String, key: String, value: String, expirationDate: Option[DateTime] = None)
另外,请考虑以下路线测试:
"retrieve config by id" in new Context {
val testConfig = testConfigs(4)
Get(s"/configs/${testConfig.id.get}") ~> route ~> check {
responseAs[ConfigEntity] should be(testConfig)
}
}
当我运行“sbt test”时,代码无法编译,抛出以下错误:“找不到akka.http.scaladsl.unmarshalling.FromResponseUnmarshaller[me.archdev.restapi.models.ConfigEntity] 类型的证据参数的隐式值"
我知道该消息非常不言自明,但我仍然不知道如何创建代码抱怨的隐式 FromResponseUnmarshaller。
我的代码基于此示例:https ://github.com/ArchDev/akka-http-rest
我只是在创建一些新实体并尝试玩...
提前致谢。