Search in sources :

Example 1 with StreamInfo

use of com.amazonaws.services.kinesisvideo.model.StreamInfo in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class EdgeConnectorForKVSService method initKinesisVideoStream.

private void initKinesisVideoStream() {
    for (EdgeConnectorForKVSConfiguration configuration : edgeConnectorForKVSConfigurationList) {
        String kinesisVideoStreamName = configuration.getKinesisVideoStreamName();
        Optional<StreamInfo> result = kvsClient.describeStream(kinesisVideoStreamName);
        if (!result.isPresent()) {
            log.info("Configured KinesisVideoStream name :" + kinesisVideoStreamName + " does not exist, creating it ...");
            kvsClient.createStream(kinesisVideoStreamName);
            log.info("Created KinesisVideoStream name :" + kinesisVideoStreamName);
        }
    }
}
Also used : StreamInfo(com.amazonaws.services.kinesisvideo.model.StreamInfo) EdgeConnectorForKVSConfiguration(com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)

Example 2 with StreamInfo

use of com.amazonaws.services.kinesisvideo.model.StreamInfo in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class KvsClientTest method describeStream_ResourceNotFound.

@Test
public void describeStream_ResourceNotFound() {
    // when
    when(amazonKinesisVideoClient.describeStream(any())).thenThrow(new ResourceNotFoundException(""));
    // then
    Optional<StreamInfo> result = kvsClient.describeStream(STREAM_NAME);
    // verify
    assertFalse(result.isPresent());
}
Also used : StreamInfo(com.amazonaws.services.kinesisvideo.model.StreamInfo) ResourceNotFoundException(com.amazonaws.services.kinesisvideo.model.ResourceNotFoundException) Test(org.junit.jupiter.api.Test)

Example 3 with StreamInfo

use of com.amazonaws.services.kinesisvideo.model.StreamInfo in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class KvsClientTest method testRegionOverride.

@Test
public void testRegionOverride() {
    // when
    this.kvsClient = new KvsClient(awsCredentialsProvider, region);
    DescribeStreamResult describeStreamResult = new DescribeStreamResult().withStreamInfo(new StreamInfo().withStreamName(STREAM_NAME));
    when(amazonKinesisVideoClient.describeStream(any())).thenReturn(describeStreamResult);
    // then and verify
    assertThrows(EdgeConnectorForKVSException.class, () -> {
        kvsClient.describeStream(STREAM_NAME);
    });
}
Also used : StreamInfo(com.amazonaws.services.kinesisvideo.model.StreamInfo) DescribeStreamResult(com.amazonaws.services.kinesisvideo.model.DescribeStreamResult) Test(org.junit.jupiter.api.Test)

Example 4 with StreamInfo

use of com.amazonaws.services.kinesisvideo.model.StreamInfo in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class KvsClientTest method describeStream_Success.

@Test
public void describeStream_Success() {
    // when
    DescribeStreamResult describeStreamResult = new DescribeStreamResult().withStreamInfo(new StreamInfo().withStreamName(STREAM_NAME));
    when(amazonKinesisVideoClient.describeStream(any())).thenReturn(describeStreamResult);
    // then
    Optional<StreamInfo> result = kvsClient.describeStream(STREAM_NAME);
    // verify
    assertEquals(result.get().getStreamName(), STREAM_NAME);
}
Also used : StreamInfo(com.amazonaws.services.kinesisvideo.model.StreamInfo) DescribeStreamResult(com.amazonaws.services.kinesisvideo.model.DescribeStreamResult) Test(org.junit.jupiter.api.Test)

Aggregations

StreamInfo (com.amazonaws.services.kinesisvideo.model.StreamInfo)4 Test (org.junit.jupiter.api.Test)3 DescribeStreamResult (com.amazonaws.services.kinesisvideo.model.DescribeStreamResult)2 ResourceNotFoundException (com.amazonaws.services.kinesisvideo.model.ResourceNotFoundException)1 EdgeConnectorForKVSConfiguration (com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)1