use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method test_initMQTTSubscription_onError.
@Test
public void test_initMQTTSubscription_onError(@TempDir Path tempDir) throws IOException, InterruptedException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).captureStartTime(START_TIME_NEVER).liveStreamingStartTime(START_TIME_NEVER).videoUploadRequestMqttTopic(VIDEO_UPLOAD_REQUEST_MQTT_TOPIC).videoRecordFolderPath(tempDir).recordingRequestsCount(0).liveStreamingRequestsCount(0).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
doAnswer(invocationOnMock -> {
VideoUploadRequestEvent event = invocationOnMock.getArgument(1);
event.onError("Test Error");
return null;
}).when(videoUploadRequestHandler).subscribeToMqttTopic(any(), any());
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
Thread.sleep(3000);
assertEquals(0, edgeConnectorForKVSConfiguration.getLiveStreamingRequestsCount());
assertEquals(0, edgeConnectorForKVSConfiguration.getRecordingRequestsCount());
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method testInitVideoRecorders_startRecordingJob_InterruptedException.
@Test
public void testInitVideoRecorders_startRecordingJob_InterruptedException(@TempDir Path tempDir) throws IOException, InterruptedException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = Mockito.spy(EdgeConnectorForKVSConfiguration.class);
ReentrantLock processLock = Mockito.mock(ReentrantLock.class);
when(edgeConnectorForKVSConfiguration.getKinesisVideoStreamName()).thenReturn(MOCK_KINESIS_VIDEO_STREAM_NAME);
when(edgeConnectorForKVSConfiguration.getLiveStreamingStartTime()).thenReturn(START_TIME_ALWAYS);
when(edgeConnectorForKVSConfiguration.getCaptureStartTime()).thenReturn(START_TIME_ALWAYS);
when(edgeConnectorForKVSConfiguration.getCaptureStartTime()).thenReturn(CAPTURE_START_TIME);
when(edgeConnectorForKVSConfiguration.getVideoRecordFolderPath()).thenReturn(tempDir);
doNothing().when(edgeConnectorForKVSConfiguration).setVideoUploader(any());
doNothing().when(edgeConnectorForKVSConfiguration).setVideoUploader(any());
doNothing().when(edgeConnectorForKVSConfiguration).setProcessLock(any());
when(edgeConnectorForKVSConfiguration.getProcessLock()).thenReturn(processLock);
when(processLock.tryLock(anyLong(), any())).thenThrow(new InterruptedException());
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
Thread.sleep(2000);
// verify
assertEquals(0, edgeConnectorForKVSConfiguration.getRecordingRequestsCount());
assertEquals(true, edgeConnectorForKVSConfiguration.getFatalStatus().get());
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method testInitVideoUploaders_Configure_Not_Init.
@Test
public void testInitVideoUploaders_Configure_Not_Init(@TempDir Path tempDir) throws IOException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).liveStreamingStartTime("").videoRecordFolderPath(tempDir).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
// verify
assertNotNull(edgeConnectorForKVSConfiguration.videoUploader);
assertNotNull(edgeConnectorForKVSConfiguration.inputStream);
assertEquals(0, edgeConnectorForKVSConfiguration.getLiveStreamingRequestsCount());
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method test_initMQTTSubscription_onStartHistorical.
@Test
public void test_initMQTTSubscription_onStartHistorical(@TempDir Path tempDir) throws IOException, InterruptedException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).captureStartTime(START_TIME_NEVER).liveStreamingStartTime(START_TIME_NEVER).videoUploadRequestMqttTopic(VIDEO_UPLOAD_REQUEST_MQTT_TOPIC).videoRecordFolderPath(tempDir).recordingRequestsCount(0).liveStreamingRequestsCount(0).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
doAnswer(invocationOnMock -> {
VideoUploadRequestEvent event = invocationOnMock.getArgument(1);
event.onStart(IS_LIVE_FALSE, EVENT_TIMESTAMP, START_TIME, END_TIME);
return null;
}).when(videoUploadRequestHandler).subscribeToMqttTopic(any(), any());
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
Thread.sleep(3000);
assertEquals(0, edgeConnectorForKVSConfiguration.getLiveStreamingRequestsCount());
assertEquals(0, edgeConnectorForKVSConfiguration.getRecordingRequestsCount());
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method testInitConfiguration.
@Test
public void testInitConfiguration(@TempDir Path tempDir) throws IOException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).liveStreamingStartTime(LIVE_STREAMING_START_TIME).liveStreamingDurationInMinutes(LIVE_STREAMING_DURATION_IN_MINUTES).videoRecordFolderPath(tempDir).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSConfigurationList.forEach(configuration -> edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(configuration));
// verify
assertNotNull(edgeConnectorForKVSConfigurationList.get(0).getRtspStreamURL());
}
Aggregations