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/MedicalRecordMetaGen.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/MedicalRecordMetaGen.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala new file mode 100644 index 0000000..1536c65 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/rep/MedicalRecordMetaGen.scala @@ -0,0 +1,63 @@ +package xyz.driver.pdsuidomain.fakes.entities.rep + +import xyz.driver.pdsuidomain.entities.MedicalRecord +import xyz.driver.core.generators +import xyz.driver.core.generators._ + +object MedicalRecordMetaGen { + private val maxItemsInCollectionNumber = 50 + private val pageMaxNumber = 1000 + + private val medicalRecordMetas = { + Set( + () => nextMedicalRecordMetaReorder, + () => nextMedicalRecordMetaDuplicate, + () => nextMedicalRecordMetaRotation + ) + } + + + def nextMedicalRecordMetaReorder: MedicalRecord.Meta.Reorder = { + val itemsNumber = + maxItemsInCollectionNumber + val items = scala.util.Random + .shuffle(Seq.tabulate(itemsNumber)(identity)) + + MedicalRecord.Meta.Reorder( + predicted = nextOption(nextBoolean), + items = items + ) + } + + + def nextMedicalRecordMetaDuplicate: MedicalRecord.Meta.Duplicate = { + val startPageGen = + nextInt(pageMaxNumber, minValue = 0) + val endPageGen = + nextInt(pageMaxNumber, startPageGen) + + MedicalRecord.Meta.Duplicate( + predicted = nextOption(nextBoolean), + startPage = startPageGen.toDouble, + endPage = endPageGen.toDouble, + startOriginalPage = startPageGen.toDouble, + endOriginalPage = nextOption(endPageGen.toDouble) + ) + } + + def nextMedicalRecordMetaRotation: MedicalRecord.Meta.Rotation = { + val items = + Array.tabulate(maxItemsInCollectionNumber)( + index => nextString() -> index + ).toMap + + MedicalRecord.Meta.Rotation( + predicted = nextOption(nextBoolean()), + items = items + ) + } + + def nextMedicalRecordMeta: MedicalRecord.Meta = { + generators.oneOf(medicalRecordMetas)() + } +} |