Search in sources :

Example 1 with JobStatus

use of software.amazon.awssdk.iot.iotjobs.model.JobStatus in project aws-greengrass-nucleus by aws-greengrass.

the class IotJobsHelperTest method GIVEN_connected_to_iot_WHEN_subscribe_to_jobs_topics_THEN_get_notification_for_queued_jobs.

@Test
void GIVEN_connected_to_iot_WHEN_subscribe_to_jobs_topics_THEN_get_notification_for_queued_jobs() throws Exception {
    iotJobsHelper.postInject();
    CompletableFuture<Integer> integerCompletableFuture = CompletableFuture.completedFuture(1);
    when(mockIotJobsClientWrapper.SubscribeToJobExecutionsChangedEvents(any(), eq(QualityOfService.AT_LEAST_ONCE), any())).thenReturn(integerCompletableFuture);
    when(mockIotJobsClientWrapper.SubscribeToDescribeJobExecutionAccepted(any(), eq(QualityOfService.AT_LEAST_ONCE), any())).thenReturn(integerCompletableFuture);
    when(mockIotJobsClientWrapper.SubscribeToDescribeJobExecutionRejected(any(), eq(QualityOfService.AT_LEAST_ONCE), any())).thenReturn(integerCompletableFuture);
    iotJobsHelper.subscribeToJobsTopics();
    verify(mockIotJobsClientWrapper, times(2)).SubscribeToJobExecutionsChangedEvents(any(), eq(QualityOfService.AT_LEAST_ONCE), eventChangeResponseCaptor.capture());
    JobExecutionsChangedEvent event = new JobExecutionsChangedEvent();
    HashMap<JobStatus, List<JobExecutionSummary>> jobs = new HashMap<>();
    jobs.put(JobStatus.QUEUED, Arrays.asList(new JobExecutionSummary()));
    event.jobs = jobs;
    eventChangeResponseCaptor.getValue().accept(event);
    verify(mockIotJobsClientWrapper, times(3)).PublishDescribeJobExecution(any(), eq(QualityOfService.AT_LEAST_ONCE));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JobStatus(software.amazon.awssdk.iot.iotjobs.model.JobStatus) HashMap(java.util.HashMap) JobExecutionsChangedEvent(software.amazon.awssdk.iot.iotjobs.model.JobExecutionsChangedEvent) JobExecutionSummary(software.amazon.awssdk.iot.iotjobs.model.JobExecutionSummary) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 2 with JobStatus

use of software.amazon.awssdk.iot.iotjobs.model.JobStatus in project aws-greengrass-nucleus by aws-greengrass.

the class IotJobsHelperTest method GIVEN_connected_to_iot_WHEN_subscribe_to_jobs_topics_THEN_get_notification_for_in_progress_jobs.

@Test
void GIVEN_connected_to_iot_WHEN_subscribe_to_jobs_topics_THEN_get_notification_for_in_progress_jobs() throws Exception {
    iotJobsHelper.postInject();
    CompletableFuture<Integer> integerCompletableFuture = CompletableFuture.completedFuture(1);
    when(mockIotJobsClientWrapper.SubscribeToJobExecutionsChangedEvents(any(), eq(QualityOfService.AT_LEAST_ONCE), any())).thenReturn(integerCompletableFuture);
    when(mockIotJobsClientWrapper.SubscribeToDescribeJobExecutionAccepted(any(), eq(QualityOfService.AT_LEAST_ONCE), any())).thenReturn(integerCompletableFuture);
    when(mockIotJobsClientWrapper.SubscribeToDescribeJobExecutionRejected(any(), eq(QualityOfService.AT_LEAST_ONCE), any())).thenReturn(integerCompletableFuture);
    iotJobsHelper.subscribeToJobsTopics();
    verify(mockIotJobsClientWrapper, times(2)).SubscribeToJobExecutionsChangedEvents(any(), eq(QualityOfService.AT_LEAST_ONCE), eventChangeResponseCaptor.capture());
    JobExecutionsChangedEvent event = new JobExecutionsChangedEvent();
    HashMap<JobStatus, List<JobExecutionSummary>> jobs = new HashMap<>();
    jobs.put(JobStatus.IN_PROGRESS, Arrays.asList(new JobExecutionSummary()));
    event.jobs = jobs;
    eventChangeResponseCaptor.getValue().accept(event);
    verify(mockIotJobsClientWrapper, times(2)).PublishDescribeJobExecution(any(), eq(QualityOfService.AT_LEAST_ONCE));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JobStatus(software.amazon.awssdk.iot.iotjobs.model.JobStatus) HashMap(java.util.HashMap) JobExecutionsChangedEvent(software.amazon.awssdk.iot.iotjobs.model.JobExecutionsChangedEvent) JobExecutionSummary(software.amazon.awssdk.iot.iotjobs.model.JobExecutionSummary) List(java.util.List) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)2 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Test (org.junit.jupiter.api.Test)2 JobExecutionSummary (software.amazon.awssdk.iot.iotjobs.model.JobExecutionSummary)2 JobExecutionsChangedEvent (software.amazon.awssdk.iot.iotjobs.model.JobExecutionsChangedEvent)2 JobStatus (software.amazon.awssdk.iot.iotjobs.model.JobStatus)2