use of com.amazonaws.services.kinesis.model.StreamDescription in project beam by apache.
the class SimplifiedKinesisClientTest method shouldListAllShards.
@Test
public void shouldListAllShards() throws Exception {
Shard shard1 = new Shard().withShardId(SHARD_1);
Shard shard2 = new Shard().withShardId(SHARD_2);
Shard shard3 = new Shard().withShardId(SHARD_3);
given(kinesis.describeStream(STREAM, null)).willReturn(new DescribeStreamResult().withStreamDescription(new StreamDescription().withShards(shard1, shard2).withHasMoreShards(true)));
given(kinesis.describeStream(STREAM, SHARD_2)).willReturn(new DescribeStreamResult().withStreamDescription(new StreamDescription().withShards(shard3).withHasMoreShards(false)));
List<Shard> shards = underTest.listShards(STREAM);
assertThat(shards).containsOnly(shard1, shard2, shard3);
}
use of com.amazonaws.services.kinesis.model.StreamDescription in project camel by apache.
the class KinesisConsumerTest method setup.
@Before
public void setup() throws Exception {
KinesisEndpoint endpoint = new KinesisEndpoint(null, "streamName", component);
endpoint.setAmazonKinesisClient(kinesisClient);
endpoint.setIteratorType(ShardIteratorType.LATEST);
undertest = new KinesisConsumer(endpoint, processor);
when(kinesisClient.getRecords(any(GetRecordsRequest.class))).thenReturn(new GetRecordsResult().withNextShardIterator("nextShardIterator"));
when(kinesisClient.describeStream(any(DescribeStreamRequest.class))).thenReturn(new DescribeStreamResult().withStreamDescription(new StreamDescription().withShards(new Shard().withShardId("shardId"))));
when(kinesisClient.getShardIterator(any(GetShardIteratorRequest.class))).thenReturn(new GetShardIteratorResult().withShardIterator("shardIterator"));
}
use of com.amazonaws.services.kinesis.model.StreamDescription in project beam by apache.
the class AmazonKinesisMock method describeStream.
@Override
public DescribeStreamResult describeStream(String streamName, String exclusiveStartShardId) {
int nextShardId = 0;
if (exclusiveStartShardId != null) {
nextShardId = parseInt(exclusiveStartShardId) + 1;
}
boolean hasMoreShards = nextShardId + 1 < shardedData.size();
List<Shard> shards = newArrayList();
if (nextShardId < shardedData.size()) {
shards.add(new Shard().withShardId(Integer.toString(nextShardId)));
}
return new DescribeStreamResult().withStreamDescription(new StreamDescription().withHasMoreShards(hasMoreShards).withShards(shards));
}
Aggregations