use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testRegisterStreamConsumerBackoffJitter.
@Test
public void testRegisterStreamConsumerBackoffJitter() throws Exception {
FullJitterBackoff backoff = mock(FullJitterBackoff.class);
KinesisAsyncClient client = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), backoff);
when(client.registerStreamConsumer(any(RegisterStreamConsumerRequest.class))).thenThrow(new RuntimeException(LimitExceededException.builder().build())).thenReturn(CompletableFuture.completedFuture(RegisterStreamConsumerResponse.builder().build()));
proxy.registerStreamConsumer("arn", "name");
verify(backoff).sleep(anyLong());
verify(backoff).calculateFullJitterBackoff(EXPECTED_REGISTRATION_BASE, EXPECTED_REGISTRATION_MAX, EXPECTED_REGISTRATION_POW, 1);
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testDeregisterStreamConsumer.
@Test
public void testDeregisterStreamConsumer() throws Exception {
KinesisAsyncClient client = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
DeregisterStreamConsumerResponse expected = DeregisterStreamConsumerResponse.builder().build();
ArgumentCaptor<DeregisterStreamConsumerRequest> requestCaptor = ArgumentCaptor.forClass(DeregisterStreamConsumerRequest.class);
when(client.deregisterStreamConsumer(requestCaptor.capture())).thenReturn(CompletableFuture.completedFuture(expected));
DeregisterStreamConsumerResponse actual = proxy.deregisterStreamConsumer("arn");
assertEquals(expected, actual);
DeregisterStreamConsumerRequest request = requestCaptor.getValue();
assertEquals("arn", request.consumerARN());
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project flink by apache.
the class KinesisProxyV2Test method testDescribeStreamConsumerWithStreamArnAndConsumerName.
@Test
public void testDescribeStreamConsumerWithStreamArnAndConsumerName() throws Exception {
KinesisAsyncClient client = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(client, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
DescribeStreamConsumerResponse expected = DescribeStreamConsumerResponse.builder().build();
ArgumentCaptor<DescribeStreamConsumerRequest> requestCaptor = ArgumentCaptor.forClass(DescribeStreamConsumerRequest.class);
when(client.describeStreamConsumer(requestCaptor.capture())).thenReturn(CompletableFuture.completedFuture(expected));
DescribeStreamConsumerResponse actual = proxy.describeStreamConsumer("arn", "name");
assertEquals(expected, actual);
DescribeStreamConsumerRequest request = requestCaptor.getValue();
assertEquals("arn", request.streamARN());
assertEquals("name", request.consumerName());
}
Aggregations