diff options
author | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-27 12:41:33 +0700 |
---|---|---|
committer | Kseniya Tomskikh <ktomskih@datamonsters.co> | 2017-10-27 12:41:33 +0700 |
commit | d9440a727edd25f2472754dc51b0206d6abbeba4 (patch) | |
tree | 1e7a123e5f28c7b5adfa4962971a550d247c28dd /src/test/scala/xyz/driver | |
parent | b27ba47906e48e9fc59d65893c71309303f73fc8 (diff) | |
parent | fde83eb31ef4f2c2334b41d3a727239c034bfd63 (diff) | |
download | rest-query-d9440a727edd25f2472754dc51b0206d6abbeba4.tar.gz rest-query-d9440a727edd25f2472754dc51b0206d6abbeba4.tar.bz2 rest-query-d9440a727edd25f2472754dc51b0206d6abbeba4.zip |
Merge branch 'master' into PDSUI-2336
Diffstat (limited to 'src/test/scala/xyz/driver')
6 files changed, 119 insertions, 18 deletions
diff --git a/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala b/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala index ac5eec1..0209222 100644 --- a/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala +++ b/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala @@ -1,5 +1,7 @@ package xyz.driver.pdsuicommon.parsers +import java.util.UUID + import xyz.driver.pdsuicommon.db.SearchFilterExpr.Dimension import xyz.driver.pdsuicommon.db.{SearchFilterBinaryOperation, SearchFilterExpr, SearchFilterNAryOperation} import xyz.driver.pdsuicommon.utils.Implicits.toStringOps @@ -126,6 +128,14 @@ class SearchFilterParserSuite extends FreeSpecLike with Checkers { } } + "actual patientId uuid" - { + "should parse the full UUID as java.util.UUID type" in { + val filter = SearchFilterParser.parse(Seq("filters" -> "patientId EQ 4b4879f7-42b3-4b7c-a685-5c97d9e69e7c")) + assert(filter === Success(SearchFilterExpr.Atom.Binary( + Dimension(None, "patient_id"), Eq, UUID.fromString("4b4879f7-42b3-4b7c-a685-5c97d9e69e7c")))) + } + } + "all operators" - { "should be parsed with numeric values" in check { val testQueryGen = queryGen( 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 1f024c3..c976243 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala @@ -92,7 +92,8 @@ class ExportFormatSuite extends FlatSpec with Matchers { armIds = Set(LongId(1), LongId(2)), criteria = "criteria 10 text", isCompound = false, - isDefining = false + isDefining = false, + inclusion = Some(false) ), ExportTrialLabelCriterion( criterionId = LongId(11), @@ -101,7 +102,8 @@ class ExportFormatSuite extends FlatSpec with Matchers { armIds = Set(LongId(2)), criteria = "criteria 11 text", isCompound = true, - isDefining = false + isDefining = false, + inclusion = None ) ) val trialWithLabels = ExportTrialWithLabels( @@ -117,8 +119,10 @@ class ExportFormatSuite extends FlatSpec with Matchers { writtenJson should be( """{"nctId":"NCT000001","trialId":"40892a07-c638-49d2-9795-1edfefbbcc7c","lastReviewed":"2017-08-10T18:00Z", "labelVersion":1,"arms":[{"armId":1,"armName":"arm 1","diseaseList":["Breast"]},{"armId":2,"armName":"arm 2","diseaseList":["Breast"]}],"criteria":[ - {"value":"Yes","labelId":21,"criterionId":10,"criterionText":"criteria 10 text","armIds":[1,2],"isCompound":false,"isDefining":false}, - {"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true,"isDefining":false}]}""".parseJson) + {"value":"Yes","labelId":21,"criterionId":10,"criterionText":"criteria 10 text","armIds":[1,2],"isCompound":false, + "isDefining":false,"inclusion":false}, + {"value":"Unknown","labelId":21,"criterionId":11,"criterionText":"criteria 11 text","armIds":[2],"isCompound":true, + "isDefining":false,"inclusion":null}]}""".parseJson) } } diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExtractedDataFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExtractedDataFormatSuite.scala index bc20280..d1d8d44 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExtractedDataFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExtractedDataFormatSuite.scala @@ -17,8 +17,18 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { documentId = LongId(101), keywordId = Some(LongId(201)), evidenceText = Some("evidence text"), - meta = None - ) + meta = Option(TextJson(Meta( + evidence = None, + keyword = + Some(Meta.Keyword( + page = 1, + pageRatio = Some(1.6161616161616161d), + index = 0, + sortIndex = "1080000" + )) + ) + ))) + val extractedDataLabels = List( ExtractedDataLabel( id = LongId(1), @@ -43,11 +53,13 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { 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) + "labels":[{"id":null,"categoryId":null,"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}], + "meta":{"keyword":{"index":0,"page":1,"pageRatio":1.6161616161616161,"sortIndex":"1080000"}}}""".parseJson) val createExtractedDataJson = """{"documentId":101,"keywordId":201,"evidence":"evidence text", - "labels":[{"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}]}""".parseJson + "labels":[{"value":"Yes"},{"id":12,"categoryId":1,"value":"No"}], + "meta":{"keyword":{"index":0,"page":1,"pageRatio":1.6161616161616161,"sortIndex":"1080000"}}}""".parseJson val expectedCreatedExtractedData = origRichExtractedData.copy( extractedData = extractedData.copy(id = LongId(0)), labels = extractedDataLabels.map(_.copy(id = LongId(0), dataId = LongId(0))) @@ -80,12 +92,12 @@ class ExtractedDataFormatSuite extends FlatSpec with Matchers { evidenceText = Some("new evidence text"), meta = Some( TextJson(Meta( - keyword = Meta.Keyword(page = 1, pageRatio = None, index = 2, sortIndex = "ASC"), - evidence = Meta.Evidence( + keyword = Some(Meta.Keyword(page = 1, pageRatio = None, index = 2, sortIndex = "ASC")), + evidence = Some(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/InterventionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/InterventionFormatSuite.scala index ac01c34..015c7b5 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/InterventionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/InterventionFormatSuite.scala @@ -19,7 +19,7 @@ class InterventionFormatSuite extends FlatSpec with Matchers { dosage = "", originalDosage = "", isActive = true, - deliveryMethod = Some("pill") + deliveryMethod = Some("Inhalation") ) val arms = List( InterventionArm(interventionId = intervention.id, armId = LongId(20)), @@ -34,11 +34,11 @@ class InterventionFormatSuite extends FlatSpec with Matchers { writtenJson should be( """{"id":1,"name":"intervention name","typeId":10,"dosage":"","isActive":true,"arms":[20,21,22], - "trialId":"NCT000001","deliveryMethod":"pill","originalName":"orig name","originalDosage":"","originalType":"orig type"}""".parseJson) + "trialId":"NCT000001","deliveryMethod":"Inhalation","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 + "trialId":"NCT000001","deliveryMethod":"Inhalation"}""".parseJson val parsedCreateIntervention = interventionFormat.read(createInterventionJson) val expectedCreateIntervention = parsedCreateIntervention.copy( intervention = intervention.copy(id = LongId(0), originalType = None, originalName = "intervention name"), @@ -46,9 +46,9 @@ class InterventionFormatSuite extends FlatSpec with Matchers { ) parsedCreateIntervention should be(expectedCreateIntervention) - val updateInterventionJson = """{"dosage":"descr","arms":[21,22]}""".parseJson + val updateInterventionJson = """{"dosage":"descr","deliveryMethod":null,"arms":[21,22]}""".parseJson val expectedUpdatedIntervention = orig.copy( - intervention = intervention.copy(dosage = "descr"), + intervention = intervention.copy(dosage = "descr", deliveryMethod = None), arms = List( InterventionArm(interventionId = intervention.id, armId = LongId(21)), InterventionArm(interventionId = intervention.id, armId = LongId(22)) 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 e811a29..b4e37a2 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala @@ -12,6 +12,80 @@ class MedicalRecordFormatSuite extends FlatSpec with Matchers { import xyz.driver.pdsuidomain.formats.json.record._ import MedicalRecord._ + "Json format for MedicalRecord.Meta" should "read and write correct JSON" in { + val duplicate1 = Meta.Duplicate( + startPage = 1.0d, + endPage = 2.0d, + startOriginalPage = 1.0d, + endOriginalPage = Some(2.0d) + ) + + val duplicate2 = Meta.Duplicate( + startPage = 1.0d, + endPage = 2.0d, + startOriginalPage = 1.0d, + endOriginalPage = None + ) + + val reorder = Meta.Reorder( + Seq(1, 2) + ) + + val rotation = Meta.Rotation( + Map("item1" -> 1, "item2" -> 2) + ) + + val writtenDuplicateJson1 = + duplicateMetaFormat.write(duplicate1) + + val writtenDuplicateJson2 = + duplicateMetaFormat.write(duplicate2) + + val writtenReorderJson = + reorderMetaFormat.write(reorder) + + val writtenRotationJson = + rotateMetaFormat.write(rotation) + + writtenDuplicateJson1 should be( + """{"startOriginalPage":1.0,"endPage":2.0,"startPage":1.0,"type":"duplicate","endOriginalPage":2.0}""".parseJson) + + writtenDuplicateJson2 should be( + """{"startOriginalPage":1.0,"endPage":2.0,"startPage":1.0,"type":"duplicate","endOriginalPage":null}""".parseJson) + + writtenReorderJson should be( + """{"type":"reorder","items":[1,2]}""".parseJson) + + writtenRotationJson should be( + """{"type":"rotation","items":{"item1":1,"item2":2}}""".parseJson) + + val parsedDuplicateJson1 = + duplicateMetaFormat.read(writtenDuplicateJson1) + + val parsedDuplicateJson2 = + duplicateMetaFormat.read(writtenDuplicateJson2) + + val parsedReorderJson = + reorderMetaFormat.read(writtenReorderJson) + + val parsedRotationJson = + rotateMetaFormat.read(writtenRotationJson) + + duplicate1 should be(parsedDuplicateJson1) + + duplicate2 should be(parsedDuplicateJson2) + + reorder should be(parsedReorderJson) + + rotation should be(parsedRotationJson) + + duplicate1 should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(duplicate1))) + duplicate2 should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(duplicate2))) + reorder should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(reorder))) + rotation should be(recordMetaTypeFormat.read(recordMetaTypeFormat.write(rotation))) + } + + "Json format for MedicalRecord" should "read and write correct JSON" in { val orig = MedicalRecord( id = LongId(1), diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala index 2e193c7..93284d9 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala @@ -26,7 +26,8 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers { verifiedEligibilityStatus = None, isVisible = true, isVerified = true, - lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00") + lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"), + inclusion = Some(true) ) val arms = List( PatientCriterionArm(patientCriterionId = LongId(1), armId = LongId(31), armName = "arm 31"), @@ -38,7 +39,7 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers { 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) + "isVisible":true,"isVerified":true,"lastUpdate":"2017-08-10T18:00Z","arms":["arm 31","arm 32"],"inclusion":true}""".parseJson) val updatePatientCriterionJson = """{"verifiedEligibilityStatus":"No"}""".parseJson val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = Some(LabelValue.No)) |