aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/pdsuidomain/formats/json
diff options
context:
space:
mode:
authorMarvin Bertin <marvin.bertin@gmail.com>2017-10-10 17:05:32 -0700
committerMarvin Bertin <marvin.bertin@gmail.com>2017-10-10 17:05:32 -0700
commitf55212361d6126a05075a1f00f3915484b4f334e (patch)
treea376ae86b707699a971ddbd6abe6bd2d29ca124d /src/test/scala/xyz/driver/pdsuidomain/formats/json
parent0653b90dddc294fddb0e81059aef00b202113d78 (diff)
downloadrest-query-f55212361d6126a05075a1f00f3915484b4f334e.tar.gz
rest-query-f55212361d6126a05075a1f00f3915484b4f334e.tar.bz2
rest-query-f55212361d6126a05075a1f00f3915484b4f334e.zip
add json format tests for Slot and 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/ArmFormatSuite.scala9
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala10
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala3
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala3
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmFormatSuite.scala36
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala19
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala3
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala2
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala17
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala3
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala4
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala9
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala8
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala2
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala6
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala9
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala10
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/SlotArmFormatSuite.scala36
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala6
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala3
-rw-r--r--src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala8
21 files changed, 142 insertions, 64 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala
index e7d37a0..35b0fad 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala
@@ -17,19 +17,20 @@ class ArmFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = armFormat.write(arm)
- writtenJson should be("""{"id":10,"trialId":"NCT000001","name":"arm name","originalName":"orig arm name"}""".parseJson)
+ 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 = armFormat.read(createArmJson)
+ val parsedArm = armFormat.read(createArmJson)
val expectedCreatedArm = arm.copy(
id = LongId(0),
originalName = "arm name"
)
parsedArm should be(expectedCreatedArm)
- val updateArmJson = """{"name":"new arm name"}""".parseJson
+ val updateArmJson = """{"name":"new arm name"}""".parseJson
val expectedUpdatedArm = arm.copy(name = "new arm name")
- val parsedUpdateArm = applyUpdateToArm(updateArmJson, arm)
+ val parsedUpdateArm = applyUpdateToArm(updateArmJson, arm)
parsedUpdateArm should be(expectedUpdatedArm)
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala
index 9394735..481e92f 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala
@@ -31,7 +31,7 @@ class DocumentFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = documentFormat.write(orig)
- writtenJson should be (
+ writtenJson should be(
"""{"id":1,"recordId":101,"physician":"physician","typeId":10,"provider":"provider 21","providerTypeId":21,
"requiredType":"OPN","startDate":null,"endDate":null,"status":"New","assignee":null,"previousStatus":null,
"previousAssignee":null,"lastActiveUser":null,"lastUpdate":"2017-08-10T18:00Z","meta":null}""".parseJson)
@@ -58,15 +58,15 @@ class DocumentFormatSuite extends FlatSpec with Matchers {
}
"Json format for Document.Meta" should "read and write correct JSON" in {
- val meta = Document.Meta(predicted = None, startPage = 1.0, endPage = 2.0)
+ val meta = Document.Meta(predicted = None, startPage = 1.0, endPage = 2.0)
val writtenJson = documentMetaFormat.write(meta)
- writtenJson should be ("""{"startPage":1.0,"endPage":2.0}""".parseJson)
+ writtenJson should be("""{"startPage":1.0,"endPage":2.0}""".parseJson)
- val metaJsonWithoutPredicted = """{"startPage":1.0,"endPage":2.0}""".parseJson
+ val metaJsonWithoutPredicted = """{"startPage":1.0,"endPage":2.0}""".parseJson
val parsedMetaWithoutPredicted = documentMetaFormat.read(metaJsonWithoutPredicted)
parsedMetaWithoutPredicted should be(meta)
- val metaJsonWithPredicted = """{"predicted":true,"startPage":1.0,"endPage":2.0}""".parseJson
+ val metaJsonWithPredicted = """{"predicted":true,"startPage":1.0,"endPage":2.0}""".parseJson
val parsedMetaWithPredicted = documentMetaFormat.read(metaJsonWithPredicted)
parsedMetaWithPredicted should be(meta.copy(predicted = Some(true)))
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala
index ddbda1d..5975919 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala
@@ -21,8 +21,7 @@ class DocumentHistoryFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = documentHistoryFormat.write(documentHistory)
- writtenJson should be(
- """{"id":10,"executor":"userId-001","documentId":1,"state":"Extract",
+ writtenJson should be("""{"id":10,"executor":"userId-001","documentId":1,"state":"Extract",
"action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
val parsedDocumentHistory = documentHistoryFormat.read(writtenJson)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala
index c4c9f7c..54cfe90 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala
@@ -29,7 +29,8 @@ class DocumentIssueFormatSuite extends FlatSpec with Matchers {
"text":"message text","archiveRequired":false,"startPage":1.0,"endPage":2.0}""".parseJson)
val createDocumentIssueJson = """{"text":"message text","startPage":1.0,"endPage":2.0}""".parseJson
- val expectedCreatedDocumentIssue = documentIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
+ val expectedCreatedDocumentIssue =
+ documentIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
val parsedCreateDocumentIssue = jsValueToDocumentIssue(createDocumentIssueJson, LongId(1), StringId("userId-001"))
parsedCreateDocumentIssue should be(expectedCreatedDocumentIssue)
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)
+ }
+}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala
index a4b8bab..c3df80a 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala
@@ -40,7 +40,7 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = extractedDataFormat.write(origRichExtractedData)
- writtenJson should be (
+ writtenJson should be(
"""{"id":1,"documentId":101,"keywordId":201,"evidence":"evidence text","meta":null,
"labels":[{"id":null,"categoryId":null,"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}]}""".parseJson)
@@ -77,14 +77,15 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers {
val expectedUpdatedExtractedData = origRichExtractedData.copy(
extractedData = extractedData.copy(
evidenceText = Some("new evidence text"),
- meta = Some(TextJson(Meta(
- keyword = Meta.Keyword(page = 1, pageRatio = None, index = 2, sortIndex = "ASC"),
- evidence = Meta.Evidence(
- pageRatio = 1.0,
- start = Meta.TextLayerPosition(page = 1, index = 3, offset = 2),
- end = Meta.TextLayerPosition(page = 2, index = 3, offset = 10)
- )
- )))
+ meta = Some(
+ TextJson(Meta(
+ keyword = Meta.Keyword(page = 1, pageRatio = None, index = 2, sortIndex = "ASC"),
+ evidence = Meta.Evidence(
+ pageRatio = 1.0,
+ start = Meta.TextLayerPosition(page = 1, index = 3, offset = 2),
+ end = Meta.TextLayerPosition(page = 2, index = 3, offset = 10)
+ )
+ )))
),
labels = updatedExtractedDataLabels
)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala
index 306fb17..76d90f5 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala
@@ -17,8 +17,7 @@ class HypothesisFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = hypothesisFormat.write(hypothesis)
- writtenJson should be(
- """{"id":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","name":"hypothesis name",
+ writtenJson should be("""{"id":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","name":"hypothesis name",
"treatmentType":"treatment type","description":"descr"}""".parseJson)
val parsedHypothesis = hypothesisFormat.read(writtenJson)
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 dad39c8..5891e1c 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
@@ -60,7 +60,7 @@ class InterventionFormatSuite extends FlatSpec with Matchers {
"Json format for InterventionType" should "read and write correct JSON" in {
val interventionType = InterventionType.typeFromString("Surgery/Procedure")
- val writtenJson = interventionTypeFormat.write(interventionType)
+ val writtenJson = interventionTypeFormat.write(interventionType)
writtenJson should be(
"""{"id":9,"name":"Surgery/Procedure","deliveryMethods":["Radio-Frequency Ablation (RFA)",
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
index 899e5c9..feedf2f 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala
@@ -32,7 +32,7 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = recordFormat.write(orig)
- writtenJson should be (
+ writtenJson should be(
"""{"id":1,"status":"New","assignee":null,"previousStatus":null,"previousAssignee":null,"lastActiveUser":null,
"lastUpdate":"2017-08-10T18:00Z","meta":[],"patientId":"748b5884-3528-4cb9-904b-7a8151d6e343","caseId":null,
"requestId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","disease":"Breast","physician":"physician"}""".parseJson)
@@ -64,11 +64,16 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers {
{"type":"reorder","items":[1,2]},
{"type":"rotation","items":{"item1":1,"item2":2}}]}""".parseJson
val expectedUpdatedRecord = orig.copy(
- meta = Some(TextJson(List(
- Meta.Duplicate(predicted = Some(true), startPage = 1.0, endPage = 2.0, startOriginalPage = 1.0, endOriginalPage = None),
- Meta.Reorder(predicted = None, items = Seq(1, 2)),
- Meta.Rotation(predicted = None, items = Map("item1" -> 1, "item2" -> 2))
- )))
+ meta = Some(
+ TextJson(List(
+ Meta.Duplicate(predicted = Some(true),
+ startPage = 1.0,
+ endPage = 2.0,
+ startOriginalPage = 1.0,
+ endOriginalPage = None),
+ Meta.Reorder(predicted = None, items = Seq(1, 2)),
+ Meta.Rotation(predicted = None, items = Map("item1" -> 1, "item2" -> 2))
+ )))
)
val parsedUpdatedRecord = applyUpdateToMedicalRecord(updateRecordJson, orig)
parsedUpdatedRecord should be(expectedUpdatedRecord)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala
index 5cd6c8d..a8634d9 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala
@@ -21,8 +21,7 @@ class MedicalRecordHistoryFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = recordHistoryFormat.write(recordHistory)
- writtenJson should be(
- """{"id":10,"executor":"userId-001","recordId":1,"state":"Clean",
+ writtenJson should be("""{"id":10,"executor":"userId-001","recordId":1,"state":"Clean",
"action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
val parsedRecordHistory = recordHistoryFormat.read(writtenJson)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala
index c23ca37..5fa740b 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala
@@ -28,9 +28,9 @@ class MedicalRecordIssueFormatSuite extends FlatSpec with Matchers {
"""{"id":10,"recordId":1,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
"text":"message text","archiveRequired":false,"startPage":1.0,"endPage":2.0}""".parseJson)
- val createRecordIssueJson = """{"text":"message text","startPage":1.0,"endPage":2.0}""".parseJson
+ val createRecordIssueJson = """{"text":"message text","startPage":1.0,"endPage":2.0}""".parseJson
val expectedCreatedRecordIssue = recordIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
- val parsedCreateRecordIssue = jsValueToRecordIssue(createRecordIssueJson, LongId(1), StringId("userId-001"))
+ val parsedCreateRecordIssue = jsValueToRecordIssue(createRecordIssueJson, LongId(1), StringId("userId-001"))
parsedCreateRecordIssue should be(expectedCreatedRecordIssue)
val updateRecordIssueJson =
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala
index 0f5e4e2..43f9b48 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala
@@ -33,17 +33,18 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = patientCriterionWriter.write((orig, LongId(21), arms))
- writtenJson should be (
+ writtenJson should be(
"""{"id":1,"labelId":21,"nctId":"NCT00001","criterionId":101,"criterionText":"criterion text","criterionValue":"Yes",
"criterionIsDefining":false,"criterionIsCompound":false,"eligibilityStatus":"Yes","verifiedEligibilityStatus":null,
"isVisible":true,"isVerified":true,"lastUpdate":"2017-08-10T18:00Z","arms":["arm 31","arm 32"]}""".parseJson)
- val updatePatientCriterionJson = """{"verifiedEligibilityStatus":"No"}""".parseJson
+ val updatePatientCriterionJson = """{"verifiedEligibilityStatus":"No"}""".parseJson
val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = Some(FuzzyValue.No))
- val parsedUpdatePatientCriterion = applyUpdateToPatientCriterion(updatePatientCriterionJson, orig)
+ val parsedUpdatePatientCriterion = applyUpdateToPatientCriterion(updatePatientCriterionJson, orig)
parsedUpdatePatientCriterion should be(expectedUpdatedPatientCriterion)
- val updateBulkPatientCriterionJson = """[{"id":1,"eligibilityStatus":"No"},{"id":2,"isVerified":false}]""".parseJson
+ val updateBulkPatientCriterionJson =
+ """[{"id":1,"eligibilityStatus":"No"},{"id":2,"isVerified":false}]""".parseJson
val expectedDraftPatientCriterionList = List(
DraftPatientCriterion(id = LongId(1), eligibilityStatus = Some(FuzzyValue.No), isVerified = None),
DraftPatientCriterion(id = LongId(2), eligibilityStatus = None, isVerified = Some(false))
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala
index 8b00883..1d28b2e 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala
@@ -45,16 +45,16 @@ class PatientEligibleTrialFormatSuite extends FlatSpec with Matchers {
PatientCriterionArm(patientCriterionId = LongId(1), armId = LongId(31), armName = "arm 31"),
PatientCriterionArm(patientCriterionId = LongId(1), armId = LongId(32), armName = "arm 32")
)
- val orig = RichPatientEligibleTrial(trial, group, arms)
+ val orig = RichPatientEligibleTrial(trial, group, arms)
val writtenJson = patientEligibleTrialWriter.write(orig)
- writtenJson should be (
+ writtenJson should be(
"""{"id":1,"patientId":"748b5884-3528-4cb9-904b-7a8151d6e343","trialId":"NCT000001","trialTitle":"trial title",
"hypothesisId":"e76e2fc4-a29c-44fb-a81b-8856d06bb1d4","verifiedEligibilityStatus":"Yes","isVerified":false,"arms":["arm 31","arm 32"]}""".parseJson)
- val updatePatientEligibleTrialJson = """{"isVerified":true}""".parseJson
+ val updatePatientEligibleTrialJson = """{"isVerified":true}""".parseJson
val expectedUpdatedPatientTrialArmGroup = group.copy(isVerified = true)
- val parsedUpdatePatientTrialArmGroup = applyUpdateToTrialArmGroup(updatePatientEligibleTrialJson, group)
+ val parsedUpdatePatientTrialArmGroup = applyUpdateToTrialArmGroup(updatePatientEligibleTrialJson, group)
parsedUpdatePatientTrialArmGroup should be(expectedUpdatedPatientTrialArmGroup)
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala
index 2761d6a..b1b6b2a 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala
@@ -27,7 +27,7 @@ class PatientFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = patientWriter.write(orig)
- writtenJson should be (
+ writtenJson should be(
"""{"id":"748b5884-3528-4cb9-904b-7a8151d6e343","dob":"1980-06-30","name":"John Doe","status":"New","assignee":null,
"previousStatus":null,"previousAssignee":null,"lastActiveUser":null,"lastUpdate":"2017-08-10T18:00Z",
"orderId":"7b54a75d-4197-4b27-9045-b9b6cb131be9","condition":"breast"}""".parseJson)
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
index 2999cc1..0e628a8 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala
@@ -18,13 +18,13 @@ class PatientHypothesisFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = patientHypothesisWriter.write((orig, true))
- writtenJson should be (
+ 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 updatePatientHypothesisJson = """{"rationale":"rationale"}""".parseJson
val expectedUpdatedPatientHypothesis = orig.copy(rationale = Some("rationale"))
- val parsedUpdatePatientHypothesis = applyUpdateToPatientHypothesis(updatePatientHypothesisJson, orig)
+ val parsedUpdatePatientHypothesis = applyUpdateToPatientHypothesis(updatePatientHypothesisJson, orig)
parsedUpdatePatientHypothesis should be(expectedUpdatedPatientHypothesis)
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala
index 1e2a11e..2776dcc 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala
@@ -22,13 +22,14 @@ class PatientIssueFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = patientIssueWriter.write(patientIssue)
- writtenJson should be(
- """{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
+ writtenJson should be("""{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
"text":"message text","archiveRequired":false}""".parseJson)
- val createPatientIssueJson = """{"text":"message text"}""".parseJson
+ val createPatientIssueJson = """{"text":"message text"}""".parseJson
val expectedCreatedPatientIssue = patientIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
- val parsedCreatePatientIssue = jsValueToPatientIssue(createPatientIssueJson, UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"), StringId("userId-001"))
+ val parsedCreatePatientIssue = jsValueToPatientIssue(createPatientIssueJson,
+ UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"),
+ StringId("userId-001"))
parsedCreatePatientIssue should be(expectedCreatedPatientIssue)
val updatePatientIssueJson =
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala
index e18239c..67d678c 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala
@@ -23,13 +23,13 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = patientLabelWriter.write((orig, true))
- writtenJson should be (
+ writtenJson should be(
"""{"id":1,"labelId":20,"primaryValue":"Yes","verifiedPrimaryValue":null,"isVisible":true,"isVerified":true,
"score":1,"isImplicitMatch":false}""".parseJson)
- val updatePatientLabelJson = """{"verifiedPrimaryValue":"No"}""".parseJson
+ val updatePatientLabelJson = """{"verifiedPrimaryValue":"No"}""".parseJson
val expectedUpdatedPatientLabel = orig.copy(verifiedPrimaryValue = Some(FuzzyValue.No))
- val parsedUpdatePatientLabel = applyUpdateToPatientLabel(updatePatientLabelJson, orig)
+ val parsedUpdatePatientLabel = applyUpdateToPatientLabel(updatePatientLabelJson, orig)
parsedUpdatePatientLabel should be(expectedUpdatedPatientLabel)
}
@@ -51,7 +51,7 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = patientLabelEvidenceWriter.write(orig)
- writtenJson should be (
+ writtenJson should be(
"""{"id":1,"value":"Maybe","evidenceText":"evidence text","documentId":21,"evidenceId":10,"reportId":null,
"documentType":"document type","date":"2017-08-10","providerType":"provider type"}""".parseJson)
}
@@ -70,7 +70,7 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = patientLabelDefiningCriteriaWriter.write(orig)
- writtenJson should be ("""{"id":1,"value":"Yes"}""".parseJson)
+ writtenJson should be("""{"id":1,"value":"Yes"}""".parseJson)
}
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/SlotArmFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/SlotArmFormatSuite.scala
new file mode 100644
index 0000000..7dd085c
--- /dev/null
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/SlotArmFormatSuite.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.SlotArm
+
+class SlotArmFormatSuite extends FlatSpec with Matchers {
+ import slotarm._
+
+ "Json format for SlotArm" should "read and write correct JSON" in {
+ val arm = SlotArm(
+ id = LongId(10),
+ trialId = StringId("NCT000001"),
+ name = "arm name",
+ originalName = "orig arm name"
+ )
+ val writtenJson = slotArmFormat.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 = slotArmFormat.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)
+ }
+}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala
index 3533c07..a3da52f 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala
@@ -33,16 +33,16 @@ class TrialFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = trialWriter.write(orig)
- writtenJson should be (
+ writtenJson should be(
"""{"isPartner":false,"assignee":null,"lastUpdate":"2017-08-10T18:16:19Z","previousStatus":null,
"isUpdated":false,"overviewTemplate":"","phase":"","originalStudyDesignId":null,
"hypothesisId":"3b80b2e2-5372-4cf5-a342-6e4ebe10fafd","originalTitle":"orig trial title",
"studyDesignId":321,"lastActiveUser":null,"externalid":"40892a07-c638-49d2-9795-1edfefbbcc7c",
"id":"NCT000001","status":"New","overview":null,"previousAssignee":null,"title":"trial title"}""".parseJson)
- val updateTrialJson = """{"hypothesisId":null,"overview":"new overview"}""".parseJson
+ val updateTrialJson = """{"hypothesisId":null,"overview":"new overview"}""".parseJson
val expectedUpdatedTrial = orig.copy(hypothesisId = None, overview = Some("new overview"))
- val parsedUpdateTrial = applyUpdateToTrial(updateTrialJson, orig)
+ val parsedUpdateTrial = applyUpdateToTrial(updateTrialJson, orig)
parsedUpdateTrial should be(expectedUpdatedTrial)
}
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala
index dbb143c..d5ad2ec 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala
@@ -21,8 +21,7 @@ class TrialHistoryFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = trialHistoryFormat.write(trialHistory)
- writtenJson should be(
- """{"id":10,"executor":"userId-001","trialId":"NCT000001","state":"Summarize",
+ writtenJson should be("""{"id":10,"executor":"userId-001","trialId":"NCT000001","state":"Summarize",
"action":"Start","created":"2017-08-10T18:00Z"}""".parseJson)
val parsedTrialHistory = trialHistoryFormat.read(writtenJson)
diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala
index 02e14ba..4a9ea4f 100644
--- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala
+++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala
@@ -24,13 +24,13 @@ class TrialIssueFormatSuite extends FlatSpec with Matchers {
)
val writtenJson = trialIssueWriter.write(trialIssue)
- writtenJson should be(
- """{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
+ writtenJson should be("""{"id":10,"userId":"userId-001","lastUpdate":"2017-08-10T18:00Z","isDraft":false,
"text":"message text","evidence":"evidence","archiveRequired":false,"meta":"{}"}""".parseJson)
- val createTrialIssueJson = """{"text":"message text","evidence":"evidence","meta":"{}"}""".parseJson
+ val createTrialIssueJson = """{"text":"message text","evidence":"evidence","meta":"{}"}""".parseJson
val expectedCreatedTrialIssue = trialIssue.copy(id = LongId(0), lastUpdate = LocalDateTime.MIN, isDraft = true)
- val parsedCreateTrialIssue = jsValueToTrialIssue(createTrialIssueJson, StringId("NCT000001"), StringId("userId-001"))
+ val parsedCreateTrialIssue =
+ jsValueToTrialIssue(createTrialIssueJson, StringId("NCT000001"), StringId("userId-001"))
parsedCreateTrialIssue should be(expectedCreatedTrialIssue)
val updateTrialIssueJson =