Search in sources :

Example 1 with ChildChanged

use of com.aws.greengrass.config.ChildChanged in project aws-greengrass-nucleus by aws-greengrass.

the class IotJobsHelperTest method GIVEN_device_configured_WHEN_connecting_to_iot_cloud_THEN_connection_retry_on_provisioning.

@Test
void GIVEN_device_configured_WHEN_connecting_to_iot_cloud_THEN_connection_retry_on_provisioning() throws Exception {
    doThrow(new DeviceConfigurationException("Error")).doNothing().when(deviceConfiguration).validate();
    iotJobsHelper.postInject();
    ArgumentCaptor<ChildChanged> ccCaptor = ArgumentCaptor.forClass(ChildChanged.class);
    verify(deviceConfiguration).onAnyChange(ccCaptor.capture());
    Node mockNode = mock(Node.class);
    lenient().doReturn(true).when(mockNode).childOf(eq(DEVICE_PARAM_IOT_DATA_ENDPOINT));
    ccCaptor.getValue().childChanged(WhatHappened.childChanged, mockNode);
    verify(mockMqttClient, times(1)).addToCallbackEvents(any());
    verify(mockIotJobsClientWrapper, times(1)).SubscribeToJobExecutionsChangedEvents(any(), any(), any());
    verify(mockIotJobsClientWrapper, times(1)).SubscribeToDescribeJobExecutionAccepted(any(), any(), any());
    verify(mockIotJobsClientWrapper, times(1)).SubscribeToDescribeJobExecutionRejected(any(), any(), any());
    verify(mockFleetStatusService, times(1)).updateFleetStatusUpdateForAllComponents();
}
Also used : ChildChanged(com.aws.greengrass.config.ChildChanged) Node(com.aws.greengrass.config.Node) DeviceConfigurationException(com.aws.greengrass.deployment.exceptions.DeviceConfigurationException) Test(org.junit.jupiter.api.Test)

Example 2 with ChildChanged

use of com.aws.greengrass.config.ChildChanged in project aws-greengrass-nucleus by aws-greengrass.

the class ShadowDeploymentListenerTest method testCommunicationWithIotCore_unsuccessful_THEN_retry_on_update.

@Test
public void testCommunicationWithIotCore_unsuccessful_THEN_retry_on_update() throws DeviceConfigurationException {
    when(mockKernel.getContext()).thenReturn(mockContext);
    when(mockContext.runOnPublishQueueAndWait(any())).thenReturn(null);
    doThrow(new DeviceConfigurationException("Error")).doNothing().when(mockDeviceConfiguration).validate();
    doReturn(CompletableFuture.completedFuture(null)).when(mockIotShadowClient).SubscribeToUpdateNamedShadowAccepted(any(), any(), any(), any());
    doReturn(CompletableFuture.completedFuture(null)).when(mockIotShadowClient).SubscribeToUpdateNamedShadowRejected(any(), any(), any(), any());
    doReturn(CompletableFuture.completedFuture(null)).when(mockIotShadowClient).SubscribeToGetNamedShadowAccepted(any(), any(), any(), any());
    shadowDeploymentListener.postInject();
    ArgumentCaptor<ChildChanged> ccCaptor = ArgumentCaptor.forClass(ChildChanged.class);
    verify(mockDeviceConfiguration).onAnyChange(ccCaptor.capture());
    Node mockNode = mock(Node.class);
    lenient().when(mockNode.childOf(DEVICE_PARAM_IOT_DATA_ENDPOINT)).thenReturn(true);
    ccCaptor.getValue().childChanged(WhatHappened.childChanged, mockNode);
    verify(mockMqttClient, times(1)).addToCallbackEvents(any());
    verify(mockIotShadowClient, timeout(1000).times(1)).SubscribeToUpdateNamedShadowAccepted(any(), any(), any(), any());
    verify(mockIotShadowClient, timeout(1000).times(1)).SubscribeToUpdateNamedShadowRejected(any(), any(), any(), any());
    verify(mockIotShadowClient, timeout(1000).times(1)).SubscribeToGetNamedShadowAccepted(any(), any(), any(), any());
}
Also used : ChildChanged(com.aws.greengrass.config.ChildChanged) Node(com.aws.greengrass.config.Node) DeviceConfigurationException(com.aws.greengrass.deployment.exceptions.DeviceConfigurationException) Test(org.junit.jupiter.api.Test)

Aggregations

ChildChanged (com.aws.greengrass.config.ChildChanged)2 Node (com.aws.greengrass.config.Node)2 DeviceConfigurationException (com.aws.greengrass.deployment.exceptions.DeviceConfigurationException)2 Test (org.junit.jupiter.api.Test)2