software.amazon.awssdk.services.kinesis.model.ListStreamsResponse Java Examples

The following examples show how to use software.amazon.awssdk.services.kinesis.model.ListStreamsResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsKinesisScannerTest.java    From clouditor with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void setUpOnce() throws IOException {
  discoverAssets(
      KinesisClient.class,
      AwsKinesisScanner::new,
      api -> {
        when(api.listStreams())
            .thenReturn(
                ListStreamsResponse.builder()
                    .streamNames("stream-encrypted", "stream-not-encrypted")
                    .build());

        when(api.describeStream(
                DescribeStreamRequest.builder().streamName("stream-encrypted").build()))
            .thenReturn(
                DescribeStreamResponse.builder()
                    .streamDescription(
                        StreamDescription.builder()
                            .streamARN("arn:aws:kinesis:us-east-1:111122223333:encrypted")
                            .encryptionType(EncryptionType.KMS)
                            .build())
                    .build());

        when(api.describeStream(
                DescribeStreamRequest.builder().streamName("stream-not-encrypted").build()))
            .thenReturn(
                DescribeStreamResponse.builder()
                    .streamDescription(
                        StreamDescription.builder()
                            .streamARN("arn:aws:kinesis:us-east-1:111122223333:unencrypted")
                            .encryptionType(EncryptionType.NONE)
                            .build())
                    .build());
      });
}
 
Example #2
Source File: KinesisIntegrationTests.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
private void findStreamInList(final String streamName) {
    boolean found = false;

    String start = null;
    while (true) {

        ListStreamsResponse result = client.listStreams(ListStreamsRequest.builder().exclusiveStartStreamName(start).build());

        Assert.assertNotNull(result);

        List<String> names = result.streamNames();
        Assert.assertNotNull(names);

        if (names.size() > 0) {
            if (names.contains(streamName)) {
                found = true;
            }

            start = names.get(names.size() - 1);
        }

        if (!result.hasMoreStreams()) {
            break;
        }

    }

    Assert.assertTrue(found);
}
 
Example #3
Source File: KinesisMessageSenderEndpointFactoryTest.java    From synapse with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldBuildKinesisMessageSender() {
    final KinesisAsyncClient kinesisClient = mock(KinesisAsyncClient.class);
    when(kinesisClient.listStreams()).thenReturn(completedFuture(ListStreamsResponse.builder().build()));

    final KinesisMessageSenderEndpointFactory factory = new KinesisMessageSenderEndpointFactory(new MessageInterceptorRegistry(), kinesisClient);

    final KinesisMessageSender sender = (KinesisMessageSender) factory.create("foo-stream", MessageFormat.V2);
    assertThat(sender.getChannelName(), is("foo-stream"));
    assertThat(sender.getMessageFormat(), is(MessageFormat.V2));
    assertThat(sender, is(instanceOf(KinesisMessageSender.class)));
}