Search in sources :

Example 6 with ShardFilter

use of software.amazon.awssdk.services.kinesis.model.ShardFilter in project beam by apache.

the class SimplifiedKinesisClientTest method shouldListAllShardsForTrimHorizonWithPagedResults.

@Test
public void shouldListAllShardsForTrimHorizonWithPagedResults() throws Exception {
    Shard shard1 = Shard.builder().shardId(SHARD_1).build();
    Shard shard2 = Shard.builder().shardId(SHARD_2).build();
    Shard shard3 = Shard.builder().shardId(SHARD_3).build();
    ShardFilter shardFilter = ShardFilter.builder().type(ShardFilterType.AT_TRIM_HORIZON).build();
    String nextListShardsToken = "testNextToken";
    when(kinesis.listShards(ListShardsRequest.builder().streamName(STREAM).shardFilter(shardFilter).maxResults(1_000).build())).thenReturn(ListShardsResponse.builder().shards(shard1, shard2).nextToken(nextListShardsToken).build());
    when(kinesis.listShards(ListShardsRequest.builder().maxResults(1_000).shardFilter(shardFilter).nextToken(nextListShardsToken).build())).thenReturn(ListShardsResponse.builder().shards(shard3).nextToken(null).build());
    List<Shard> shards = underTest.listShardsAtPoint(STREAM, new StartingPoint(InitialPositionInStream.TRIM_HORIZON));
    assertThat(shards).containsOnly(shard1, shard2, shard3);
}
Also used : ShardFilter(software.amazon.awssdk.services.kinesis.model.ShardFilter) Shard(software.amazon.awssdk.services.kinesis.model.Shard) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 Shard (software.amazon.awssdk.services.kinesis.model.Shard)6 ShardFilter (software.amazon.awssdk.services.kinesis.model.ShardFilter)6 Instant (org.joda.time.Instant)4 Datapoint (software.amazon.awssdk.services.cloudwatch.model.Datapoint)3 DescribeStreamSummaryRequest (software.amazon.awssdk.services.kinesis.model.DescribeStreamSummaryRequest)2