Hi, how would one write generator for class like t...
# kotest
s
Hi, how would one write generator for class like this
Copy code
data class CreateTokensRequest(
    val resourceId: UUID,
    val requestId: String,
    val schedule : Map<LocalDate, Long>,
)
I can’t quite figure out how to do map of
LocalDate
to
Long
I was trying something like this.
Copy code
val createRequestArb: Arb<CreateTokensRequest> = Arb.bind(
    Arb.string(),
    mapOf(Arb.localDate(), Arb.long(0, 1000))
) { requestId, schedule -> CreateTokensRequest(UUID.randomUUID(), requestId, schedule) }
I was able to get this working by making
Map<LocalDate, Long>
a
List<Transaction>
and create
Arb<Transaction>
s
There is
Arb.map
that takes 2
Arb
. In your original snippet you use
mapOf
but I think you want
Arb.map(Arb.localDate(), Arb.long(0, 1000))
.
s
Oh, I missed that one! Thanks.