Search in sources :

Example 1 with DeferComponentUpdateResponse

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

the class LifecycleIPCEventStreamAgentTest method testUpdateStateHandler_subscribe_then_defer.

@Test
@SuppressWarnings("PMD.CloseResource")
void testUpdateStateHandler_subscribe_then_defer() throws ExecutionException, InterruptedException {
    SubscribeToComponentUpdatesRequest subsRequest = new SubscribeToComponentUpdatesRequest();
    LifecycleIPCEventStreamAgent.SubscribeToComponentUpdateOperationHandler handler = lifecycleIPCEventStreamAgent.getSubscribeToComponentUpdateHandler(mockContext);
    SubscribeToComponentUpdatesResponse response = handler.handleRequest(subsRequest);
    assertNotNull(response);
    CompletableFuture<DeferComponentUpdateRequest> deferFuture = new CompletableFuture<>();
    lifecycleIPCEventStreamAgent.getDeferUpdateFuturesMap().put(new Pair<>(TEST_SERVICE, "A"), deferFuture);
    DeferComponentUpdateRequest deferComponentUpdateRequest = new DeferComponentUpdateRequest();
    deferComponentUpdateRequest.setMessage("Test defer");
    deferComponentUpdateRequest.setDeploymentId("A");
    deferComponentUpdateRequest.setRecheckAfterMs(1000L);
    DeferComponentUpdateResponse response1 = lifecycleIPCEventStreamAgent.getDeferComponentHandler(mockContext).handleRequest(deferComponentUpdateRequest);
    assertNotNull(response1);
    DeferComponentUpdateRequest request = deferFuture.get();
    assertEquals("A", request.getDeploymentId());
    assertEquals("Test defer", request.getMessage());
    assertEquals(1000L, request.getRecheckAfterMs());
    assertFalse(lifecycleIPCEventStreamAgent.getDeferUpdateFuturesMap().containsKey(new Pair<>(TEST_SERVICE, "A")));
}
Also used : SubscribeToComponentUpdatesResponse(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesResponse) CompletableFuture(java.util.concurrent.CompletableFuture) DeferComponentUpdateResponse(software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateResponse) SubscribeToComponentUpdatesRequest(software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest) DeferComponentUpdateRequest(software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest) Pair(com.aws.greengrass.util.Pair) Test(org.junit.jupiter.api.Test)

Aggregations

Pair (com.aws.greengrass.util.Pair)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Test (org.junit.jupiter.api.Test)1 DeferComponentUpdateRequest (software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateRequest)1 DeferComponentUpdateResponse (software.amazon.awssdk.aws.greengrass.model.DeferComponentUpdateResponse)1 SubscribeToComponentUpdatesRequest (software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesRequest)1 SubscribeToComponentUpdatesResponse (software.amazon.awssdk.aws.greengrass.model.SubscribeToComponentUpdatesResponse)1