diff --git a/core/src/test/scala/dev/profunktor/fs2rabbit/testing/RabbitStdDataArbs.scala b/core/src/test/scala/dev/profunktor/fs2rabbit/testing/RabbitStdDataArbs.scala index 002e078b..98938c47 100644 --- a/core/src/test/scala/dev/profunktor/fs2rabbit/testing/RabbitStdDataArbs.scala +++ b/core/src/test/scala/dev/profunktor/fs2rabbit/testing/RabbitStdDataArbs.scala @@ -16,7 +16,7 @@ package dev.profunktor.fs2rabbit.testing -import dev.profunktor.fs2rabbit.model.AmqpFieldValue.DecimalVal +import dev.profunktor.fs2rabbit.model.AmqpFieldValue.{DecimalVal, TimestampVal} import org.scalacheck._ import java.time.Instant @@ -24,20 +24,15 @@ import java.util.Date object RabbitStdDataArbs { - implicit val bigDecimalArb: Arbitrary[BigDecimal] = - Arbitrary(Arbitrary.arbBigDecimal.arbitrary.filter(DecimalVal.from(_).isDefined)) + implicit def bigDecimalArb(implicit a: Arbitrary[DecimalVal]): Arbitrary[BigDecimal] = + Arbitrary(a.arbitrary.map(_.sizeLimitedBigDecimal)) - implicit val bigIntArb: Arbitrary[BigInt] = + implicit def bigIntArb(implicit a: Arbitrary[DecimalVal]): Arbitrary[BigInt] = Arbitrary(bigDecimalArb.arbitrary.map(_.toBigInt)) - implicit val arbInstant: Arbitrary[Instant] = - Arbitrary(Arbitrary.arbInstant.arbitrary.map(_.truncatedTo(java.time.temporal.ChronoUnit.SECONDS))) - - implicit val arbDate: Arbitrary[Date] = - Arbitrary( - Arbitrary.arbDate.arbitrary - .map(_.toInstant.truncatedTo(java.time.temporal.ChronoUnit.SECONDS)) - .map(Date.from) - ) + implicit def arbInstant(implicit a: Arbitrary[TimestampVal]): Arbitrary[Instant] = + Arbitrary(a.arbitrary.map(_.instantWithOneSecondAccuracy)) + implicit def arbDate(implicit a: Arbitrary[TimestampVal]): Arbitrary[Date] = + Arbitrary(a.arbitrary.map(_.toValueWriterCompatibleJava)) }