Search in sources :

Example 1 with JobExecutionSummary

use of software.amazon.awssdk.iot.iotjobs.model.JobExecutionSummary in project aws-iot-device-sdk-java-v2 by aws.

the class JobsSample method onGetPendingJobExecutionsAccepted.

static void onGetPendingJobExecutionsAccepted(GetPendingJobExecutionsResponse response) {
    System.out.println("Pending Jobs: " + (response.queuedJobs.size() + response.inProgressJobs.size() == 0 ? "none" : ""));
    for (JobExecutionSummary job : response.inProgressJobs) {
        availableJobs.add(job.jobId);
        System.out.println("  In Progress: " + job.jobId + " @  " + job.lastUpdatedAt.toString());
    }
    for (JobExecutionSummary job : response.queuedJobs) {
        availableJobs.add(job.jobId);
        System.out.println("  " + job.jobId + " @ " + job.lastUpdatedAt.toString());
    }
    gotResponse.complete(null);
}
Also used : JobExecutionSummary(software.amazon.awssdk.iot.iotjobs.model.JobExecutionSummary)

Example 2 with JobExecutionSummary

use of software.amazon.awssdk.iot.iotjobs.model.JobExecutionSummary 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 3 with JobExecutionSummary

use of software.amazon.awssdk.iot.iotjobs.model.JobExecutionSummary 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

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