diff options
author | Aleksandr <ognelisar@gmail.com> | 2017-09-28 13:31:21 +0700 |
---|---|---|
committer | Aleksandr <ognelisar@gmail.com> | 2017-09-28 13:31:21 +0700 |
commit | d8e71e0a9ee7db58032384d059403bc227a35138 (patch) | |
tree | 4803503379c4e71f2e6ed1c8c50a8914186a5798 /src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala | |
parent | c24679f1ae7d7ccc4e6693535b0aa3ac0e1ca225 (diff) | |
download | rest-query-d8e71e0a9ee7db58032384d059403bc227a35138.tar.gz rest-query-d8e71e0a9ee7db58032384d059403bc227a35138.tar.bz2 rest-query-d8e71e0a9ee7db58032384d059403bc227a35138.zip |
Implemented some REP entities objects generators
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala new file mode 100644 index 0000000..1c77a78 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala @@ -0,0 +1,68 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + + +import java.time.LocalDate + +import xyz.driver.core.generators +import xyz.driver.core.generators.{nextBoolean, nextDouble, nextOption, nextString} +import xyz.driver.pdsuicommon.domain.{TextJson, User} +import xyz.driver.pdsuidomain.entities.{Document, DocumentType, MedicalRecord, ProviderType} +import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLocalDateTime, nextLongId, nextStringId} + +object DocumentGen { + implicit private class LocalDateOrdering(localData: LocalDate) + extends Ordered[LocalDate] { + + override def compare(that: LocalDate): Int = { + this.localData.compareTo(that) + } + } + + def nextDocumentStatus: Document.Status = + generators.oneOf[Document.Status](Document.Status.All) + + def nextDocumentRequiredType: Document.RequiredType = + generators.oneOf[Document.RequiredType](Document.RequiredType.All) + + def nextDocumentMeta: Document.Meta = { + val (startPage, endPage) = { + val startPage = nextDouble() + val endPage = nextDouble() + if (startPage > endPage) { + endPage -> startPage + } + else { + startPage -> endPage + } + } + + Document.Meta( + nextOption(nextBoolean()), startPage, endPage + ) + } + + def nextDocument: Document = { + val dates = Common + .genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + + Document( + id = nextLongId[Document], + status = nextDocumentStatus, + previousStatus = nextOption(nextDocumentStatus), + assignee = nextOption(nextStringId[User]), + previousAssignee = nextOption(nextStringId[User]), + lastActiveUserId = nextOption(nextStringId[User]), + recordId = nextLongId[MedicalRecord], + physician = nextOption(nextString()), + typeId = nextOption(nextLongId[DocumentType]), + providerName = nextOption(nextString()), + providerTypeId = nextOption(nextLongId[ProviderType]), + requiredType = nextOption(nextDocumentRequiredType), + meta = nextOption(TextJson(nextDocumentMeta)), + startDate = dates._1, + endDate = dates._2, + lastUpdate = nextLocalDateTime + ) + } + +} |