diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/scala/xyz/driver/pdsuicommon/BaseSuite.scala | 12 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuicommon/Mocks.scala | 51 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuicommon/concurrent/BridgeUploadQueueRepositoryAdapterSuite.scala | 285 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuicommon/db/QueryBuilderParametersSuite.scala | 310 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/ArmFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/BridgeUploadQueueFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala) | 6 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/CriterionFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentIssueFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/EligibilityArmWithDiseasesFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmWithDiseasesFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/ExtractedDataFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala) | 5 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/HypothesisFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/InterventionFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/ListResponseFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ListResponseFormatSuite.scala) | 6 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordIssueFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientEligibleTrialFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala) | 6 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHistoryFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHistoryFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala) | 8 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/SlotArmFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/SlotArmFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/StudyDesignFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala) | 6 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala) | 4 | ||||
-rw-r--r-- | src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialIssueFormatSuite.scala (renamed from src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala) | 4 |
31 files changed, 72 insertions, 707 deletions
diff --git a/src/test/scala/xyz/driver/pdsuicommon/BaseSuite.scala b/src/test/scala/xyz/driver/pdsuicommon/BaseSuite.scala index 7c9d8c4..29e7610 100644 --- a/src/test/scala/xyz/driver/pdsuicommon/BaseSuite.scala +++ b/src/test/scala/xyz/driver/pdsuicommon/BaseSuite.scala @@ -5,15 +5,12 @@ import java.time.{LocalDateTime, ZoneId} import org.scalatest.FreeSpecLike import org.scalatest.concurrent.ScalaFutures import org.scalatest.time.{Millis, Span} -import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.domain._ -import xyz.driver.pdsuicommon.error.UnexpectedFilterException import xyz.driver.pdsuicommon.utils.DiffUtils trait BaseSuite extends FreeSpecLike with DiffUtils with ScalaFutures { implicit val defaultPatience = PatienceConfig(timeout = Span(1000, Millis), interval = Span(20, Millis)) - implicit val sqlContext = new MockMySqlContext() def sampleUser(role: User.Role, email: String = "test@example.com", password: String = "123") = User( id = StringId("2001"), @@ -23,13 +20,4 @@ trait BaseSuite extends FreeSpecLike with DiffUtils with ScalaFutures { latestActivity = Some(LocalDateTime.now(ZoneId.of("Z"))), deleted = None ) - - def createMockQueryBuilder[T](isExpectedFilter: SearchFilterExpr => Boolean): MysqlQueryBuilder[T] = { - MockQueryBuilder[T] { - case (filter, _, _) if isExpectedFilter(filter) => Seq.empty - case (filter, _, _) => throw new UnexpectedFilterException(s"Filter is unexpected: $filter") - } { - case _ => (0, Option.empty[LocalDateTime]) - } - } } diff --git a/src/test/scala/xyz/driver/pdsuicommon/Mocks.scala b/src/test/scala/xyz/driver/pdsuicommon/Mocks.scala index 51d39e5..699020c 100644 --- a/src/test/scala/xyz/driver/pdsuicommon/Mocks.scala +++ b/src/test/scala/xyz/driver/pdsuicommon/Mocks.scala @@ -6,7 +6,7 @@ import java.sql.Connection import java.util.logging.Logger import javax.sql.DataSource -import com.typesafe.config.ConfigFactory +import xyz.driver.pdsuicommon.db.SlickQueryBuilder.TableData import xyz.driver.pdsuicommon.db._ import xyz.driver.pdsuicommon.http.HttpFetcher @@ -27,32 +27,7 @@ class MockDataSource extends DataSource with Closeable { override def isWrapperFor(iface: Class[_]): Boolean = throw new NotImplementedError("MockDataSource.isWrapperFor") } -object MockMySqlContext { - - val Settings = MySqlContext.Settings( - credentials = MySqlContext.DbCredentials( - user = "test", - password = "test", - host = "localhost", - port = 3248, - dbName = "test", - dbCreateFlag = false, - dbContext = "test", - connectionParams = "", - url = "" - ), - connection = ConfigFactory.empty(), - threadPoolSize = 10 - ) -} - -class MockMySqlContext() extends MySqlContext(new MockDataSource, MockMySqlContext.Settings) { - override protected def withConnection[T](f: Connection => T): Nothing = { - throw new NotImplementedError("MockSqlContext.withConnection") - } -} - -class MockFactory()(implicit val sqlContext: MySqlContext) { +class MockFactory()(implicit val sqlContext: PostgresContext) { val MockHttpFetcher: HttpFetcher = { (url: URL) => Future.successful(Array.empty[Byte]) } @@ -61,28 +36,26 @@ class MockFactory()(implicit val sqlContext: MySqlContext) { object MockQueryBuilder { type MockRunnerIn = (SearchFilterExpr, Sorting, Option[Pagination]) - type MockRunnerOut[T] = Seq[T] - type MockCountRunnerOut = QueryBuilder.CountResult + type MockRunnerOut[T] = Future[Seq[T]] + type MockCountRunnerOut = SlickQueryBuilder.CountResult def apply[T](matcher: PartialFunction[MockRunnerIn, MockRunnerOut[T]])( countMatcher: PartialFunction[MockRunnerIn, MockCountRunnerOut])( - implicit context: MySqlContext): MysqlQueryBuilder[T] = { + implicit context: PostgresContext): SlickQueryBuilder[T] = { - val runner: QueryBuilder.Runner[T] = { parameters => + val runner: SlickQueryBuilder.Runner[T] = { parameters => matcher((parameters.filter, parameters.sorting, parameters.pagination)) } - val countRunner: QueryBuilder.CountRunner = { parameters => + val countRunner: SlickQueryBuilder.CountRunner = { parameters => countMatcher((parameters.filter, parameters.sorting, parameters.pagination)) } - MysqlQueryBuilder[T]( - tableName = "", - lastUpdateFieldName = Option.empty[String], - nullableFields = Set.empty[String], - links = Set.empty[TableLink], - runner = runner, - countRunner = countRunner + val parameters = SlickPostgresQueryBuilderParameters( + databaseName = "test", + tableData = TableData("", None, Set.empty[String]), + links = Map.empty ) + new SlickPostgresQueryBuilder(parameters)(runner, countRunner) } } diff --git a/src/test/scala/xyz/driver/pdsuicommon/concurrent/BridgeUploadQueueRepositoryAdapterSuite.scala b/src/test/scala/xyz/driver/pdsuicommon/concurrent/BridgeUploadQueueRepositoryAdapterSuite.scala deleted file mode 100644 index 8b38316..0000000 --- a/src/test/scala/xyz/driver/pdsuicommon/concurrent/BridgeUploadQueueRepositoryAdapterSuite.scala +++ /dev/null @@ -1,285 +0,0 @@ -package xyz.driver.pdsuicommon.concurrent - -import java.util.concurrent.ThreadLocalRandom - -import xyz.driver.pdsuicommon.BaseSuite -import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueueRepositoryAdapter.Strategy -import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueueRepositoryAdapter.Strategy.{OnAttempt, OnComplete} -import xyz.driver.pdsuicommon.db.{FakeDbIo, MysqlQueryBuilder} -import xyz.driver.pdsuicommon.db.repositories.BridgeUploadQueueRepository - -import scala.concurrent.Future -import scala.concurrent.duration.DurationInt - -class BridgeUploadQueueRepositoryAdapterSuite extends BaseSuite { - - // IDEA have some issue here with imports - private implicit val executionContext = scala.concurrent.ExecutionContext.global - - "Strategy" - { - "LimitExponential" - { - "on" - { - val strategy = Strategy.LimitExponential( - startInterval = 10.seconds, - intervalFactor = 1.4, - maxInterval = 50.seconds, - onComplete = OnComplete.Delete - ) - - "a new interval should be greater than the previous one if the limit not reached" in { - val previous = strategy.on(1) - val current = strategy.on(2) - - (previous, current) match { - case (OnAttempt.Continue(a), OnAttempt.Continue(b)) => assert(a < b) - case x => fail(s"Unexpected result: $x") - } - } - - "should limit intervals" in { - assert(strategy.on(20) == OnAttempt.Continue(strategy.maxInterval)) - } - - "should not fail, if there is many attempts" in { - assert(strategy.on(1000) == OnAttempt.Continue(strategy.maxInterval)) - } - } - } - } - - "complete" - { - "onComplete == mark" - { - "should update the item" in { - var done = false - val item = defaultItem - - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - - override def delete(kind: String, tag: String): Unit = throw new IllegalStateException("Impossible call") - - override def update(entity: EntityT): EntityT = { - assert(entity.kind == item.kind, "repository.delete, kind") - assert(entity.tag == item.tag, "repository.delete, tag") - done = true - entity - } - - override def getById(kind: String, tag: String): Option[EntityT] = Some(item) - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = Strategy.Stop(OnComplete.Mark), - repository = repository, - dbIo = FakeDbIo - ) - - assert(adapter.complete(item.kind, item.tag).isReadyWithin(100.millis)) - assert(done) - } - } - - "onComplete == delete" - { - "should delete the item" in { - var done = false - val item = defaultItem - - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - override def getById(kind: String, tag: String): Option[EntityT] = fail("getById should not be used!") - - override def delete(kind: String, tag: String): Unit = { - assert(kind == item.kind, "repository.delete, kind") - assert(tag == item.tag, "repository.delete, tag") - done = true - } - override def update(entity: EntityT): EntityT = throw new IllegalStateException("Impossible call") - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = Strategy.Stop(OnComplete.Delete), - repository = repository, - dbIo = FakeDbIo - ) - - assert(adapter.complete(item.kind, item.tag).isReadyWithin(100.millis)) - assert(done) - } - } - } - - "tryRetry" - { - - "when all attempts are not out" - { - - val defaultStrategy = Strategy.Constant(10.seconds) - - "should return an updated item" in { - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - override def getById(kind: String, tag: String): Option[EntityT] = fail("getById should not be used!") - - override def update(draft: EntityT): EntityT = draft - override def delete(kind: String, tag: String): Unit = throw new IllegalAccessError(s"kind=$kind, tag=$tag") - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = defaultStrategy, - repository = repository, - dbIo = FakeDbIo - ) - - val item = defaultItem - val r = adapter.tryRetry(item).futureValue - assert(r.isDefined) - assert(!r.contains(item)) - } - - "should update an item with increased attempts" in { - val item = defaultItem - - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - override def getById(kind: String, tag: String): Option[EntityT] = fail("getById should not be used!") - - override def update(draft: EntityT): EntityT = { - assert(draft.attempts === (item.attempts + 1), "repository.add") - draft - } - override def delete(kind: String, tag: String): Unit = throw new IllegalAccessError(s"kind=$kind, tag=$tag") - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = defaultStrategy, - repository = repository, - dbIo = FakeDbIo - ) - - assert(adapter.tryRetry(item).isReadyWithin(100.millis)) - } - - "should remove an old item" in { - val item = defaultItem - - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - override def getById(kind: String, tag: String): Option[EntityT] = fail("getById should not be used!") - override def update(draft: EntityT): EntityT = draft - override def delete(kind: String, tag: String): Unit = { - assert(kind == item.kind, "repository.delete, kind") - assert(tag == item.tag, "repository.delete, kind") - } - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = defaultStrategy, - repository = repository, - dbIo = FakeDbIo - ) - - assert(adapter.tryRetry(item).isReadyWithin(100.millis)) - } - - "should update time of the next attempt" in { - val item = defaultItem - - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - override def getById(kind: String, tag: String): Option[EntityT] = fail("getById should not be used!") - - override def update(draft: EntityT): EntityT = { - assert(draft.nextAttempt.isAfter(item.nextAttempt), "repository.add") - draft - } - override def delete(kind: String, tag: String): Unit = throw new IllegalAccessError(s"kind=$kind, tag=$tag") - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = defaultStrategy, - repository = repository, - dbIo = FakeDbIo - ) - - assert(adapter.tryRetry(item).isReadyWithin(100.millis)) - } - - } - - "when all attempts are out" - { - - val defaultStrategy = Strategy.Stop() - - "should not return an item" in { - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - override def getById(kind: String, tag: String): Option[EntityT] = fail("getById should not be used!") - override def update(entity: EntityT): EntityT = fail("update should not be used!") - - override def delete(kind: String, tag: String): Unit = {} - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = defaultStrategy, - repository = repository, - dbIo = FakeDbIo - ) - - val r = adapter.tryRetry(defaultItem).futureValue - assert(r.isEmpty) - } - - "should complete the item" in { - var taskWasCompleted = false - val item = defaultItem - - val repository = new BridgeUploadQueueRepository { - override def add(draft: EntityT): EntityT = draft - override def getOne(kind: String): Option[EntityT] = fail("getOne should not be used!") - override def buildQuery: MysqlQueryBuilder[EntityT] = fail("buildQuery should not be used!") - override def getById(kind: String, tag: String): Option[EntityT] = fail("getById should not be used!") - override def update(entity: EntityT): EntityT = fail("update should not be used!") - - override def delete(kind: String, tag: String): Unit = {} - } - - val adapter = new BridgeUploadQueueRepositoryAdapter( - strategy = defaultStrategy, - repository = repository, - dbIo = FakeDbIo - ) { - override def complete(kind: String, tag: String): Future[Unit] = Future { - assert(kind == item.kind, "adapter.complete, kind") - assert(tag == item.tag, "adapter.complete, tag") - taskWasCompleted = true - } - } - - val r = adapter.tryRetry(item).futureValue - assert(r.isEmpty) - assert(taskWasCompleted) - } - - } - - } - - private def defaultItem = BridgeUploadQueue.Item( - "test", - ThreadLocalRandom.current().nextInt().toString - ) - -} diff --git a/src/test/scala/xyz/driver/pdsuicommon/db/QueryBuilderParametersSuite.scala b/src/test/scala/xyz/driver/pdsuicommon/db/QueryBuilderParametersSuite.scala deleted file mode 100644 index 2c23b92..0000000 --- a/src/test/scala/xyz/driver/pdsuicommon/db/QueryBuilderParametersSuite.scala +++ /dev/null @@ -1,310 +0,0 @@ -package xyz.driver.pdsuicommon.db - -import java.time.LocalDateTime - -import io.getquill.MysqlEscape -import org.scalatest.FreeSpecLike -import xyz.driver.pdsuicommon.db.QueryBuilder.TableData -import xyz.driver.pdsuicommon.domain._ - -class QueryBuilderParametersSuite extends FreeSpecLike { - - import SearchFilterBinaryOperation._ - import SearchFilterExpr.{Dimension => _, _} - import SearchFilterNAryOperation._ - import Sorting._ - import SortingOrder._ - - val tableName = "Entity" - - case class Entity(id: LongId[Entity], - name: String, - email: Email, - optionUser: Option[StringId[User]], - date: LocalDateTime, - optionDate: Option[LocalDateTime], - kindId: Long) - - def queryBuilderParameters = MysqlQueryBuilderParameters( - tableData = TableData( - tableName = tableName, - nullableFields = Set("optionUser", "optionDate") - ), - links = Map( - "Kind" -> TableLink("kindId", "Kind", "id"), - "User" -> TableLink("optionUser", "User", "id") - ) - ) - - val queryBasis = - s"""select `$tableName`.* - |from `$tableName`""".stripMargin.trim - - "toSql" - { - "should generate correct SQL query" - { - "with default parameters" in { - val (sql, _) = queryBuilderParameters.toSql(namingStrategy = MysqlEscape) - assert(sql == queryBasis) - } - - "with filtering: " - { - "single atom filter" in { - val (sql, _) = - queryBuilderParameters.copy(filter = Atom.Binary("name", Eq, "x")).toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |where `$tableName`.`name` = ?""".stripMargin) - } - - "single atom filter for optional field with NotEq operation" in { - val (sql, _) = queryBuilderParameters - .copy(filter = Atom.Binary("optionUser", NotEq, "x")) - .toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |where (`$tableName`.`optionUser` is null or `$tableName`.`optionUser` != ?)""".stripMargin) - } - - "single atom filter for field with IN operation" in { - val (sql, _) = queryBuilderParameters - .copy(filter = Atom.NAry("date", In, Seq("x", "x", "x"))) - .toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |where `$tableName`.`date` in (?, ?, ?)""".stripMargin) - } - - "multiple intersected filters" in { - val (sql, _) = queryBuilderParameters - .copy( - filter = Intersection( - Seq( - Atom.Binary("name", Gt, "x"), - Atom.Binary("optionDate", GtEq, "x") - ))) - .toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |where (`$tableName`.`name` > ? and `$tableName`.`optionDate` >= ?)""".stripMargin) - } - - "multiple intersected nested filters" in { - val (sql, _) = queryBuilderParameters - .copy( - filter = Intersection( - Seq( - Atom.Binary("name", Gt, "x"), - Atom.Binary("optionDate", GtEq, "x"), - Intersection(Seq( - Atom.Binary("optionUser", Eq, "x"), - Atom.Binary("date", LtEq, "x") - )) - ))) - .toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"$queryBasis\nwhere (`$tableName`.`name` > ? and `$tableName`.`optionDate` >= ?" + - s" and (`$tableName`.`optionUser` = ? and `$tableName`.`date` <= ?))") - } - - "multiple unionized filters" in { - val (sql, _) = queryBuilderParameters - .copy( - filter = Union( - Seq( - Atom.Binary("name", Gt, "x"), - Atom.Binary("optionDate", GtEq, "x") - ))) - .toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |where (`$tableName`.`name` > ? or `$tableName`.`optionDate` >= ?)""".stripMargin.trim) - } - - "multiple unionized nested filters" in { - val (sql, _) = queryBuilderParameters - .copy( - filter = Union( - Seq( - Atom.Binary("name", Gt, "x"), - Atom.Binary("optionDate", GtEq, "x"), - Union(Seq( - Atom.Binary("optionUser", Eq, "x"), - Atom.Binary("date", LtEq, "x") - )) - ))) - .toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |where (`$tableName`.`name` > ? or `$tableName`.`optionDate` >= ? or (`$tableName`.`optionUser` = ? or `$tableName`.`date` <= ?))""".stripMargin) - } - - "multiple unionized and intersected nested filters" in { - val (sql, _) = queryBuilderParameters - .copy(filter = Union(Seq( - Intersection(Seq( - Atom.Binary("name", Gt, "x"), - Atom.Binary("optionDate", GtEq, "x") - )), - Intersection(Seq( - Atom.Binary("optionUser", Eq, "x"), - Atom.Binary("date", LtEq, "x") - )) - ))) - .toSql(namingStrategy = MysqlEscape) - - assert( - sql == - s"$queryBasis\nwhere ((`$tableName`.`name` > ? and `$tableName`.`optionDate` >= ?) " + - s"or (`$tableName`.`optionUser` = ? and `$tableName`.`date` <= ?))") - } - - "single field from foreign table" in { - val (sql, _) = queryBuilderParameters - .copy(filter = Atom.Binary(SearchFilterExpr.Dimension(Some("Kind"), "name"), Eq, "x")) - .toSql(namingStrategy = MysqlEscape) - val pattern = - s"""select `$tableName`.* - |from `$tableName` - |inner join `Kind` on `Entity`.`kindId` = `Kind`.`id` - |where `Kind`.`name` = ?""".stripMargin - assert(sql == pattern) - } - } - - "with sorting:" - { - "single field sorting" in { - val (sql, _) = queryBuilderParameters - .copy(sorting = Dimension(None, "name", Ascending)) - .toSql(namingStrategy = MysqlEscape) - - assert( - sql == - s"""$queryBasis - |order by `$tableName`.`name` asc""".stripMargin) - } - - "single foreign sorting field" in { - val (sql, _) = queryBuilderParameters - .copy(sorting = Dimension(Some("Kind"), "name", Ascending)) - .toSql(namingStrategy = MysqlEscape) - - assert( - sql == - s"""select `$tableName`.* - |from `$tableName` - |inner join `Kind` on `Entity`.`kindId` = `Kind`.`id` - |order by `Kind`.`name` asc""".stripMargin) - } - - "multiple fields sorting" in { - val (sql, _) = queryBuilderParameters - .copy( - sorting = Sequential( - Seq( - Dimension(None, "name", Ascending), - Dimension(None, "date", Descending) - ))) - .toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |order by `$tableName`.`name` asc, `$tableName`.`date` desc""".stripMargin) - } - - "multiple foreign sorting field" in { - val (sql, _) = queryBuilderParameters - .copy( - sorting = Sequential( - Seq( - Dimension(Some("Kind"), "name", Ascending), - Dimension(Some("User"), "name", Descending) - ))) - .toSql(namingStrategy = MysqlEscape) - - assert( - sql == - s"""select `$tableName`.* - |from `$tableName` - |inner join `Kind` on `$tableName`.`kindId` = `Kind`.`id` - |inner join `User` on `$tableName`.`optionUser` = `User`.`id` - |order by `Kind`.`name` asc, `User`.`name` desc""".stripMargin) - } - - "multiple field sorting (including foreign tables)" in { - val (sql, _) = queryBuilderParameters - .copy( - sorting = Sequential( - Seq( - Dimension(Some("Kind"), "name", Ascending), - Dimension(None, "date", Descending) - ))) - .toSql(namingStrategy = MysqlEscape) - - assert( - sql == - s"""select `$tableName`.* - |from `$tableName` - |inner join `Kind` on `$tableName`.`kindId` = `Kind`.`id` - |order by `Kind`.`name` asc, `$tableName`.`date` desc""".stripMargin) - } - } - - "with pagination" in { - val (sql, _) = - queryBuilderParameters.copy(pagination = Some(Pagination(5, 3))).toSql(namingStrategy = MysqlEscape) - assert( - sql == - s"""$queryBasis - |limit 10, 5""".stripMargin) - } - - "combined" in { - val filter = Union( - Seq( - Intersection( - Seq( - Atom.Binary("name", Gt, "x"), - Atom.Binary("optionDate", GtEq, "x") - )), - Intersection( - Seq( - Atom.Binary("optionUser", Eq, "x"), - Atom.Binary("date", LtEq, "x") - )) - )) - val sorting = Sequential( - Seq( - Dimension(Some("Kind"), "name", Ascending), - Dimension(None, "name", Ascending), - Dimension(None, "date", Descending) - )) - - val (sql, _) = queryBuilderParameters - .copy( - filter = filter, - sorting = sorting, - pagination = Some(Pagination(5, 3)) - ) - .toSql(namingStrategy = MysqlEscape) - - assert( - sql == - s"""select `$tableName`.* - |from `$tableName` - |inner join `Kind` on `$tableName`.`kindId` = `Kind`.`id` - |where ((`$tableName`.`name` > ? and `$tableName`.`optionDate` >= ?) or (`$tableName`.`optionUser` = ? and `$tableName`.`date` <= ?)) - |order by `Kind`.`name` asc, `$tableName`.`name` asc, `$tableName`.`date` desc - |limit 10, 5""".stripMargin) - } - - } - } - -} diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ArmFormatSuite.scala index 35b0fad..3cab4a1 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ArmFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ArmFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -6,7 +6,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.Arm class ArmFormatSuite extends FlatSpec with Matchers { - import arm._ + import xyz.driver.pdsuidomain.formats.json.arm._ "Json format for Arm" should "read and write correct JSON" in { val arm = Arm( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/BridgeUploadQueueFormatSuite.scala index 854f51f..9aaecae 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/BridgeUploadQueueFormat.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/BridgeUploadQueueFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -6,8 +6,8 @@ import spray.json._ import org.scalatest.{FlatSpec, Matchers} import xyz.driver.pdsuicommon.concurrent.BridgeUploadQueue -class BridgeUploadQueueFormat extends FlatSpec with Matchers { - import bridgeuploadqueue._ +class BridgeUploadQueueFormatSuite extends FlatSpec with Matchers { + import xyz.driver.pdsuidomain.formats.json.bridgeuploadqueue._ "Json format for BridgeUploadQueue.Item" should "read and write correct JSON" in { val item = BridgeUploadQueue.Item( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/CriterionFormatSuite.scala index 51665d2..a227afa 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/CriterionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/CriterionFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -7,7 +7,7 @@ import xyz.driver.pdsuidomain.entities.{EligibilityArm, Criterion, CriterionLabe import xyz.driver.pdsuidomain.services.CriterionService.RichCriterion class CriterionFormatSuite extends FlatSpec with Matchers { - import criterion._ + import xyz.driver.pdsuidomain.formats.json.criterion._ "Json format for Criterion" should "read and write correct JSON" in { val criterion = Criterion( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentFormatSuite.scala index 111da6e..5e33805 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.{LocalDate, LocalDateTime} @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, TextJson} import xyz.driver.pdsuidomain.entities.Document class DocumentFormatSuite extends FlatSpec with Matchers { - import document._ + import xyz.driver.pdsuidomain.formats.json.document._ "Json format for Document" should "read and write correct JSON" in { val orig = Document( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala index 5975919..e4a0733 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentHistoryFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.DocumentHistory class DocumentHistoryFormatSuite extends FlatSpec with Matchers { - import documenthistory._ + import xyz.driver.pdsuidomain.formats.json.documenthistory._ "Json format for DocumentHistory" should "read and write correct JSON" in { val documentHistory = DocumentHistory( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentIssueFormatSuite.scala index 54cfe90..7f34725 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/DocumentIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/DocumentIssueFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.DocumentIssue class DocumentIssueFormatSuite extends FlatSpec with Matchers { - import documentissue._ + import xyz.driver.pdsuidomain.formats.json.documentissue._ "Json format for DocumentIssue" should "read and write correct JSON" in { val documentIssue = DocumentIssue( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmWithDiseasesFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/EligibilityArmWithDiseasesFormatSuite.scala index 22adc98..054f2f6 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/EligibilityArmWithDiseasesFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/EligibilityArmWithDiseasesFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -7,7 +7,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.{EligibilityArm, EligibilityArmDisease, EligibilityArmWithDiseases} class EligibilityArmWithDiseasesFormatSuite extends FlatSpec with Matchers { - import eligibilityarm._ + import xyz.driver.pdsuidomain.formats.json.eligibilityarm._ "Json format for EligibilityArmWithDiseases" should "read and write correct JSON" in { val name = "arm name" diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala index 767f832..c976243 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExportFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExportFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.{LocalDate, LocalDateTime} import java.util.UUID @@ -10,7 +10,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.{DocumentType, ProviderType, RecordRequestId} class ExportFormatSuite extends FlatSpec with Matchers { - import export._ + import xyz.driver.pdsuidomain.formats.json.export._ "Json format for ExportPatientWithLabels" should "read and write correct JSON" in { import xyz.driver.pdsuidomain.entities.export.patient._ diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExtractedDataFormatSuite.scala index d87b6c7..d1d8d44 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ExtractedDataFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ExtractedDataFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -9,8 +9,7 @@ import xyz.driver.pdsuidomain.entities.{ExtractedData, ExtractedDataLabel} import xyz.driver.pdsuidomain.services.ExtractedDataService.RichExtractedData class ExtractedDataFormatSuite extends FlatSpec with Matchers { - - import extracteddata._ + import xyz.driver.pdsuidomain.formats.json.extracteddata._ "Json format for ExtractedData" should "read and write correct JSON" in { val extractedData = ExtractedData( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/HypothesisFormatSuite.scala index 76d90f5..6d51873 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/HypothesisFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/HypothesisFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -6,7 +6,7 @@ import xyz.driver.pdsuicommon.domain.UuidId import xyz.driver.pdsuidomain.entities.Hypothesis class HypothesisFormatSuite extends FlatSpec with Matchers { - import hypothesis._ + import xyz.driver.pdsuidomain.formats.json.hypothesis._ "Json format for Hypothesis" should "read and write correct JSON" in { val hypothesis = Hypothesis( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/InterventionFormatSuite.scala index edce9c1..015c7b5 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/InterventionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/InterventionFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -6,7 +6,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.{Intervention, InterventionArm, InterventionType, InterventionWithArms} class InterventionFormatSuite extends FlatSpec with Matchers { - import intervention._ + import xyz.driver.pdsuidomain.formats.json.intervention._ "Json format for Intervention" should "read and write correct JSON" in { val intervention = Intervention( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ListResponseFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ListResponseFormatSuite.scala index d6752d6..c561412 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/ListResponseFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/ListResponseFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime import java.util.UUID @@ -9,8 +9,8 @@ import xyz.driver.pdsuicommon.domain.{LongId, UuidId} import xyz.driver.pdsuidomain.ListResponse import xyz.driver.pdsuidomain.entities.MedicalRecord.Status import xyz.driver.pdsuidomain.entities._ -import xyz.driver.pdsuidomain.formats.json.sprayformats.record.recordFormat -import xyz.driver.pdsuidomain.formats.json.sprayformats.listresponse._ +import xyz.driver.pdsuidomain.formats.json.record.recordFormat +import xyz.driver.pdsuidomain.formats.json.listresponse._ class ListResponseFormatSuite extends FlatSpec with Matchers { diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala index 363e352..b4e37a2 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime import java.util.UUID @@ -9,7 +9,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, TextJson, UuidId} import xyz.driver.pdsuidomain.entities.{MedicalRecord, RecordRequestId} class MedicalRecordFormatSuite extends FlatSpec with Matchers { - import record._ + import xyz.driver.pdsuidomain.formats.json.record._ import MedicalRecord._ "Json format for MedicalRecord.Meta" should "read and write correct JSON" in { diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala index a8634d9..ca4058e 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordHistoryFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.MedicalRecordHistory class MedicalRecordHistoryFormatSuite extends FlatSpec with Matchers { - import recordhistory._ + import xyz.driver.pdsuidomain.formats.json.recordhistory._ "Json format for MedicalRecordHistory" should "read and write correct JSON" in { val recordHistory = MedicalRecordHistory( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordIssueFormatSuite.scala index 5fa740b..c7c82a4 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/MedicalRecordIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/MedicalRecordIssueFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.MedicalRecordIssue class MedicalRecordIssueFormatSuite extends FlatSpec with Matchers { - import recordissue._ + import xyz.driver.pdsuidomain.formats.json.recordissue._ "Json format for MedicalRecordIssue" should "read and write correct JSON" in { val recordIssue = MedicalRecordIssue( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala index 27e27c2..93284d9 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientCriterionFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientCriterionFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -10,7 +10,7 @@ import xyz.driver.pdsuidomain.entities.{PatientCriterion, PatientCriterionArm} import xyz.driver.pdsuidomain.services.PatientCriterionService.{DraftPatientCriterion, RichPatientCriterion} class PatientCriterionFormatSuite extends FlatSpec with Matchers { - import patientcriterion._ + import xyz.driver.pdsuidomain.formats.json.patientcriterion._ "Json format for PatientCriterion" should "read and write correct JSON" in { val orig = PatientCriterion( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientEligibleTrialFormatSuite.scala index b8f6f8e..b5fbf3f 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientEligibleTrialFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientEligibleTrialFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -10,7 +10,7 @@ import xyz.driver.pdsuidomain.entities.{PatientCriterionArm, PatientTrialArmGrou import xyz.driver.pdsuidomain.services.PatientEligibleTrialService.RichPatientEligibleTrial class PatientEligibleTrialFormatSuite extends FlatSpec with Matchers { - import patienteligibletrial._ + import xyz.driver.pdsuidomain.formats.json.patienteligibletrial._ "Json format for PatientEligibleTrial" should "read and write correct JSON" in { val trial = Trial( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientFormatSuite.scala index 128cad1..c296f84 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.{LocalDate, LocalDateTime} @@ -10,7 +10,7 @@ import xyz.driver.pdsuicommon.domain.UuidId import xyz.driver.pdsuidomain.entities.{Patient, PatientOrderId} class PatientFormatSuite extends FlatSpec with Matchers { - import patient._ + import xyz.driver.pdsuidomain.formats.json.patient._ "Json format for Patient" should "read and write correct JSON" in { val orig = Patient( @@ -27,7 +27,7 @@ class PatientFormatSuite extends FlatSpec with Matchers { orderId = PatientOrderId("7b54a75d-4197-4b27-9045-b9b6cb131be9"), lastUpdate = LocalDateTime.parse("2017-08-10T18:00:00") ) - val writtenJson = patientWriter.write(orig) + val writtenJson = patientFormat.write(orig) writtenJson should be( """{"id":"748b5884-3528-4cb9-904b-7a8151d6e343","dob":"1980-06-30", diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHistoryFormatSuite.scala index c6a5a9f..e46cf50 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHistoryFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.PatientHistory class PatientHistoryFormatSuite extends FlatSpec with Matchers { - import patienthistory._ + import xyz.driver.pdsuidomain.formats.json.patienthistory._ "Json format for PatientHistory" should "read and write correct JSON" in { val patientHistory = PatientHistory( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala index 71cbbad..270a04d 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientHypothesisFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientHypothesisFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -7,7 +7,7 @@ import xyz.driver.pdsuidomain.entities.PatientHypothesis import xyz.driver.pdsuidomain.services.PatientHypothesisService.RichPatientHypothesis class PatientHypothesisFormatSuite extends FlatSpec with Matchers { - import patienthypothesis._ + import xyz.driver.pdsuidomain.formats.json.patienthypothesis._ "Json format for RichPatientHypothesis" should "read and write correct JSON" in { val orig = PatientHypothesis( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala index 2776dcc..0d56918 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientIssueFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.PatientIssue class PatientIssueFormatSuite extends FlatSpec with Matchers { - import patientissue._ + import xyz.driver.pdsuidomain.formats.json.patientissue._ "Json format for PatientIssue" should "read and write correct JSON" in { val patientIssue = PatientIssue( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala index 2122777..95dfa68 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/PatientLabelFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/PatientLabelFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDate @@ -12,7 +12,7 @@ import xyz.driver.pdsuidomain.services.PatientLabelService.RichPatientLabel class PatientLabelFormatSuite extends FlatSpec with Matchers { "Json format for RichPatientLabel" should "read and write correct JSON" in { - import patientlabel._ + import xyz.driver.pdsuidomain.formats.json.patientlabel._ val orig = PatientLabel( id = LongId(1), patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), @@ -36,7 +36,7 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { } "Json format for PatientLabelEvidence" should "read and write correct JSON" in { - import patientlabel._ + import xyz.driver.pdsuidomain.formats.json.patientlabel._ val orig = PatientLabelEvidenceView( id = LongId(1), value = LabelValue.Maybe, @@ -60,7 +60,7 @@ class PatientLabelFormatSuite extends FlatSpec with Matchers { } "Json format for PatientLabelDefiningCriteria" should "read and write correct JSON" in { - import patientdefiningcriteria._ + import xyz.driver.pdsuidomain.formats.json.patientdefiningcriteria._ val orig = PatientLabel( id = LongId(1), patientId = UuidId("748b5884-3528-4cb9-904b-7a8151d6e343"), diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/SlotArmFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/SlotArmFormatSuite.scala index 7dd085c..95853f6 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/SlotArmFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/SlotArmFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} @@ -6,7 +6,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.SlotArm class SlotArmFormatSuite extends FlatSpec with Matchers { - import slotarm._ + import xyz.driver.pdsuidomain.formats.json.slotarm._ "Json format for SlotArm" should "read and write correct JSON" in { val arm = SlotArm( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/StudyDesignFormatSuite.scala index e847445..f3a4c83 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/StudyDesignFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/StudyDesignFormatSuite.scala @@ -1,11 +1,11 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import spray.json._ import org.scalatest.{FlatSpec, Matchers} import xyz.driver.pdsuidomain.entities.StudyDesign class StudyDesignFormatSuite extends FlatSpec with Matchers { - import studydesign._ + import xyz.driver.pdsuidomain.formats.json.studydesign._ "Json format for StudyDesign" should "read and write correct JSON" in { val studyDesign = StudyDesign.Randomized diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala index c9dc85f..b832733 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} import xyz.driver.pdsuidomain.entities.Trial class TrialFormatSuite extends FlatSpec with Matchers { - import trial._ + import xyz.driver.pdsuidomain.formats.json.trial._ "Json format for Trial" should "read and write correct JSON" in { val orig = Trial( @@ -31,7 +31,7 @@ class TrialFormatSuite extends FlatSpec with Matchers { title = "trial title", originalTitle = "orig trial title" ) - val writtenJson = trialWriter.write(orig) + val writtenJson = trialFormat.write(orig) writtenJson should be( """{"isPartner":false,"assignee":null,"lastUpdate":"2017-08-10T18:16:19Z","previousStatus":null, diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala index d5ad2ec..aa0b404 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialHistoryFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialHistoryFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.TrialHistory class TrialHistoryFormatSuite extends FlatSpec with Matchers { - import trialhistory._ + import xyz.driver.pdsuidomain.formats.json.trialhistory._ "Json format for TrialHistory" should "read and write correct JSON" in { val trialHistory = TrialHistory( diff --git a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialIssueFormatSuite.scala index 4a9ea4f..5c6aa8d 100644 --- a/src/test/scala/xyz/driver/pdsuidomain/formats/json/sprayformats/TrialIssueFormatSuite.scala +++ b/src/test/scala/xyz/driver/pdsuidomain/formats/json/TrialIssueFormatSuite.scala @@ -1,4 +1,4 @@ -package xyz.driver.pdsuidomain.formats.json.sprayformats +package xyz.driver.pdsuidomain.formats.json import java.time.LocalDateTime @@ -8,7 +8,7 @@ import xyz.driver.pdsuicommon.domain.{LongId, StringId} import xyz.driver.pdsuidomain.entities.TrialIssue class TrialIssueFormatSuite extends FlatSpec with Matchers { - import trialissue._ + import xyz.driver.pdsuidomain.formats.json.trialissue._ "Json format for TrialIssue" should "read and write correct JSON" in { val trialIssue = TrialIssue( |