diff options
author | Aleksandr <ognelisar@gmail.com> | 2017-11-14 15:45:50 +0700 |
---|---|---|
committer | Aleksandr <ognelisar@gmail.com> | 2017-11-14 15:45:50 +0700 |
commit | add98e1a1100d5b0fb666ac4669d0a90272959ca (patch) | |
tree | 4e32e92e7bc3a6373f95f04bd28f946b5b100234 /src/test/scala/xyz/driver | |
parent | 2afec69b277c031eb52e1a05e57ff7bb0079f8d1 (diff) | |
parent | 29ee5de759374ceed9c856a51443a3f7c2cec029 (diff) | |
download | rest-query-add98e1a1100d5b0fb666ac4669d0a90272959ca.tar.gz rest-query-add98e1a1100d5b0fb666ac4669d0a90272959ca.tar.bz2 rest-query-add98e1a1100d5b0fb666ac4669d0a90272959ca.zip |
Merge branch 'master' into PDSUI-2345
Diffstat (limited to 'src/test/scala/xyz/driver')
8 files changed, 19 insertions, 87 deletions
diff --git a/src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala b/src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala index eb9d9b4..8fd783f 100644 --- a/src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala +++ b/src/test/scala/xyz/driver/pdsuicommon/logging/PhiStringContextSuite.scala @@ -4,7 +4,7 @@ import org.scalatest.FreeSpecLike class PhiStringContextSuite extends FreeSpecLike { - class Foo(x: Int, y: String) { + case class Foo(x: Int, y: String) { val z: Boolean = true } diff --git a/src/test/scala/xyz/driver/pdsuicommon/parsers/TestUtils.scala b/src/test/scala/xyz/driver/pdsuicommon/parsers/TestUtils.scala index 09b60ed..8ab2131 100644 --- a/src/test/scala/xyz/driver/pdsuicommon/parsers/TestUtils.scala +++ b/src/test/scala/xyz/driver/pdsuicommon/parsers/TestUtils.scala @@ -21,7 +21,7 @@ object TestUtils { MatchResult( left.isFailure && left.failed.get.getClass == ct.runtimeClass, left match { - case Success(x) => s"$left did not fail" + case Success(_) => s"$left did not fail" case Failure(e) => s"$left did fail with ${Utils.getClassSimpleName(e.getClass)}, " + s"not ${Utils.getClassSimpleName(ct.runtimeClass)}" @@ -45,7 +45,7 @@ object TestUtils { def failureProp: Prop = self match { case Success(x) => false :| s"invalid: $x" - case Failure(e) => true + case Failure(_) => true } } diff --git a/src/test/scala/xyz/driver/pdsuicommon/utils/DiffUtils.scala b/src/test/scala/xyz/driver/pdsuicommon/utils/DiffUtils.scala deleted file mode 100644 index 156cb08..0000000 --- a/src/test/scala/xyz/driver/pdsuicommon/utils/DiffUtils.scala +++ /dev/null @@ -1,68 +0,0 @@ -package xyz.driver.pdsuicommon.utils - -import java.net.URI -import java.time.{LocalDate, LocalDateTime} - -import ai.x.diff._ -import org.scalatest.Assertions -import xyz.driver.pdsuidomain.entities.{Document, ExtractedData, MedicalRecord} - -import scala.io.AnsiColor - -trait DiffUtils { this: Assertions => - - def assertIdentical[T: DiffShow](left: T, right: T): Unit = { - val diff = DiffShow.diff(left, right) - assert(diff.isIdentical, s"\n${AnsiColor.RESET}$diff") // reset red color - } - - implicit def localTimeDiffShow: DiffShow[LocalDateTime] = new DiffShow[LocalDateTime] { - def show(x: LocalDateTime): String = s"LocalTime($x)" - def diff(left: LocalDateTime, right: LocalDateTime): Comparison = { - if (left.isEqual(right)) Identical(show(left)) - else Different(showChange(left, right)) - } - } - - implicit def localDateDiffShow: DiffShow[LocalDate] = new DiffShow[LocalDate] { - def show(x: LocalDate): String = s"LocalDate($x)" - def diff(left: LocalDate, right: LocalDate): Comparison = { - if (left.isEqual(right)) Identical(show(left)) - else Different(showChange(left, right)) - } - } - - implicit def urlDiffShow: DiffShow[URI] = new DiffShow[URI] { - def show(x: URI): String = s"URI($x)" - def diff(left: URI, right: URI): Comparison = { - if (left.equals(right)) Identical(show(left)) - else Different(showChange(left, right)) - } - } - - implicit def metaDiffShow: DiffShow[MedicalRecord.Meta] = new DiffShow[MedicalRecord.Meta] { - def show(x: MedicalRecord.Meta): String = s"MedicalRecord.Meta($x)" - def diff(left: MedicalRecord.Meta, right: MedicalRecord.Meta): Comparison = { - if (left.equals(right)) Identical(show(left)) - else Different(showChange(left, right)) - } - } - - implicit def extractedDataMetaDiffShow: DiffShow[ExtractedData.Meta] = new DiffShow[ExtractedData.Meta] { - def show(x: ExtractedData.Meta): String = s"ExtractedData.Meta($x)" - def diff(left: ExtractedData.Meta, right: ExtractedData.Meta): Comparison = { - if (left.equals(right)) Identical(show(left)) - else Different(showChange(left, right)) - } - } - - implicit def documentDiffShow: DiffShow[Document] = new DiffShow[Document] { - def show(x: Document): String = s"Document($x)" - - def diff(left: Document, right: Document): Comparison = { - if (left == right) Identical(show(left)) - else Different(showChange(left, right)) - } - } - -} diff --git a/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala index 63c4aa2..ccd5a3a 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/DocumentSuite.scala @@ -7,10 +7,9 @@ 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 FreeSpecLike with DiffUtils with ScalaFutures { +class DocumentSuite extends FreeSpecLike with ScalaFutures { implicit val defaultPatience: PatienceConfig = PatienceConfig(timeout = Span(1000, Millis), interval = Span(20, Millis)) 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 e0f96bb..94d80c9 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala @@ -22,8 +22,8 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers { criterionText = "criterion text", criterionValue = Some(true), criterionIsDefining = false, - eligibilityStatus = Some(LabelValue.Yes), - verifiedEligibilityStatus = None, + eligibilityStatus = LabelValue.Yes, + verifiedEligibilityStatus = LabelValue.Unknown, isVisible = true, isVerified = true, lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00"), @@ -39,12 +39,12 @@ class PatientCriterionFormatSuite extends FlatSpec with Matchers { writtenJson should be( """{"isVerified":true,"patientLabelId":1,"lastUpdate":"2017-08-10T18:00Z","trialId":0, "armList":[{"patientCriterionId":1,"armId":31,"armName":"arm 31"},{"patientCriterionId":1, - "armId":32,"armName":"arm 32"}],"eligibilityStatus":"Yes","id":1,"nctId":"NCT00001", + "armId":32,"armName":"arm 32"}],"eligibilityStatus":"Yes","verifiedEligibilityStatus":"Unknown","id":1,"nctId":"NCT00001", "criterionId":101,"criterionValue":true,"criterionIsDefining":false,"labelId":21, "isVisible":true,"criterionText":"criterion text","inclusion":true}""".parseJson) val updatePatientCriterionJson = """{"verifiedEligibilityStatus":"No"}""".parseJson - val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = Some(LabelValue.No)) + val expectedUpdatedPatientCriterion = orig.copy(verifiedEligibilityStatus = LabelValue.No) val parsedUpdatePatientCriterion = applyUpdateToPatientCriterion(updatePatientCriterionJson, orig) parsedUpdatePatientCriterion should be(expectedUpdatedPatientCriterion) diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientEligibleTrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientEligibleTrialFormatSuite.scala index b5fbf3f..faef0f6 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientEligibleTrialFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientEligibleTrialFormatSuite.scala @@ -38,8 +38,8 @@ class PatientEligibleTrialFormatSuite extends FlatSpec with Matchers { patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), trialId = StringId("NCT000001"), hypothesisId = UuidId("e76e2fc4-a29c-44fb-a81b-8856d06bb1d4"), - eligibilityStatus = Some(LabelValue.Yes), - verifiedEligibilityStatus = Some(LabelValue.Yes), + eligibilityStatus = LabelValue.Yes, + verifiedEligibilityStatus = LabelValue.Yes, isVerified = false ) val arms = List( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala index b83aad1..289de53 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala @@ -17,8 +17,8 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { id = LongId(1), patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), labelId = LongId(20), - primaryValue = Some(LabelValue.Yes), - verifiedPrimaryValue = None, + primaryValue = LabelValue.Yes, + verifiedPrimaryValue = LabelValue.Unknown, isVisible = true, score = 1, isImplicitMatch = false @@ -26,11 +26,11 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { val writtenJson = richPatientLabelFormat.write(RichPatientLabel(orig, isVerified = true)) writtenJson should be( - """{"id":1,"labelId":20,"primaryValue":"Yes","isVisible":true,"isVerified":true, + """{"id":1,"labelId":20,"primaryValue":"Yes","isVisible":true,"isVerified":true,"verifiedPrimaryValue":"Unknown", "score":1,"isImplicitMatch":false, "patientId":"748b5884-3528-4cb9-904b-7a8151d6e343"}""".parseJson) val updatePatientLabelJson = """{"verifiedPrimaryValue":"No"}""".parseJson - val expectedUpdatedPatientLabel = orig.copy(verifiedPrimaryValue = Some(LabelValue.No)) + val expectedUpdatedPatientLabel = orig.copy(verifiedPrimaryValue = LabelValue.No) val parsedUpdatePatientLabel = applyUpdateToPatientLabel(updatePatientLabelJson, orig) parsedUpdatePatientLabel should be(expectedUpdatedPatientLabel) } @@ -65,8 +65,8 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { id = LongId(1), patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), labelId = LongId(20), - primaryValue = Some(LabelValue.Yes), - verifiedPrimaryValue = Some(LabelValue.Yes), + primaryValue = LabelValue.Yes, + verifiedPrimaryValue = LabelValue.Yes, isVisible = true, score = 1, isImplicitMatch = false 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 c17327b..7f4f169 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala @@ -17,12 +17,13 @@ class TrialHistoryFormatSuite extends FlatSpec with Matchers { executor = xyz.driver.core.Id("userId-001"), state = TrialHistory.State.Summarize, action = TrialHistory.Action.Start, - created = LocalDateTime.parse("2017-08-10T18:00:00") + created = LocalDateTime.parse("2017-08-10T18:00:00"), + comment = Option("Yolo!") ) val writtenJson = trialHistoryFormat.write(trialHistory) writtenJson should be("""{"id":10,"executor":"userId-001","trialId":"NCT000001","state":"Summarize", - "action":"Start","created":"2017-08-10T18:00Z"}""".parseJson) + "action":"Start","created":"2017-08-10T18:00Z", "comment": "Yolo!"}""".parseJson) val parsedTrialHistory = trialHistoryFormat.read(writtenJson) parsedTrialHistory should be(trialHistory) |