diff options
author | Vlad Uspensky <v.uspenskiy@icloud.com> | 2017-11-02 20:40:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-02 20:40:31 -0700 |
commit | aedb5274932db81a32f9d89938636df114dc9a44 (patch) | |
tree | 13a0a8a51f477a4fce2bb8f4d5cd8248de54a73b /src/test/scala/xyz/driver/pdsuidomain | |
parent | 4583af5213b9f7b1e8a06f58321813556763f2d1 (diff) | |
parent | 5515c834853cbe3ce60460a4819a94805cfe24f7 (diff) | |
download | rest-query-aedb5274932db81a32f9d89938636df114dc9a44.tar.gz rest-query-aedb5274932db81a32f9d89938636df114dc9a44.tar.bz2 rest-query-aedb5274932db81a32f9d89938636df114dc9a44.zip |
Merge pull request #59 from drivergroup/common-contextsv0.13.1
Using common request contexts and user objects
Diffstat (limited to 'src/test/scala/xyz/driver/pdsuidomain')
13 files changed, 48 insertions, 37 deletions
diff --git a/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala index 915e4e7..63c4aa2 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala @@ -3,11 +3,17 @@ package xyz.driver.pdsuidomain import java.time.{LocalDate, LocalDateTime} import java.time.temporal.ChronoUnit -import xyz.driver.pdsuicommon.BaseSuite +import org.scalatest.FreeSpecLike +import org.scalatest.concurrent.ScalaFutures +import org.scalatest.time.{Millis, Span} import xyz.driver.pdsuicommon.domain.{LongId, TextJson} +import xyz.driver.pdsuicommon.utils.DiffUtils import xyz.driver.pdsuidomain.entities.Document -class DocumentSuite extends BaseSuite { +class DocumentSuite extends FreeSpecLike with DiffUtils with ScalaFutures { + + implicit val defaultPatience: PatienceConfig = + PatienceConfig(timeout = Span(1000, Millis), interval = Span(20, Millis)) "validation" - { "can't submit invalid data" - { diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala index e4a0733..4dc4d00 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala @@ -2,9 +2,9 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import spray.json._ +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.DocumentHistory class DocumentHistoryFormatSuite extends FlatSpec with Matchers { @@ -14,7 +14,7 @@ class DocumentHistoryFormatSuite extends FlatSpec with Matchers { val documentHistory = DocumentHistory( id = LongId(10), documentId = LongId(1), - executor = StringId("userId-001"), + executor = xyz.driver.core.Id("userId-001"), state = DocumentHistory.State.Extract, action = DocumentHistory.Action.Start, created = LocalDateTime.parse("2017-08-10T18:00:00") diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentIssueFormatSuite.scala index 7f34725..2ddd5e7 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentIssueFormatSuite.scala @@ -2,9 +2,9 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import spray.json._ +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.DocumentIssue class DocumentIssueFormatSuite extends FlatSpec with Matchers { @@ -14,7 +14,7 @@ class DocumentIssueFormatSuite extends FlatSpec with Matchers { val documentIssue = DocumentIssue( id = LongId(10), documentId = LongId(1), - userId = StringId("userId-001"), + userId = xyz.driver.core.Id("userId-001"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"), isDraft = false, text = "message text", @@ -31,7 +31,7 @@ class DocumentIssueFormatSuite extends FlatSpec with Matchers { 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 parsedCreateDocumentIssue = jsValueToDocumentIssue(createDocumentIssueJson, LongId(1), StringId("userId-001")) + val parsedCreateDocumentIssue = jsValueToDocumentIssue(createDocumentIssueJson, LongId(1), xyz.driver.core.Id("userId-001")) parsedCreateDocumentIssue should be(expectedCreatedDocumentIssue) val updateDocumentIssueJson = diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala index c976243..9c53d3b 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala @@ -1,13 +1,14 @@ package xyz.driver.pdsuidomain.formats.json import java.time.{LocalDate, LocalDateTime} -import java.util.UUID import org.scalatest.{FlatSpec, Matchers} import spray.json._ +import xyz.driver.core.Id +import xyz.driver.entities.clinic.ClinicalRecord import xyz.driver.entities.labels.LabelValue import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} -import xyz.driver.pdsuidomain.entities.{DocumentType, ProviderType, RecordRequestId} +import xyz.driver.pdsuidomain.entities.{DocumentType, ProviderType} class ExportFormatSuite extends FlatSpec with Matchers { import xyz.driver.pdsuidomain.formats.json.export._ @@ -16,7 +17,7 @@ class ExportFormatSuite extends FlatSpec with Matchers { import xyz.driver.pdsuidomain.entities.export.patient._ val document = ExportPatientLabelEvidenceDocument( documentId = LongId(101), - requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")), + requestId = Id[ClinicalRecord]("7b54a75d-4197-4b27-9045-b9b6cb131be9"), documentType = DocumentType.OutpatientPhysicianNote, providerType = ProviderType.Surgery, date = LocalDate.parse("2017-08-10") diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/ListResponseFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ListResponseFormatSuite.scala index c561412..e43e922 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/ListResponseFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ListResponseFormatSuite.scala @@ -1,10 +1,11 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import java.util.UUID import spray.json._ import org.scalatest.{FlatSpec, Matchers} +import xyz.driver.core.Id +import xyz.driver.entities.clinic.ClinicalRecord import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuidomain.ListResponse import xyz.driver.pdsuidomain.entities.MedicalRecord.Status @@ -18,7 +19,7 @@ class ListResponseFormatSuite extends FlatSpec with Matchers { private val lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00") private val lastUpdateToLocal = "2017-08-10T18:00Z" - def metaJsonObjectAsString(meta: ListResponse.Meta) = { + def metaJsonObjectAsString(meta: ListResponse.Meta): String = { import meta._ val lastUpdate = meta.lastUpdate .map(_ => s""","lastUpdate":"$lastUpdateToLocal"""") @@ -74,7 +75,7 @@ class ListResponseFormatSuite extends FlatSpec with Matchers { physician = Some("physician"), meta = None, disease = "Breast", - requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")), + requestId = Id[ClinicalRecord]("7b54a75d-4197-4b27-9045-b9b6cb131be9"), caseId = None, patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), totalPages = 10 diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala index b4e37a2..86462b2 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala @@ -1,12 +1,13 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import java.util.UUID import spray.json._ import org.scalatest.{FlatSpec, Matchers} +import xyz.driver.core.Id +import xyz.driver.entities.clinic.ClinicalRecord import xyz.driver.pdsuicommon.domain.{LongId, TextJson, UuidId} -import xyz.driver.pdsuidomain.entities.{MedicalRecord, RecordRequestId} +import xyz.driver.pdsuidomain.entities.MedicalRecord class MedicalRecordFormatSuite extends FlatSpec with Matchers { import xyz.driver.pdsuidomain.formats.json.record._ @@ -98,7 +99,7 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers { physician = Some("physician"), meta = None, disease = "Breast", - requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")), + requestId = Id[ClinicalRecord]("7b54a75d-4197-4b27-9045-b9b6cb131be9"), caseId = None, patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), totalPages = 10 @@ -120,7 +121,7 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers { previousAssignee = None, lastActiveUserId = None, patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), - requestId = RecordRequestId(UUID.fromString("7b54a75d-4197-4b27-9045-b9b6cb131be9")), + requestId = Id[ClinicalRecord]("7b54a75d-4197-4b27-9045-b9b6cb131be9"), disease = "Breast", caseId = None, physician = None, diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala index ca4058e..88240cd 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala @@ -2,9 +2,9 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import spray.json._ +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.MedicalRecordHistory class MedicalRecordHistoryFormatSuite extends FlatSpec with Matchers { @@ -14,7 +14,7 @@ class MedicalRecordHistoryFormatSuite extends FlatSpec with Matchers { val recordHistory = MedicalRecordHistory( id = LongId(10), recordId = LongId(1), - executor = StringId("userId-001"), + executor = xyz.driver.core.Id("userId-001"), state = MedicalRecordHistory.State.Clean, action = MedicalRecordHistory.Action.Start, created = LocalDateTime.parse("2017-08-10T18:00:00") diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordIssueFormatSuite.scala index c7c82a4..b93e2bd 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordIssueFormatSuite.scala @@ -2,9 +2,9 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{LongId, StringId} +import spray.json._ +import xyz.driver.pdsuicommon.domain.LongId import xyz.driver.pdsuidomain.entities.MedicalRecordIssue class MedicalRecordIssueFormatSuite extends FlatSpec with Matchers { @@ -14,7 +14,7 @@ class MedicalRecordIssueFormatSuite extends FlatSpec with Matchers { val recordIssue = MedicalRecordIssue( id = LongId(10), recordId = LongId(1), - userId = StringId("userId-001"), + userId = xyz.driver.core.Id("userId-001"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"), isDraft = false, text = "message text", @@ -30,7 +30,7 @@ class MedicalRecordIssueFormatSuite extends FlatSpec with Matchers { 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), xyz.driver.core.Id("userId-001")) parsedCreateRecordIssue should be(expectedCreatedRecordIssue) val updateRecordIssueJson = diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientFormatSuite.scala index c296f84..6cddb45 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientFormatSuite.scala @@ -4,10 +4,12 @@ import java.time.{LocalDate, LocalDateTime} import spray.json._ import org.scalatest.{FlatSpec, Matchers} +import xyz.driver.core.Id +import xyz.driver.entities.clinic.TestOrder import xyz.driver.entities.common.FullName import xyz.driver.entities.patient.CancerType import xyz.driver.pdsuicommon.domain.UuidId -import xyz.driver.pdsuidomain.entities.{Patient, PatientOrderId} +import xyz.driver.pdsuidomain.entities.Patient class PatientFormatSuite extends FlatSpec with Matchers { import xyz.driver.pdsuidomain.formats.json.patient._ @@ -24,7 +26,7 @@ class PatientFormatSuite extends FlatSpec with Matchers { lastActiveUserId = None, isUpdateRequired = false, disease = CancerType.Breast, - orderId = PatientOrderId("7b54a75d-4197-4b27-9045-b9b6cb131be9"), + orderId = Id[TestOrder]("7b54a75d-4197-4b27-9045-b9b6cb131be9"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00") ) val writtenJson = patientFormat.write(orig) diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHistoryFormatSuite.scala index e46cf50..74f6f70 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHistoryFormatSuite.scala @@ -2,9 +2,9 @@ package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime -import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} +import spray.json._ +import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuidomain.entities.PatientHistory class PatientHistoryFormatSuite extends FlatSpec with Matchers { @@ -14,7 +14,7 @@ class PatientHistoryFormatSuite extends FlatSpec with Matchers { val patientHistory = PatientHistory( id = LongId(10), patientId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"), - executor = StringId("userId-001"), + executor = xyz.driver.core.Id("userId-001"), state = PatientHistory.State.Verify, action = PatientHistory.Action.Start, created = LocalDateTime.parse("2017-08-10T18:00:00") 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..ee76094 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala @@ -4,7 +4,7 @@ import java.time.LocalDateTime import spray.json._ import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} +import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuidomain.entities.PatientIssue class PatientIssueFormatSuite extends FlatSpec with Matchers { @@ -14,7 +14,7 @@ class PatientIssueFormatSuite extends FlatSpec with Matchers { val patientIssue = PatientIssue( id = LongId(10), patientId = UuidId("40892a07-c638-49d2-9795-1edfefbbcc7c"), - userId = StringId("userId-001"), + userId = xyz.driver.core.Id("userId-001"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"), isDraft = false, text = "message text", @@ -29,7 +29,7 @@ class PatientIssueFormatSuite extends FlatSpec with Matchers { 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")) + xyz.driver.core.Id("userId-001")) parsedCreatePatientIssue should be(expectedCreatedPatientIssue) val updatePatientIssueJson = diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala index aa0b404..c17327b 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala @@ -14,7 +14,7 @@ class TrialHistoryFormatSuite extends FlatSpec with Matchers { val trialHistory = TrialHistory( id = LongId(10), trialId = StringId("NCT000001"), - executor = StringId("userId-001"), + executor = xyz.driver.core.Id("userId-001"), state = TrialHistory.State.Summarize, action = TrialHistory.Action.Start, created = LocalDateTime.parse("2017-08-10T18:00:00") diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialIssueFormatSuite.scala index 5c6aa8d..a3b5931 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialIssueFormatSuite.scala @@ -14,7 +14,7 @@ class TrialIssueFormatSuite extends FlatSpec with Matchers { val trialIssue = TrialIssue( id = LongId(10), trialId = StringId("NCT000001"), - userId = StringId("userId-001"), + userId = xyz.driver.core.Id("userId-001"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"), isDraft = false, text = "message text", @@ -30,7 +30,7 @@ class TrialIssueFormatSuite extends FlatSpec with Matchers { 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")) + jsValueToTrialIssue(createTrialIssueJson, StringId("NCT000001"), xyz.driver.core.Id("userId-001")) parsedCreateTrialIssue should be(expectedCreatedTrialIssue) val updateTrialIssueJson = |