Search in sources :

Example 1 with StreamDescription

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);
}
Also used : StreamDescription(com.amazonaws.services.kinesis.model.StreamDescription) Shard(com.amazonaws.services.kinesis.model.Shard) DescribeStreamResult(com.amazonaws.services.kinesis.model.DescribeStreamResult) Test(org.junit.Test)

Example 2 with StreamDescription

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"));
}
Also used : GetRecordsResult(com.amazonaws.services.kinesis.model.GetRecordsResult) StreamDescription(com.amazonaws.services.kinesis.model.StreamDescription) GetShardIteratorRequest(com.amazonaws.services.kinesis.model.GetShardIteratorRequest) GetShardIteratorResult(com.amazonaws.services.kinesis.model.GetShardIteratorResult) DescribeStreamRequest(com.amazonaws.services.kinesis.model.DescribeStreamRequest) DescribeStreamResult(com.amazonaws.services.kinesis.model.DescribeStreamResult) Shard(com.amazonaws.services.kinesis.model.Shard) GetRecordsRequest(com.amazonaws.services.kinesis.model.GetRecordsRequest) Before(org.junit.Before)

Example 3 with StreamDescription

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));
}
Also used : StreamDescription(com.amazonaws.services.kinesis.model.StreamDescription) Shard(com.amazonaws.services.kinesis.model.Shard) DescribeStreamResult(com.amazonaws.services.kinesis.model.DescribeStreamResult)

Aggregations

DescribeStreamResult (com.amazonaws.services.kinesis.model.DescribeStreamResult)3 Shard (com.amazonaws.services.kinesis.model.Shard)3 StreamDescription (com.amazonaws.services.kinesis.model.StreamDescription)3 DescribeStreamRequest (com.amazonaws.services.kinesis.model.DescribeStreamRequest)1 GetRecordsRequest (com.amazonaws.services.kinesis.model.GetRecordsRequest)1 GetRecordsResult (com.amazonaws.services.kinesis.model.GetRecordsResult)1 GetShardIteratorRequest (com.amazonaws.services.kinesis.model.GetShardIteratorRequest)1 GetShardIteratorResult (com.amazonaws.services.kinesis.model.GetShardIteratorResult)1 Before (org.junit.Before)1 Test (org.junit.Test)1