aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala
diff options
context:
space:
mode:
authorAleksandr <ognelisar@gmail.com>2017-10-12 10:44:54 +0700
committerAleksandr <ognelisar@gmail.com>2017-10-12 10:44:54 +0700
commitf525ab2604cc5d1366c852bdbcb4d912bbcea800 (patch)
tree4fe4b35e1f474e2dc85a8885dc4c9002f3ea46c2 /src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala
parent9198729ebf3d20b650b4467daa0d484a3148f01c (diff)
parente15415d69ec990d5243e58704e232e619b80aa6f (diff)
downloadrest-query-f525ab2604cc5d1366c852bdbcb4d912bbcea800.tar.gz
rest-query-f525ab2604cc5d1366c852bdbcb4d912bbcea800.tar.bz2
rest-query-f525ab2604cc5d1366c852bdbcb4d912bbcea800.zip
All merge conflicts are resolved
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala')
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala
new file mode 100644
index 0000000..bcfb977
--- /dev/null
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala
@@ -0,0 +1,36 @@
+package xyz.driver.pdsuidomain.formats.json.sprayformats
+
+import spray.json._
+import org.scalatest.{FlatSpec, Matchers}
+import xyz.driver.pdsuicommon.domain.{LongId, StringId}
+import xyz.driver.pdsuidomain.entities.EligibilityArm
+
+class EligibilityArmFormatSuite extends FlatSpec with Matchers {
+ import eligibilityarm._
+
+ "Json format for EligibilityArm" should "read and write correct JSON" in {
+ val arm = EligibilityArm(
+ id = LongId(10),
+ trialId = StringId("NCT000001"),
+ name = "arm name",
+ originalName = "orig arm name"
+ )
+ val writtenJson = eligibilityArmFormat.write(arm)
+
+ writtenJson should be(
+ """{"id":10,"trialId":"NCT000001","name":"arm name","originalName":"orig arm name"}""".parseJson)
+
+ val createArmJson = """{"trialId":"NCT000001","name":"arm name"}""".parseJson
+ val parsedArm = eligibilityArmFormat.read(createArmJson)
+ val expectedCreatedArm = arm.copy(
+ id = LongId(0),
+ originalName = "arm name"
+ )
+ parsedArm should be(expectedCreatedArm)
+
+ val updateArmJson = """{"name":"new arm name"}""".parseJson
+ val expectedUpdatedArm = arm.copy(name = "new arm name")
+ val parsedUpdateArm = applyUpdateToArm(updateArmJson, arm)
+ parsedUpdateArm should be(expectedUpdatedArm)
+ }
+}