aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2017-08-14 22:29:45 -0700
committerGitHub <noreply@github.com>2017-08-14 22:29:45 -0700
commit322ea28ecf5ad5f65d3376f3e97e004d229d4736 (patch)
treec405d10d70f4ec1f18ffa81bc01cd8da64bddcba /src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
parentbe74ae7c5531af998d38b9de8052791f17b25341 (diff)
parent442579b27ccbac82cb001a5b02402a593d005977 (diff)
downloadrest-query-322ea28ecf5ad5f65d3376f3e97e004d229d4736.tar.gz
rest-query-322ea28ecf5ad5f65d3376f3e97e004d229d4736.tar.bz2
rest-query-322ea28ecf5ad5f65d3376f3e97e004d229d4736.zip
Merge pull request #18 from drivergroup/PDSUI-2188
PDSUI-2188 Create spray json formats for domain entities
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala')
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
new file mode 100644
index 0000000..2999cc1
--- /dev/null
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
@@ -0,0 +1,31 @@
+package xyz.driver.pdsuidomain.formats.json.sprayformats
+
+import spray.json._
+import org.scalatest.{FlatSpec, Matchers}
+import xyz.driver.pdsuicommon.domain.UuidId
+import xyz.driver.pdsuidomain.entities.PatientHypothesis
+
+class PatientHypothesisFormatSuite extends FlatSpec with Matchers {
+ import patienthypothesis._
+
+ "Json format for PatientHypothesis" should "read and write correct JSON" in {
+ val orig = PatientHypothesis(
+ id = UuidId("815d9715-1089-4775-b120-3afb983b9a97"),
+ patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"),
+ hypothesisId = UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4"),
+ rationale = None,
+ matchedTrials = 1
+ )
+ val writtenJson = patientHypothesisWriter.write((orig, true))
+
+ writtenJson should be (
+ """{"id":"815d9715-1089-4775-b120-3afb983b9a97","patientId":"748b5884-3528-4cb9-904b-7a8151d6e343",
+ "hypothesisId":"e76e2fc4-a29c-44fb-a81b-8856d06bb1d4","rationale":null,"matchedTrials":1,"isRationaleRequired":true}""".parseJson)
+
+ val updatePatientHypothesisJson = """{"rationale":"rationale"}""".parseJson
+ val expectedUpdatedPatientHypothesis = orig.copy(rationale = Some("rationale"))
+ val parsedUpdatePatientHypothesis = applyUpdateToPatientHypothesis(updatePatientHypothesisJson, orig)
+ parsedUpdatePatientHypothesis should be(expectedUpdatedPatientHypothesis)
+ }
+
+}