From d6373490e4c12e8bc4566bfdaa3c65eba47dbfae Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Mon, 6 Feb 2023 16:09:38 -0600 Subject: [PATCH] Revert "EnhancedMonitoring and FailedRecordCount outputs should be nullable (#418)" This reverts commit ba6ee358f75099ae2f159a9f403808cdc55bdb48. --- .../mock/DescribeStreamSummaryTests.scala | 8 ++ .../kinesis/mock/DescribeStreamTests.scala | 8 ++ .../mock/api/DeleteStreamRequest.scala | 2 +- .../DisableEnhancedMonitoringRequest.scala | 10 +-- .../DisableEnhancedMonitoringResponse.scala | 8 +- .../api/EnableEnhancedMonitoringRequest.scala | 17 ++--- .../EnableEnhancedMonitoringResponse.scala | 8 +- .../kinesis/mock/api/PutRecordsRequest.scala | 2 +- .../kinesis/mock/api/PutRecordsResponse.scala | 4 +- .../kinesis/mock/models/StreamData.scala | 6 +- .../mock/models/StreamDescription.scala | 4 +- .../models/StreamDescriptionSummary.scala | 4 +- .../scala/kinesis/mock/models/Streams.scala | 2 +- .../api/DisableEnhancedMonitoringTests.scala | 24 +++--- .../api/EnableEnhancedMonitoringTests.scala | 2 +- .../cache/DescribeStreamSummaryTests.scala | 2 +- .../mock/cache/DescribeStreamTests.scala | 2 +- .../DisableEnhancedMonitoringTests.scala | 4 +- .../cache/EnableEnhancedMonitoringTests.scala | 4 +- .../kinesis/mock/instances/arbitrary.scala | 74 ++++++++----------- 20 files changed, 96 insertions(+), 99 deletions(-) diff --git a/src/fun/scala/kinesis/mock/DescribeStreamSummaryTests.scala b/src/fun/scala/kinesis/mock/DescribeStreamSummaryTests.scala index 9a612bf5..34acc769 100644 --- a/src/fun/scala/kinesis/mock/DescribeStreamSummaryTests.scala +++ b/src/fun/scala/kinesis/mock/DescribeStreamSummaryTests.scala @@ -1,5 +1,7 @@ package kinesis.mock +import java.util.Collections + import cats.syntax.all._ import software.amazon.awssdk.services.kinesis.model._ @@ -12,6 +14,12 @@ class DescribeStreamSummaryTests extends AwsFunctionalTests { .builder() .consumerCount(0) .encryptionType(EncryptionType.NONE) + .enhancedMonitoring( + EnhancedMetrics + .builder() + .shardLevelMetricsWithStrings(Collections.emptyList[String]()) + .build() + ) .openShardCount(genStreamShardCount) .retentionPeriodHours(24) .streamARN( diff --git a/src/fun/scala/kinesis/mock/DescribeStreamTests.scala b/src/fun/scala/kinesis/mock/DescribeStreamTests.scala index 19d3a8e4..60ee9bdf 100644 --- a/src/fun/scala/kinesis/mock/DescribeStreamTests.scala +++ b/src/fun/scala/kinesis/mock/DescribeStreamTests.scala @@ -1,5 +1,7 @@ package kinesis.mock +import java.util.Collections + import software.amazon.awssdk.services.kinesis.model._ import kinesis.mock.syntax.javaFuture._ @@ -19,6 +21,12 @@ class DescribeStreamTests extends AwsFunctionalTests { expected = StreamDescription .builder() .encryptionType(EncryptionType.NONE) + .enhancedMonitoring( + EnhancedMetrics + .builder() + .shardLevelMetricsWithStrings(Collections.emptyList[String]()) + .build() + ) .hasMoreShards(false) .shards(res.streamDescription().shards()) .retentionPeriodHours(24) diff --git a/src/main/scala/kinesis/mock/api/DeleteStreamRequest.scala b/src/main/scala/kinesis/mock/api/DeleteStreamRequest.scala index db39a8eb..252c0fb6 100644 --- a/src/main/scala/kinesis/mock/api/DeleteStreamRequest.scala +++ b/src/main/scala/kinesis/mock/api/DeleteStreamRequest.scala @@ -51,7 +51,7 @@ final case class DeleteStreamRequest( shards = SortedMap.empty, streamStatus = StreamStatus.DELETING, tags = Tags.empty, - enhancedMonitoring = None, + enhancedMonitoring = Vector.empty, consumers = SortedMap.empty ) ) diff --git a/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringRequest.scala b/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringRequest.scala index aad8ffac..87eb42b2 100644 --- a/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringRequest.scala +++ b/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringRequest.scala @@ -29,17 +29,17 @@ final case class DisableEnhancedMonitoringRequest( .flatMap(_ => CommonValidations.findStream(arn, streams)) .map { stream => val current = - stream.enhancedMonitoring.map(_.flatMap(_.shardLevelMetrics)) - val desired: Option[Vector[ShardLevelMetric]] = + stream.enhancedMonitoring.flatMap(_.shardLevelMetrics) + val desired = if (shardLevelMetrics.contains(ShardLevelMetric.ALL)) - None - else current.map(_.diff(shardLevelMetrics)) + Vector.empty + else current.diff(shardLevelMetrics) ( streams.updateStream( stream .copy(enhancedMonitoring = - desired.map(x => Vector(ShardLevelMetrics(x))) + Vector(ShardLevelMetrics(desired)) ) ), DisableEnhancedMonitoringResponse( diff --git a/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringResponse.scala b/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringResponse.scala index b5239035..0bd7e4db 100644 --- a/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringResponse.scala +++ b/src/main/scala/kinesis/mock/api/DisableEnhancedMonitoringResponse.scala @@ -7,8 +7,8 @@ import io.circe import kinesis.mock.models._ final case class DisableEnhancedMonitoringResponse( - currentShardLevelMetrics: Option[Vector[ShardLevelMetric]], - desiredShardLevelMetrics: Option[Vector[ShardLevelMetric]], + currentShardLevelMetrics: Vector[ShardLevelMetric], + desiredShardLevelMetrics: Vector[ShardLevelMetric], streamName: StreamName, streamArn: StreamArn ) @@ -35,10 +35,10 @@ object DisableEnhancedMonitoringResponse { for { currentShardLevelMetrics <- x .downField("CurrentShardLevelMetrics") - .as[Option[Vector[ShardLevelMetric]]] + .as[Vector[ShardLevelMetric]] desiredShardLevelMetrics <- x .downField("DesiredShardLevelMetrics") - .as[Option[Vector[ShardLevelMetric]]] + .as[Vector[ShardLevelMetric]] streamName <- x.downField("StreamName").as[StreamName] streamArn <- x.downField("StreamARN").as[StreamArn] } yield DisableEnhancedMonitoringResponse( diff --git a/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringRequest.scala b/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringRequest.scala index 1dea76c5..b1e39b64 100644 --- a/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringRequest.scala +++ b/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringRequest.scala @@ -29,23 +29,18 @@ final case class EnableEnhancedMonitoringRequest( .flatMap(_ => CommonValidations.findStream(arn, streams)) .map { stream => val current = - stream.enhancedMonitoring.map(_.flatMap(_.shardLevelMetrics)) + stream.enhancedMonitoring.flatMap(_.shardLevelMetrics) val desired = if (shardLevelMetrics.contains(ShardLevelMetric.ALL)) - Some( - ShardLevelMetric.values - .filterNot(_ == ShardLevelMetric.ALL) - .toVector - ) - else - (current - .map(x => (x ++ shardLevelMetrics).distinct) - .orElse(Some(shardLevelMetrics))) + ShardLevelMetric.values + .filterNot(_ == ShardLevelMetric.ALL) + .toVector + else (current ++ shardLevelMetrics).distinct ( streams.updateStream( stream .copy(enhancedMonitoring = - desired.map(x => Vector(ShardLevelMetrics(x))) + Vector(ShardLevelMetrics(desired)) ) ), EnableEnhancedMonitoringResponse( diff --git a/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringResponse.scala b/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringResponse.scala index 9ed6139f..036e4ef1 100644 --- a/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringResponse.scala +++ b/src/main/scala/kinesis/mock/api/EnableEnhancedMonitoringResponse.scala @@ -7,8 +7,8 @@ import io.circe import kinesis.mock.models._ final case class EnableEnhancedMonitoringResponse( - currentShardLevelMetrics: Option[Vector[ShardLevelMetric]], - desiredShardLevelMetrics: Option[Vector[ShardLevelMetric]], + currentShardLevelMetrics: Vector[ShardLevelMetric], + desiredShardLevelMetrics: Vector[ShardLevelMetric], streamName: StreamName, streamArn: StreamArn ) @@ -35,10 +35,10 @@ object EnableEnhancedMonitoringResponse { for { currentShardLevelMetrics <- x .downField("CurrentShardLevelMetrics") - .as[Option[Vector[ShardLevelMetric]]] + .as[Vector[ShardLevelMetric]] desiredShardLevelMetrics <- x .downField("DesiredShardLevelMetrics") - .as[Option[Vector[ShardLevelMetric]]] + .as[Vector[ShardLevelMetric]] streamName <- x.downField("StreamName").as[StreamName] streamArn <- x.downField("StreamARN").as[StreamArn] } yield EnableEnhancedMonitoringResponse( diff --git a/src/main/scala/kinesis/mock/api/PutRecordsRequest.scala b/src/main/scala/kinesis/mock/api/PutRecordsRequest.scala index 4ea505bf..9afb388a 100644 --- a/src/main/scala/kinesis/mock/api/PutRecordsRequest.scala +++ b/src/main/scala/kinesis/mock/api/PutRecordsRequest.scala @@ -117,7 +117,7 @@ final case class PutRecordsRequest( ), PutRecordsResponse( stream.encryptionType, - None, + 0, asRecords.map { case (_, _, _, entry) => entry } diff --git a/src/main/scala/kinesis/mock/api/PutRecordsResponse.scala b/src/main/scala/kinesis/mock/api/PutRecordsResponse.scala index 7e4792b2..207915b9 100644 --- a/src/main/scala/kinesis/mock/api/PutRecordsResponse.scala +++ b/src/main/scala/kinesis/mock/api/PutRecordsResponse.scala @@ -8,7 +8,7 @@ import kinesis.mock.models.EncryptionType final case class PutRecordsResponse( encryptionType: EncryptionType, - failedRecordCount: Option[Int], + failedRecordCount: Int, records: Vector[PutRecordsResultEntry] ) @@ -26,7 +26,7 @@ object PutRecordsResponse { x => for { encryptionType <- x.downField("EncryptionType").as[EncryptionType] - failedRecordCount <- x.downField("FailedRecordCount").as[Option[Int]] + failedRecordCount <- x.downField("FailedRecordCount").as[Int] records <- x.downField("Records").as[Vector[PutRecordsResultEntry]] } yield PutRecordsResponse(encryptionType, failedRecordCount, records) diff --git a/src/main/scala/kinesis/mock/models/StreamData.scala b/src/main/scala/kinesis/mock/models/StreamData.scala index 95bd965e..75e5032a 100644 --- a/src/main/scala/kinesis/mock/models/StreamData.scala +++ b/src/main/scala/kinesis/mock/models/StreamData.scala @@ -15,7 +15,7 @@ import kinesis.mock.instances.circe._ final case class StreamData( consumers: SortedMap[ConsumerName, Consumer], encryptionType: EncryptionType, - enhancedMonitoring: Option[Vector[ShardLevelMetrics]], + enhancedMonitoring: Vector[ShardLevelMetrics], keyId: Option[String], retentionPeriod: FiniteDuration, shards: SortedMap[Shard, Vector[KinesisRecord]], @@ -81,7 +81,7 @@ object StreamData { encryptionType <- x.downField("encryptionType").as[EncryptionType] enhancedMonitoring <- x .downField("enhancedMonitoring") - .as[Option[Vector[ShardLevelMetrics]]] + .as[Vector[ShardLevelMetrics]] keyId <- x.downField("keyId").as[Option[String]] retentionPeriod <- x.downField("retentionPeriod").as[FiniteDuration] shards <- x @@ -144,7 +144,7 @@ object StreamData { StreamData( SortedMap.empty, EncryptionType.NONE, - None, + Vector(ShardLevelMetrics(Vector.empty)), None, minRetentionPeriod, shards, diff --git a/src/main/scala/kinesis/mock/models/StreamDescription.scala b/src/main/scala/kinesis/mock/models/StreamDescription.scala index e996c86a..211083cf 100644 --- a/src/main/scala/kinesis/mock/models/StreamDescription.scala +++ b/src/main/scala/kinesis/mock/models/StreamDescription.scala @@ -11,7 +11,7 @@ import kinesis.mock.instances.circe._ final case class StreamDescription( encryptionType: Option[EncryptionType], - enhancedMonitoring: Option[Vector[ShardLevelMetrics]], + enhancedMonitoring: Vector[ShardLevelMetrics], hasMoreShards: Boolean, keyId: Option[String], retentionPeriodHours: Int, @@ -100,7 +100,7 @@ object StreamDescription { .as[Option[EncryptionType]] enhancedMonitoring <- x .downField("EnhancedMonitoring") - .as[Option[Vector[ShardLevelMetrics]]] + .as[Vector[ShardLevelMetrics]] hasMoreShards <- x.downField("HasMoreShards").as[Boolean] keyId <- x.downField("KeyId").as[Option[String]] retentionPeriodHours <- x.downField("RetentionPeriodHours").as[Int] diff --git a/src/main/scala/kinesis/mock/models/StreamDescriptionSummary.scala b/src/main/scala/kinesis/mock/models/StreamDescriptionSummary.scala index 73677d34..49e3ebfe 100644 --- a/src/main/scala/kinesis/mock/models/StreamDescriptionSummary.scala +++ b/src/main/scala/kinesis/mock/models/StreamDescriptionSummary.scala @@ -11,7 +11,7 @@ import kinesis.mock.instances.circe._ final case class StreamDescriptionSummary( consumerCount: Option[Int], encryptionType: Option[EncryptionType], - enhancedMonitoring: Option[Vector[ShardLevelMetrics]], + enhancedMonitoring: Vector[ShardLevelMetrics], keyId: Option[String], openShardCount: Int, retentionPeriodHours: Int, @@ -76,7 +76,7 @@ object StreamDescriptionSummary { encryptionType <- x.downField("EncryptionType").as[Option[EncryptionType]] enhancedMonitoring <- x .downField("EnhancedMonitoring") - .as[Option[Vector[ShardLevelMetrics]]] + .as[Vector[ShardLevelMetrics]] keyId <- x.downField("KeyId").as[Option[String]] openShardCount <- x.downField("OpenShardCount").as[Int] retentionPeriodHours <- x.downField("RetentionPeriodHours").as[Int] diff --git a/src/main/scala/kinesis/mock/models/Streams.scala b/src/main/scala/kinesis/mock/models/Streams.scala index cd79877d..59a8ae9e 100644 --- a/src/main/scala/kinesis/mock/models/Streams.scala +++ b/src/main/scala/kinesis/mock/models/Streams.scala @@ -42,7 +42,7 @@ final case class Streams(streams: SortedMap[StreamArn, StreamData]) { shards = SortedMap.empty, streamStatus = StreamStatus.DELETING, tags = Tags.empty, - enhancedMonitoring = None, + enhancedMonitoring = Vector.empty, consumers = SortedMap.empty ) ) diff --git a/src/test/scala/kinesis/mock/api/DisableEnhancedMonitoringTests.scala b/src/test/scala/kinesis/mock/api/DisableEnhancedMonitoringTests.scala index 9ab894e9..6982f632 100644 --- a/src/test/scala/kinesis/mock/api/DisableEnhancedMonitoringTests.scala +++ b/src/test/scala/kinesis/mock/api/DisableEnhancedMonitoringTests.scala @@ -21,18 +21,16 @@ class DisableEnhancedMonitoringTests val updated = streams.findAndUpdateStream(streamArn)(stream => stream.copy(enhancedMonitoring = - Some( - Vector( - ShardLevelMetrics( - Vector( - ShardLevelMetric.IncomingBytes, - ShardLevelMetric.IncomingRecords, - ShardLevelMetric.OutgoingBytes, - ShardLevelMetric.OutgoingRecords, - ShardLevelMetric.WriteProvisionedThroughputExceeded, - ShardLevelMetric.ReadProvisionedThroughputExceeded, - ShardLevelMetric.IteratorAgeMilliseconds - ) + Vector( + ShardLevelMetrics( + Vector( + ShardLevelMetric.IncomingBytes, + ShardLevelMetric.IncomingRecords, + ShardLevelMetric.OutgoingBytes, + ShardLevelMetric.OutgoingRecords, + ShardLevelMetric.WriteProvisionedThroughputExceeded, + ShardLevelMetric.ReadProvisionedThroughputExceeded, + ShardLevelMetric.IteratorAgeMilliseconds ) ) ) @@ -54,7 +52,7 @@ class DisableEnhancedMonitoringTests s <- streamsRef.get updatedMetrics = s.streams .get(streamArn) - .map(_.enhancedMonitoring.map(_.flatMap(_.shardLevelMetrics))) + .map(_.enhancedMonitoring.flatMap(_.shardLevelMetrics)) } yield assert( res.isRight && res.exists { case response => diff --git a/src/test/scala/kinesis/mock/api/EnableEnhancedMonitoringTests.scala b/src/test/scala/kinesis/mock/api/EnableEnhancedMonitoringTests.scala index 6188e076..35e30c76 100644 --- a/src/test/scala/kinesis/mock/api/EnableEnhancedMonitoringTests.scala +++ b/src/test/scala/kinesis/mock/api/EnableEnhancedMonitoringTests.scala @@ -34,7 +34,7 @@ class EnableEnhancedMonitoringTests s <- streamsRef.get updatedMetrics = s.streams .get(streamArn) - .map(_.enhancedMonitoring.map(_.flatMap(_.shardLevelMetrics))) + .map(_.enhancedMonitoring.flatMap(_.shardLevelMetrics)) } yield assert( res.isRight && res.exists { case response => diff --git a/src/test/scala/kinesis/mock/cache/DescribeStreamSummaryTests.scala b/src/test/scala/kinesis/mock/cache/DescribeStreamSummaryTests.scala index 9c18d49b..ac19f09a 100644 --- a/src/test/scala/kinesis/mock/cache/DescribeStreamSummaryTests.scala +++ b/src/test/scala/kinesis/mock/cache/DescribeStreamSummaryTests.scala @@ -44,7 +44,7 @@ class DescribeStreamSummaryTests expected = StreamDescriptionSummary( Some(0), Some(EncryptionType.NONE), - None, + Vector(ShardLevelMetrics(Vector.empty)), None, 1, 24, diff --git a/src/test/scala/kinesis/mock/cache/DescribeStreamTests.scala b/src/test/scala/kinesis/mock/cache/DescribeStreamTests.scala index 1a4e6cc4..30ffa716 100644 --- a/src/test/scala/kinesis/mock/cache/DescribeStreamTests.scala +++ b/src/test/scala/kinesis/mock/cache/DescribeStreamTests.scala @@ -60,7 +60,7 @@ class DescribeStreamTests .map(x => x.shards) expected = StreamDescription( Some(EncryptionType.NONE), - None, + Vector(ShardLevelMetrics(Vector.empty)), false, None, 24, diff --git a/src/test/scala/kinesis/mock/cache/DisableEnhancedMonitoringTests.scala b/src/test/scala/kinesis/mock/cache/DisableEnhancedMonitoringTests.scala index 2bd3f7ba..0cdc97a5 100644 --- a/src/test/scala/kinesis/mock/cache/DisableEnhancedMonitoringTests.scala +++ b/src/test/scala/kinesis/mock/cache/DisableEnhancedMonitoringTests.scala @@ -67,11 +67,11 @@ class DisableEnhancedMonitoringTests .rethrow .map( _.streamDescriptionSummary.enhancedMonitoring - .map(_.flatMap(_.shardLevelMetrics)) + .flatMap(_.shardLevelMetrics) ) } yield assert( res.desiredShardLevelMetrics == streamMonitoring && !res.desiredShardLevelMetrics - .exists(_.contains(ShardLevelMetric.IncomingBytes)) + .contains(ShardLevelMetric.IncomingBytes) ) }) } diff --git a/src/test/scala/kinesis/mock/cache/EnableEnhancedMonitoringTests.scala b/src/test/scala/kinesis/mock/cache/EnableEnhancedMonitoringTests.scala index 19fb9b50..9fee1c8e 100644 --- a/src/test/scala/kinesis/mock/cache/EnableEnhancedMonitoringTests.scala +++ b/src/test/scala/kinesis/mock/cache/EnableEnhancedMonitoringTests.scala @@ -55,11 +55,11 @@ class EnableEnhancedMonitoringTests .rethrow .map( _.streamDescriptionSummary.enhancedMonitoring - .map(_.flatMap(_.shardLevelMetrics)) + .flatMap(_.shardLevelMetrics) ) } yield assert( res.desiredShardLevelMetrics == streamMonitoring && res.desiredShardLevelMetrics - .exists(_.contains(ShardLevelMetric.IncomingBytes)) + .contains(ShardLevelMetric.IncomingBytes) ) }) } diff --git a/src/test/scala/kinesis/mock/instances/arbitrary.scala b/src/test/scala/kinesis/mock/instances/arbitrary.scala index 7c095b27..593d198a 100644 --- a/src/test/scala/kinesis/mock/instances/arbitrary.scala +++ b/src/test/scala/kinesis/mock/instances/arbitrary.scala @@ -367,16 +367,14 @@ object arbitrary { implicit val streamDescriptionArb: Arbitrary[StreamDescription] = Arbitrary( for { encryptionType <- Gen.option(Arbitrary.arbitrary[EncryptionType]) - enhancedMonitoring <- Gen.option( - Gen - .choose(1, 2) - .flatMap(size => - Gen.containerOfN[Vector, ShardLevelMetrics]( - size, - shardLevelMetricsArbitrary.arbitrary - ) + enhancedMonitoring <- Gen + .choose(0, 1) + .flatMap(size => + Gen.containerOfN[Vector, ShardLevelMetrics]( + size, + shardLevelMetricsArbitrary.arbitrary ) - ) + ) hasMoreShards <- Arbitrary.arbitrary[Boolean] keyId <- Gen.option(keyIdGen) retentionPeriodHours <- retentionPeriodHoursGen @@ -446,16 +444,14 @@ object arbitrary { for { consumerCount <- Gen.option(Gen.choose(1, 20)) encryptionType <- Gen.option(Arbitrary.arbitrary[EncryptionType]) - enhancedMonitoring <- Gen.option( - Gen - .choose(1, 2) - .flatMap(size => - Gen.containerOfN[Vector, ShardLevelMetrics]( - size, - shardLevelMetricsArbitrary.arbitrary - ) + enhancedMonitoring <- Gen + .choose(0, 1) + .flatMap(size => + Gen.containerOfN[Vector, ShardLevelMetrics]( + size, + shardLevelMetricsArbitrary.arbitrary ) - ) + ) keyId <- Gen.option(keyIdGen) openShardCount <- Gen.choose(1, 50) retentionPeriodHours <- retentionPeriodHoursGen @@ -505,15 +501,11 @@ object arbitrary { implicit val disableEnhancedMonitoringResponseArb : Arbitrary[DisableEnhancedMonitoringResponse] = Arbitrary( for { - currentShardLevelMetrics <- Gen.option( - shardLevelMetricsArbitrary.arbitrary.map( - _.shardLevelMetrics - ) + currentShardLevelMetrics <- shardLevelMetricsArbitrary.arbitrary.map( + _.shardLevelMetrics ) - desiredShardLevelMetrics <- Gen.option( - shardLevelMetricsArbitrary.arbitrary.map( - _.shardLevelMetrics - ) + desiredShardLevelMetrics <- shardLevelMetricsArbitrary.arbitrary.map( + _.shardLevelMetrics ) streamArn <- streamArnGen } yield DisableEnhancedMonitoringResponse( @@ -541,13 +533,11 @@ object arbitrary { implicit val enableEnhancedMonitoringResponseArb : Arbitrary[EnableEnhancedMonitoringResponse] = Arbitrary( for { - currentShardLevelMetrics <- Gen.option( - shardLevelMetricsArbitrary.arbitrary.map( - _.shardLevelMetrics - ) + currentShardLevelMetrics <- shardLevelMetricsArbitrary.arbitrary.map( + _.shardLevelMetrics ) - desiredShardLevelMetrics <- Gen.option( - shardLevelMetricsArbitrary.arbitrary.map(_.shardLevelMetrics) + desiredShardLevelMetrics <- shardLevelMetricsArbitrary.arbitrary.map( + _.shardLevelMetrics ) streamArn <- streamArnGen } yield EnableEnhancedMonitoringResponse( @@ -889,8 +879,8 @@ object arbitrary { implicit val putRecordsResponseArb: Arbitrary[PutRecordsResponse] = Arbitrary( for { encryptionType <- Arbitrary.arbitrary[EncryptionType] - failedRecordCount <- Gen.option(Gen.choose(1, 500)) - recordsSize <- Gen.choose(failedRecordCount.getOrElse(1), 500) + failedRecordCount <- Gen.choose(0, 500) + recordsSize <- Gen.choose(failedRecordCount, 500) records <- Gen.containerOfN[Vector, PutRecordsResultEntry]( recordsSize, putRecordsResultEntry.arbitrary @@ -996,16 +986,14 @@ object arbitrary { ) .map(x => SortedMap.from(x)) encryptionType <- Arbitrary.arbitrary[EncryptionType] - enhancedMonitoring <- Gen.option( - Gen - .choose(1, 2) - .flatMap(size => - Gen.containerOfN[Vector, ShardLevelMetrics]( - size, - shardLevelMetricsArbitrary.arbitrary - ) + enhancedMonitoring <- Gen + .choose(0, 1) + .flatMap(size => + Gen.containerOfN[Vector, ShardLevelMetrics]( + size, + shardLevelMetricsArbitrary.arbitrary ) - ) + ) keyId <- Gen.option(keyIdGen) retentionPeriod <- retentionPeriodHoursGen.map(_.hours) shardsSize <- Gen.choose(0, 50)