diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-09-28 17:52:21 +0700 |
---|---|---|
committer | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-09-28 17:52:21 +0700 |
commit | 283ca02360949143ffe7ee8ad87d51902426b450 (patch) | |
tree | c098efe0628fc80a0a6b8f05fa465a99ff494fb8 /src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats | |
parent | d82c93fef0fc0bb937220334f73c264fbb1082f2 (diff) | |
parent | c24679f1ae7d7ccc4e6693535b0aa3ac0e1ca225 (diff) | |
download | rest-query-283ca02360949143ffe7ee8ad87d51902426b450.tar.gz rest-query-283ca02360949143ffe7ee8ad87d51902426b450.tar.bz2 rest-query-283ca02360949143ffe7ee8ad87d51902426b450.zip |
Merge branch 'master' into synch-refactor
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats')
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala index 0f01d4a..dad39c8 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala @@ -18,7 +18,8 @@ class InterventionFormatSuite extends FlatSpec with Matchers { originalType = Some("orig type"), dosage = "", originalDosage = "", - isActive = true + isActive = true, + deliveryMethod = Some("pill") ) val arms = List( InterventionArm(interventionId = intervention.id, armId = LongId(20)), @@ -29,11 +30,21 @@ class InterventionFormatSuite extends FlatSpec with Matchers { intervention = intervention, arms = arms ) - val writtenJson = interventionWriter.write(orig) + val writtenJson = interventionFormat.write(orig) writtenJson should be( """{"id":1,"name":"intervention name","typeId":10,"dosage":"","isActive":true,"arms":[20,21,22], - "trialId":"NCT000001","originalName":"orig name","originalDosage":"","originalType":"orig type"}""".parseJson) + "trialId":"NCT000001","deliveryMethod":"pill","originalName":"orig name","originalDosage":"","originalType":"orig type"}""".parseJson) + + val createInterventionJson = + """{"id":1,"name":"intervention name","typeId":10,"dosage":"","isActive":true,"arms":[20,21,22], + "trialId":"NCT000001","deliveryMethod":"pill"}""".parseJson + val parsedCreateIntervention = interventionFormat.read(createInterventionJson) + val expectedCreateIntervention = parsedCreateIntervention.copy( + intervention = intervention.copy(id = LongId(0), originalType = None, originalName = "intervention name"), + arms = arms.map(_.copy(interventionId = LongId(0))) + ) + parsedCreateIntervention should be(expectedCreateIntervention) val updateInterventionJson = """{"dosage":"descr","arms":[21,22]}""".parseJson val expectedUpdatedIntervention = orig.copy( @@ -48,13 +59,12 @@ class InterventionFormatSuite extends FlatSpec with Matchers { } "Json format for InterventionType" should "read and write correct JSON" in { - val interventionType = InterventionType( - id = LongId(10), - name = "type name" - ) + val interventionType = InterventionType.typeFromString("Surgery/Procedure") val writtenJson = interventionTypeFormat.write(interventionType) - writtenJson should be("""{"id":10,"name":"type name"}""".parseJson) + writtenJson should be( + """{"id":9,"name":"Surgery/Procedure","deliveryMethods":["Radio-Frequency Ablation (RFA)", + "Cryoablation","Therapeutic Conventional Surgery","Robotic Assisted Laparoscopic Surgery"]}""".parseJson) val parsedInterventionType = interventionTypeFormat.read(writtenJson) parsedInterventionType should be(interventionType) |