I need generate list of objects. Each objects must contain predestined value and generated value. I created the generator but not sure that this is the true way. Is there any ways to make it more readable?
object Test {
case class A(myInt: Int, randomInt: Int)
val list = List(1, 2, 3, 4, 5)
val subListGen = Gen.someOf(list)
val randomIntGen = Gen.choose(0,10)
import scala.collection.JavaConverters._
val seqAGen: Gen[Seq[A]] = for {
subsetMyInts <- subListGen
seqOfRandomIntsWithSizeEqualGenSubList <- Gen.sequence(subsetMyInts.map(x => randomIntGen))
} yield {
subsetMyInts.zip(seqOfRandomIntsWithSizeEqualGenSubList.asScala.toList).map(x => A(x._1, x._2))
}
}