Search in sources :

Example 1 with SendConfigurationValidityReportResponse

use of software.amazon.awssdk.aws.greengrass.model.SendConfigurationValidityReportResponse in project aws-greengrass-nucleus by aws-greengrass.

the class ConfigStoreIPCEventStreamAgentTest method GIVEN_validation_event_being_tracked_WHEN_send_config_validity_report_request_THEN_notify_validation_requester.

@Test
void GIVEN_validation_event_being_tracked_WHEN_send_config_validity_report_request_THEN_notify_validation_requester() throws Exception {
    when(mockAuthenticationData.getIdentityLabel()).thenReturn(TEST_COMPONENT_A);
    when(mockServerConnectionContinuation.sendMessage(anyList(), byteArrayCaptor.capture(), any(MessageType.class), anyInt())).thenReturn(new CompletableFuture<>());
    SubscribeToValidateConfigurationUpdatesRequest request = new SubscribeToValidateConfigurationUpdatesRequest();
    SubscribeToValidateConfigurationUpdatesResponse response = agent.getValidateConfigurationUpdatesHandler(mockContext).handleRequest(request);
    assertNotNull(response);
    Map<String, Object> configToValidate = new HashMap<>();
    configToValidate.put(TEST_CONFIG_KEY_1, 0);
    configToValidate.put(TEST_CONFIG_KEY_2, 100);
    CompletableFuture<ConfigurationValidityReport> validationTracker = new CompletableFuture<>();
    assertTrue(agent.validateConfiguration(TEST_COMPONENT_A, "A", configToValidate, validationTracker));
    SendConfigurationValidityReportRequest reportRequest = new SendConfigurationValidityReportRequest();
    ConfigurationValidityReport validityReport = new ConfigurationValidityReport();
    validityReport.setStatus(ConfigurationValidityStatus.ACCEPTED);
    validityReport.setDeploymentId("A");
    reportRequest.setConfigurationValidityReport(validityReport);
    SendConfigurationValidityReportResponse reportResponse = agent.getSendConfigurationValidityReportHandler(mockContext).handleRequest(reportRequest);
    assertNotNull(reportResponse);
    assertTrue(validationTracker.isDone());
    assertEquals(ConfigurationValidityStatus.ACCEPTED, validationTracker.get().getStatus());
}
Also used : SubscribeToValidateConfigurationUpdatesRequest(software.amazon.awssdk.aws.greengrass.model.SubscribeToValidateConfigurationUpdatesRequest) HashMap(java.util.HashMap) SendConfigurationValidityReportResponse(software.amazon.awssdk.aws.greengrass.model.SendConfigurationValidityReportResponse) SendConfigurationValidityReportRequest(software.amazon.awssdk.aws.greengrass.model.SendConfigurationValidityReportRequest) SubscribeToValidateConfigurationUpdatesResponse(software.amazon.awssdk.aws.greengrass.model.SubscribeToValidateConfigurationUpdatesResponse) CompletableFuture(java.util.concurrent.CompletableFuture) MessageType(software.amazon.awssdk.crt.eventstream.MessageType) ConfigurationValidityReport(software.amazon.awssdk.aws.greengrass.model.ConfigurationValidityReport) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Test (org.junit.jupiter.api.Test)1 ConfigurationValidityReport (software.amazon.awssdk.aws.greengrass.model.ConfigurationValidityReport)1 SendConfigurationValidityReportRequest (software.amazon.awssdk.aws.greengrass.model.SendConfigurationValidityReportRequest)1 SendConfigurationValidityReportResponse (software.amazon.awssdk.aws.greengrass.model.SendConfigurationValidityReportResponse)1 SubscribeToValidateConfigurationUpdatesRequest (software.amazon.awssdk.aws.greengrass.model.SubscribeToValidateConfigurationUpdatesRequest)1 SubscribeToValidateConfigurationUpdatesResponse (software.amazon.awssdk.aws.greengrass.model.SubscribeToValidateConfigurationUpdatesResponse)1 MessageType (software.amazon.awssdk.crt.eventstream.MessageType)1