Created
April 23, 2014 20:25
-
-
Save rbuckland/11231068 to your computer and use it in GitHub Desktop.
JacksonUnmarshallingSpec for Spray. Just making sure that it is all still working.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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