diff options
author | Aleksandr <ognelisar@gmail.com> | 2017-09-28 14:32:21 +0700 |
---|---|---|
committer | Aleksandr <ognelisar@gmail.com> | 2017-09-28 14:32:21 +0700 |
commit | 1f569ac1a31f88334c25976d94e7c495a7bbde80 (patch) | |
tree | 584162d344db1ea767adb72dc6a67164a1e89e68 /src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala | |
parent | d8e71e0a9ee7db58032384d059403bc227a35138 (diff) | |
download | rest-query-1f569ac1a31f88334c25976d94e7c495a7bbde80.tar.gz rest-query-1f569ac1a31f88334c25976d94e7c495a7bbde80.tar.bz2 rest-query-1f569ac1a31f88334c25976d94e7c495a7bbde80.zip |
Implemented all generator for REP's entities
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, 54 insertions, 14 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 index 1c77a78..2f07f1d 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/DocumentGen.scala @@ -5,8 +5,8 @@ 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.pdsuicommon.domain.{LongId, TextJson, User} +import xyz.driver.pdsuidomain.entities._ import xyz.driver.pdsuidomain.fakes.entities.common.{nextLocalDate, nextLocalDateTime, nextLongId, nextStringId} object DocumentGen { @@ -18,23 +18,30 @@ object DocumentGen { } } + private def nextDates = + Common.genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + + private def nextStartAndEndPagesOption = + Common.nextStartAndEndPages + + private def nextStartAndEndPage = + Common.genBoundedRange(nextDouble(),nextDouble()) + + def nextDocumentStatus: Document.Status = generators.oneOf[Document.Status](Document.Status.All) def nextDocumentRequiredType: Document.RequiredType = generators.oneOf[Document.RequiredType](Document.RequiredType.All) + def nextDocumentHistoryState: DocumentHistory.State = + generators.oneOf[DocumentHistory.State](DocumentHistory.State.All) + + def nextDocumentHistoryAction: DocumentHistory.Action = + generators.oneOf[DocumentHistory.Action](DocumentHistory.Action.All) + def nextDocumentMeta: Document.Meta = { - val (startPage, endPage) = { - val startPage = nextDouble() - val endPage = nextDouble() - if (startPage > endPage) { - endPage -> startPage - } - else { - startPage -> endPage - } - } + val (startPage, endPage) = nextStartAndEndPage Document.Meta( nextOption(nextBoolean()), startPage, endPage @@ -42,8 +49,7 @@ object DocumentGen { } def nextDocument: Document = { - val dates = Common - .genBoundedRangeOption[LocalDate](nextLocalDate, nextLocalDate) + val dates = nextDates Document( id = nextLongId[Document], @@ -65,4 +71,38 @@ object DocumentGen { ) } + def nextDocumentType: DocumentType = { + DocumentType( + id = nextLongId[DocumentType], + name = nextString() + ) + } + + def nextDocumentIssue(documentId: LongId[Document]): DocumentIssue = { + val pages = nextStartAndEndPagesOption + + DocumentIssue( + id = nextLongId[DocumentIssue], + userId = nextStringId[User], + documentId = documentId, + startPage = pages._1, + endPage = pages._2, + lastUpdate = nextLocalDateTime, + isDraft = nextBoolean(), + text = nextString(), + archiveRequired = nextBoolean() + ) + } + + + def nextDocumentHistory(documentId: LongId[Document]): DocumentHistory = { + DocumentHistory( + id = nextLongId[DocumentHistory], + executor = nextStringId[User], + documentId = documentId, + state = nextDocumentHistoryState, + action = nextDocumentHistoryAction, + created = nextLocalDateTime + ) + } } |