diff options
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 + ) + } } |