diff options
author | timgushue <tim@driver.xyz> | 2017-09-27 09:34:45 -0700 |
---|---|---|
committer | timgushue <tim@driver.xyz> | 2017-09-27 09:34:45 -0700 |
commit | e9d3e19f637614809aab39d9df2d1fcc6c78916e (patch) | |
tree | 29560b9b5bfb1b235c6429506f56fa9dab8d4510 /src/test/scala | |
parent | 0ef0059e9b47430e52d6bad4ced5b1be7f3b1a0d (diff) | |
parent | c24679f1ae7d7ccc4e6693535b0aa3ac0e1ca225 (diff) | |
download | rest-query-e9d3e19f637614809aab39d9df2d1fcc6c78916e.tar.gz rest-query-e9d3e19f637614809aab39d9df2d1fcc6c78916e.tar.bz2 rest-query-e9d3e19f637614809aab39d9df2d1fcc6c78916e.zip |
Merge branch 'master' into add-slot-eligibility-arms
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala | 10 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala | 16 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala b/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala index f47f4c2..ba67d13 100644 --- a/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala +++ b/src/test/scala/xyz/driver/pdsuicommon/parsers/SearchFilterParserSuite.scala @@ -9,6 +9,7 @@ import org.scalacheck.Arbitrary.arbitrary import org.scalacheck.{Gen, Prop} import org.scalatest.FreeSpecLike import org.scalatest.prop.Checkers +import xyz.driver.pdsuicommon.db.SearchFilterBinaryOperation.Eq import xyz.driver.pdsuicommon.db.SearchFilterNAryOperation.In import xyz.driver.pdsuicommon.utils.Utils import xyz.driver.pdsuicommon.utils.Utils._ @@ -104,6 +105,13 @@ class SearchFilterParserSuite extends FreeSpecLike with Checkers { } } + "actual recordId" - { + "should not be parsed with text values" in { + val filter = SearchFilterParser.parse(Seq("filters" -> "recordId EQ 1")) + assert(filter === Success(SearchFilterExpr.Atom.Binary(Dimension(None, "record_id"), Eq, Long.box(1)))) + } + } + "all operators" - { "should be parsed with numeric values" in check { val testQueryGen = queryGen( @@ -181,7 +189,7 @@ class SearchFilterParserSuite extends FreeSpecLike with Checkers { private val nonEmptyString = arbitrary[String].filter { s => !s.safeTrim.isEmpty } - private val numericBinaryAtomValuesGen: Gen[String] = arbitrary[BigInt].map(_.toString) + private val numericBinaryAtomValuesGen: Gen[String] = arbitrary[Long].map(_.toString) private val inValueGen: Gen[String] = { Gen.nonEmptyContainerOf[Seq, Char](inValueCharsGen).map(_.mkString).filter(_.safeTrim.nonEmpty) } 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 a52c385..dad39c8 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 @@ -18,7 +18,8 @@ class InterventionFormatSuite extends FlatSpec with Matchers { originalType = Some("orig type"), dosage = "", originalDosage = "", - isActive = true + isActive = true, + deliveryMethod = Some("pill") ) val arms = List( InterventionArm(interventionId = intervention.id, armId = LongId(20)), @@ -33,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","originalName":"orig name","originalDosage":"","originalType":"orig type"}""".parseJson) + "trialId":"NCT000001","deliveryMethod":"pill","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"}""".parseJson + "trialId":"NCT000001","deliveryMethod":"pill"}""".parseJson val parsedCreateIntervention = interventionFormat.read(createInterventionJson) val expectedCreateIntervention = parsedCreateIntervention.copy( intervention = intervention.copy(id = LongId(0), originalType = None, originalName = "intervention name"), @@ -58,13 +59,12 @@ class InterventionFormatSuite extends FlatSpec with Matchers { } "Json format for InterventionType" should "read and write correct JSON" in { - val interventionType = InterventionType( - id = LongId(10), - name = "type name" - ) + val interventionType = InterventionType.typeFromString("Surgery/Procedure") val writtenJson = interventionTypeFormat.write(interventionType) - writtenJson should be("""{"id":10,"name":"type name"}""".parseJson) + writtenJson should be( + """{"id":9,"name":"Surgery/Procedure","deliveryMethods":["Radio-Frequency Ablation (RFA)", + "Cryoablation","Therapeutic Conventional Surgery","Robotic Assisted Laparoscopic Surgery"]}""".parseJson) val parsedInterventionType = interventionTypeFormat.read(writtenJson) parsedInterventionType should be(interventionType) |