Skip to content

Instantly share code, notes, and snippets.

@rbuckland
Created April 23, 2014 20:25
Show Gist options
  • Select an option

  • Save rbuckland/11231068 to your computer and use it in GitHub Desktop.

Select an option

Save rbuckland/11231068 to your computer and use it in GitHub Desktop.
JacksonUnmarshallingSpec for Spray. Just making sure that it is all still working.
package com.soqqo.luap.web.marshalling
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import io.straight.fw.spray.marshalling.JacksonUnmarshaller
import com.soqqo.luap.messages.AddNewAccountTenantRegistration
import spray.httpx.unmarshalling._
import spray.util._
import spray.http._
import spray.http.MediaTypes.`application/json`
/**
*
* This test was written because we had some marshalling issues
* @author rbuckland
*/
class UnmarshallingSpec extends FlatSpec with ShouldMatchers {
implicit val UnmarshallerAddNewAccountTenantRegistration = JacksonUnmarshaller[AddNewAccountTenantRegistration]
"a json string" should "unmarshall to the case class" in {
val addNewAccountTenant = """{"accountName":"testaccount","contactName":"Ramon Buckland","contactEmail":"ramon@thebuckland.com","heardAboutUsSource":["Horses Mouth"]}"""
val body = HttpEntity(`application/json`, addNewAccountTenant)
body.as[AddNewAccountTenantRegistration] === Right(AddNewAccountTenantRegistration)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment