diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala new file mode 100644 index 0000000..b259b07 --- /dev/null +++ b/src/main/scala/xyz/driver/pdsuidomain/fakes/entities/common.scala @@ -0,0 +1,36 @@ +package xyz.driver.pdsuidomain.fakes.entities + +import java.time.{LocalDate, LocalDateTime, LocalTime} + +import xyz.driver.pdsuicommon.domain.{LongId, StringId, UuidId} +import xyz.driver.pdsuidomain.entities.{Trial, TrialHistory} +import scala.util.Random + +object common { + import xyz.driver.core.generators + + def nextUuidId[T] = UuidId[T](generators.nextUuid()) + + def nextLongId[T] = LongId[T](generators.nextInt(Int.MaxValue).toLong) + + def nextStringId[T] = StringId[T](generators.nextString(maxLength = 20)) + + def nextTrialStatus = generators.oneOf[Trial.Status](Trial.Status.All) + + def nextPreviousTrialStatus = generators.oneOf[Trial.Status](Trial.Status.AllPrevious) + + def nextLocalDateTime = LocalDateTime.of(nextLocalDate, LocalTime.MIDNIGHT) + + def nextLocalDate = LocalDate.of( + 1970 + Random.nextInt(68), + 1 + Random.nextInt(12), + 1 + Random.nextInt(28) // all months have at least 28 days + ) + + def nextCondition = generators.oneOf[Trial.Condition](Trial.Condition.All) + + def nextTrialAction = generators.oneOf[TrialHistory.Action](TrialHistory.Action.All) + + def nextTrialState = generators.oneOf[TrialHistory.State](TrialHistory.State.All) + +} |