From 78f467dd0b3b9f35bb49ae973b26fb37c458b138 Mon Sep 17 00:00:00 2001 From: vlad Date: Mon, 30 Oct 2017 14:21:55 -0700 Subject: Fixing Patients and Trials parsing, some refined to try --- .../pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala | 6 ++++-- .../driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/test/scala/xyz') diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala index 270a04d..7ff1109 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala @@ -1,10 +1,12 @@ package xyz.driver.pdsuidomain.formats.json +import eu.timepit.refined.numeric.NonNegative import spray.json._ import org.scalatest.{FlatSpec, Matchers} import xyz.driver.pdsuicommon.domain.UuidId import xyz.driver.pdsuidomain.entities.PatientHypothesis import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis +import eu.timepit.refined.refineMV class PatientHypothesisFormatSuite extends FlatSpec with Matchers { import xyz.driver.pdsuidomain.formats.json.patienthypothesis._ @@ -15,7 +17,7 @@ class PatientHypothesisFormatSuite extends FlatSpec with Matchers { patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), hypothesisId = UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4"), rationale = None, - matchedTrials = 1 + matchedTrials = refineMV[NonNegative](1) ) val writtenJson = richPatientHypothesisWriter.write(RichPatientHypothesis(orig, isRequired = true)) @@ -35,7 +37,7 @@ class PatientHypothesisFormatSuite extends FlatSpec with Matchers { patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), hypothesisId = UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4"), rationale = None, - matchedTrials = 1 + matchedTrials = refineMV[NonNegative](1) ) val writtenJson = patientHypothesisWriter.write(orig) diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala index 0d56918..d904150 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala @@ -2,10 +2,12 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime +import eu.timepit.refined.collection.NonEmpty import spray.json._ import org.scalatest.{FlatSpec, Matchers} import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.PatientIssue +import eu.timepit.refined.refineMV class PatientIssueFormatSuite extends FlatSpec with Matchers { import xyz.driver.pdsuidomain.formats.json.patientissue._ @@ -17,7 +19,7 @@ class PatientIssueFormatSuite extends FlatSpec with Matchers { userId = StringId("userId-001"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"), isDraft = false, - text = "message text", + text = refineMV[NonEmpty]("message text"), archiveRequired = false ) val writtenJson = patientIssueWriter.write(patientIssue) @@ -35,7 +37,7 @@ class PatientIssueFormatSuite extends FlatSpec with Matchers { val updatePatientIssueJson = """{"text":"new issue text","evidence":"issue evidence","archiveRequired":true}""".parseJson val expectedUpdatedPatientIssue = patientIssue.copy( - text = "new issue text", + text = refineMV[NonEmpty]("new issue text"), archiveRequired = true ) val parsedUpdatePatientIssue = applyUpdateToPatientIssue(updatePatientIssueJson, patientIssue) -- cgit v1.2.3