Search in sources :

Example 6 with GetShardIteratorResult

use of com.amazonaws.services.kinesis.model.GetShardIteratorResult 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 7 with GetShardIteratorResult

use of com.amazonaws.services.kinesis.model.GetShardIteratorResult in project beam by apache.

the class SimplifiedKinesisClientTest method shouldReturnIteratorStartingWithSequenceNumber.

@Test
public void shouldReturnIteratorStartingWithSequenceNumber() throws Exception {
    given(kinesis.getShardIterator(new GetShardIteratorRequest().withStreamName(STREAM).withShardId(SHARD_1).withShardIteratorType(ShardIteratorType.AT_SEQUENCE_NUMBER).withStartingSequenceNumber(SEQUENCE_NUMBER))).willReturn(new GetShardIteratorResult().withShardIterator(SHARD_ITERATOR));
    String stream = underTest.getShardIterator(STREAM, SHARD_1, ShardIteratorType.AT_SEQUENCE_NUMBER, SEQUENCE_NUMBER, null);
    assertThat(stream).isEqualTo(SHARD_ITERATOR);
}
Also used : GetShardIteratorRequest(com.amazonaws.services.kinesis.model.GetShardIteratorRequest) GetShardIteratorResult(com.amazonaws.services.kinesis.model.GetShardIteratorResult) Test(org.junit.Test)

Aggregations

GetShardIteratorResult (com.amazonaws.services.kinesis.model.GetShardIteratorResult)7 GetShardIteratorRequest (com.amazonaws.services.kinesis.model.GetShardIteratorRequest)5 DescribeStreamRequest (com.amazonaws.services.kinesis.model.DescribeStreamRequest)2 DescribeStreamResult (com.amazonaws.services.kinesis.model.DescribeStreamResult)2 Test (org.junit.Test)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 GetRecordsRequest (com.amazonaws.services.kinesis.model.GetRecordsRequest)1 GetRecordsResult (com.amazonaws.services.kinesis.model.GetRecordsResult)1 Shard (com.amazonaws.services.kinesis.model.Shard)1 ShardIteratorType (com.amazonaws.services.kinesis.model.ShardIteratorType)1 StreamDescription (com.amazonaws.services.kinesis.model.StreamDescription)1 Instant (org.joda.time.Instant)1 Before (org.junit.Before)1