aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats/json
diff options
context:
space:
mode:
authorMarvin Bertin <marvin.bertin@gmail.com>2017-10-03 13:08:00 -0700
committerMarvin Bertin <marvin.bertin@gmail.com>2017-10-03 13:08:00 -0700
commit0653b90dddc294fddb0e81059aef00b202113d78 (patch)
tree3d8abb424b0f0495f1cbb18849184dd20d6897fc /src/test/scala/xyz/driver/pdsuidomain/formats/json
parent5750f2f3633e75f2f96d6a36264ab4b8f3fec7d2 (diff)
parenta321a978353439fc516b0f2016c28fb32ba1b7ae (diff)
downloadrest-query-0653b90dddc294fddb0e81059aef00b202113d78.tar.gz
rest-query-0653b90dddc294fddb0e81059aef00b202113d78.tar.bz2
rest-query-0653b90dddc294fddb0e81059aef00b202113d78.zip
Merge branch 'master' into add-slot-eligibility-arms
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain/formats/json')
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala17
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala26
2 files changed, 25 insertions, 18 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala
index 9601834..51665d2 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala
@@ -15,7 +15,8 @@ class CriterionFormatSuite extends FlatSpec with Matchers {
trialId = StringId("NCT000001"),
text = Some("text"),
isCompound = false,
- meta = "{}"
+ meta = "{}",
+ inclusion = None
)
val labels = List(
CriterionLabel(
@@ -44,12 +45,12 @@ class CriterionFormatSuite extends FlatSpec with Matchers {
val writtenJson = richCriterionFormat.write(richCriterion)
writtenJson should be(
- """{"text":"text","isCompound":false,"trialId":"NCT000001","arms":[20,21,21],"id":10,"meta":"{}",
+ """{"text":"text","isCompound":false,"trialId":"NCT000001","inclusion":null,"arms":[20,21,21],"id":10,"meta":"{}",
"labels":[{"labelId":101,"categoryId":3,"value":"Yes","isDefining":true},
{"labelId":102,"categoryId":3,"value":"No","isDefining":true}]}""".parseJson)
val createCriterionJson =
- """{"text":"text","isCompound":false,"trialId":"NCT000001",
+ """{"text":"text","isCompound":false,"trialId":"NCT000001","inclusion":null,
"arms":[20,21,21],"meta":"{}","labels":[{"labelId":101,"categoryId":3,"value":"Yes","isDefining":true},
{"labelId":102,"categoryId":3,"value":"No","isDefining":true}]}""".parseJson
val parsedRichCriterion = richCriterionFormat.read(createCriterionJson)
@@ -59,8 +60,14 @@ class CriterionFormatSuite extends FlatSpec with Matchers {
)
parsedRichCriterion should be(expectedRichCriterion)
- val updateCriterionJson = """{"meta":null,"text":"new text","isCompound":true}""".parseJson
- val expectedUpdatedCriterion = richCriterion.copy(criterion = criterion.copy(text = Some("new text"), isCompound = true, meta = "{}"))
+ val updateCriterionJson = """{"meta":null,"text":"new text","isCompound":true,"inclusion":true}""".parseJson
+ val expectedUpdatedCriterion = richCriterion.copy(
+ criterion = criterion.copy(
+ text = Some("new text"),
+ isCompound = true,
+ meta = "{}",
+ inclusion = Some(true)
+ ))
val parsedUpdateCriterion = applyUpdateToCriterion(updateCriterionJson, richCriterion)
parsedUpdateCriterion should be(expectedUpdatedCriterion)
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
index d0d4d1a..a451905 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala
@@ -6,7 +6,7 @@ import java.util.UUID
import spray.json._
import org.scalatest.{FlatSpec, Matchers}
import xyz.driver.pdsuicommon.domain.{FuzzyValue, LongId, StringId, UuidId}
-import xyz.driver.pdsuidomain.entities.RecordRequestId
+import xyz.driver.pdsuidomain.entities.{DocumentType, ProviderType, RecordRequestId}
class ExportFormatSuite extends FlatSpec with Matchers {
import export._
@@ -16,10 +16,11 @@ class ExportFormatSuite extends FlatSpec with Matchers {
val document = ExportPatientLabelEvidenceDocument(
documentId = LongId(101),
requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")),
- documentType = "document type",
- providerType = "provider type",
+ documentType = DocumentType.OutpatientPhysicianNote,
+ providerType = ProviderType.Surgery,
date = LocalDate.parse("2017-08-10")
)
+
val labels = List(
ExportPatientLabel(
id = LongId(1),
@@ -62,18 +63,18 @@ class ExportFormatSuite extends FlatSpec with Matchers {
labels = labels
)
- val writtenJson = patientWithLabelsWriter.write(patientWithLabels)
+ val writtenJson = patientWithLabelsFormat.write(patientWithLabels)
writtenJson should be(
"""{"patientId":"748b5884-3528-4cb9-904b-7a8151d6e343","labelVersion":1,"labels":[{"labelId":1,"evidence":[{"evidenceId":11,
"labelValue":"Yes","evidenceText":"evidence text 11","document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9",
- "documentType":"document type","providerType":"provider type","date":"2017-08-10"}},{"evidenceId":12,"labelValue":"No",
- "evidenceText":"evidence text 12","document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9",
- "documentType":"document type","providerType":"provider type","date":"2017-08-10"}}]},
+ "documentType":{"id":1,"name":"Outpatient Physician Note"},"providerType":{"id":2,"name":"Surgery"},"date":"2017-08-10"}},
+ {"evidenceId":12,"labelValue":"No","evidenceText":"evidence text 12","document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9",
+ "documentType":{"id":1,"name":"Outpatient Physician Note"},"providerType":{"id":2,"name":"Surgery"},"date":"2017-08-10"}}]},
{"labelId":2,"evidence":[{"evidenceId":12,"labelValue":"Yes","evidenceText":"evidence text 12","document":
- {"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","documentType":"document type",
- "providerType":"provider type","date":"2017-08-10"}},{"evidenceId":13,"labelValue":"Yes","evidenceText":"evidence text 13",
- "document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","documentType":"document type",
- "providerType":"provider type","date":"2017-08-10"}}]}]}""".parseJson)
+ {"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","documentType":{"id":1,"name":"Outpatient Physician Note"},
+ "providerType":{"id":2,"name":"Surgery"},"date":"2017-08-10"}},{"evidenceId":13,"labelValue":"Yes","evidenceText":"evidence text 13",
+ "document":{"documentId":101,"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","documentType":{"id":1,"name":"Outpatient Physician Note"},
+ "providerType":{"id":2,"name":"Surgery"},"date":"2017-08-10"}}]}]}""".parseJson)
}
"Json format for ApiExportTrialWithLabels" should "read and write correct JSON" in {
@@ -112,7 +113,7 @@ class ExportFormatSuite extends FlatSpec with Matchers {
criteria = criteriaList
)
- val writtenJson = trialWithLabelsWriter.write(trialWithLabels)
+ val writtenJson = trialWithLabelsFormat.write(trialWithLabels)
writtenJson should be(
"""{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","disease":"Breast","lastReviewed":"2017-08-10T18:00Z",
"labelVersion":1,"arms":[{"armId":1,"armName":"arm 1"},{"armId":2,"armName":"arm 2"}],"criteria":[
@@ -120,5 +121,4 @@ class ExportFormatSuite extends FlatSpec with Matchers {
{"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true,"isDefining":false}]}""".parseJson)
}
-
}