I apologize if I'm missing something simple, but I'm trying to use Akka HTTP with Circe (using the akka-http-json Circe module). I'm trying to retrieve the results of a GET call in a ScalaTest which mixes in the ErrorAccumulatingCirceSupport
trait. The call goes through successfully, but I'm unable to unmarshal the response...It's a pretty simple test, but I'm just not sure how to unmarshal the results into a list of domain objects, eg:
Get("/path/to/getfoos").withHeaders(auth) ~> Route.seal(service.route) ~> check {
import io.circe.generic.auto._
status shouldEqual StatusCodes.OK
contentType should ===(ContentTypes.`application/json`)
val reports = responseAs[List[Foo]]
reports.size shouldBe 1
}
The error I'm getting is:
Could not unmarshal response to type 'scala.collection.immutable.List' for `responseAs` assertion: de.heikoseeberger.akkahttpcirce.ErrorAccumulatingCirceSupport$DecodingFailures: DecodingFailure at [0]: CNil
If anyone can point out what I'm dong wrong I would very much appreciate the help!
Thanks!
Foo
definition? – Travis BrownFoo
is actually an ADT (case class subtype of a sealed trait) composed of other ADTs, though none are very complex. I was able to get it to work by getting theHttpEntity
and usingUnmarshal
on it (I'll post the code below in case there's a better way to handle this issue). Thanks for responding! – Timothy Perrigo