@Test public void testWaitForWhenHasInstancesAndNotCompleted() { ReflectionTestUtils.setField(underTest, "pollingInterval", 1); ReflectionTestUtils.setField(underTest, "pollingAttempt", 2); CloudContext cloudContext = new CloudContext(STACK_ID, "", "", "", ""); CloudCredential cloudCredential = new CloudCredential(STACK_ID.toString(), ""); AuthenticatedContext ac = new AuthenticatedContext(cloudContext, cloudCredential); CloudInstance cloudInstance = new CloudInstance("instanceId", null, null); List<CloudInstance> instances = List.of(cloudInstance); CloudVmInstanceStatus cloudVmInstanceStatus1 = new CloudVmInstanceStatus(cloudInstance, InstanceStatus.IN_PROGRESS); CloudVmInstanceStatus cloudVmInstanceStatus2 = new CloudVmInstanceStatus(cloudInstance, InstanceStatus.CREATED); when(awsInstanceConnector.check(ac, instances)) .thenReturn(List.of(cloudVmInstanceStatus1)) .thenReturn(List.of(cloudVmInstanceStatus2)); List<CloudVmInstanceStatus> actual = underTest.waitFor(ac, instances, Set.of(InstanceStatus.CREATED)); Assert.assertEquals(1, actual.size()); Assert.assertEquals(cloudVmInstanceStatus2, actual.get(0)); }
public List<CloudVmInstanceStatus> waitFor(AuthenticatedContext authenticatedContext, List<CloudInstance> instances, Set<InstanceStatus> completedStatuses) { return Polling.stopAfterAttempt(pollingAttempt) .waitPeriodly(pollingInterval, TimeUnit.SECONDS) .stopIfException(true) .run(process(authenticatedContext, instances, completedStatuses)); }
PollerUtil { public List<CloudVmInstanceStatus> waitFor(AuthenticatedContext authenticatedContext, List<CloudInstance> instances, Set<InstanceStatus> completedStatuses) { return Polling.stopAfterAttempt(pollingAttempt) .waitPeriodly(pollingInterval, TimeUnit.SECONDS) .stopIfException(true) .run(process(authenticatedContext, instances, completedStatuses)); } }
PollerUtil { public List<CloudVmInstanceStatus> waitFor(AuthenticatedContext authenticatedContext, List<CloudInstance> instances, Set<InstanceStatus> completedStatuses) { return Polling.stopAfterAttempt(pollingAttempt) .waitPeriodly(pollingInterval, TimeUnit.SECONDS) .stopIfException(true) .run(process(authenticatedContext, instances, completedStatuses)); }  }
PollerUtil { public List<CloudVmInstanceStatus> waitFor(AuthenticatedContext authenticatedContext, List<CloudInstance> instances, Set<InstanceStatus> completedStatuses) { return Polling.stopAfterAttempt(pollingAttempt) .waitPeriodly(pollingInterval, TimeUnit.SECONDS) .stopIfException(true) .run(process(authenticatedContext, instances, completedStatuses)); }  List<CloudVmInstanceStatus> waitFor(AuthenticatedContext authenticatedContext, List<CloudInstance> instances,
            Set<InstanceStatus> completedStatuses); }
PollerUtil { public List<CloudVmInstanceStatus> waitFor(AuthenticatedContext authenticatedContext, List<CloudInstance> instances, Set<InstanceStatus> completedStatuses) { return Polling.stopAfterAttempt(pollingAttempt) .waitPeriodly(pollingInterval, TimeUnit.SECONDS) .stopIfException(true) .run(process(authenticatedContext, instances, completedStatuses)); }  List<CloudVmInstanceStatus> waitFor(AuthenticatedContext authenticatedContext, List<CloudInstance> instances,
            Set<InstanceStatus> completedStatuses);  }