@Test public void ensureStopped_GivenReadyApplication_ShouldRequestStatusExactlyOnce() throws InterruptedException { Mockito.when(client.describeApplication(describeApplicationRequest)) .thenReturn(withStatus(ApplicationStatus.READY)); manager.ensureStopped(); Mockito.verify(client).describeApplication(describeApplicationRequest); }
public void ensureStopped() throws InterruptedException { for (int i = 0; i < 30; i++) { ApplicationStatus currentStatus = detailSupplier.get().applicationStatus(); switch (currentStatus) { case RUNNING: stop(); break; case STOPPING: break; case READY: return; default: throw new IllegalStateException("application in unexpected state: " + currentStatus); } Thread.sleep(statusPollingInterval); } throw new IllegalStateException("timed out waiting for application to stop"); }
ApplicationLifecycleManager { public void ensureStopped() throws InterruptedException { for (int i = 0; i < 30; i++) { ApplicationStatus currentStatus = detailSupplier.get().applicationStatus(); switch (currentStatus) { case RUNNING: stop(); break; case STOPPING: break; case READY: return; default: throw new IllegalStateException("application in unexpected state: " + currentStatus); } Thread.sleep(statusPollingInterval); } throw new IllegalStateException("timed out waiting for application to stop"); } }
ApplicationLifecycleManager { public void ensureStopped() throws InterruptedException { for (int i = 0; i < 30; i++) { ApplicationStatus currentStatus = detailSupplier.get().applicationStatus(); switch (currentStatus) { case RUNNING: stop(); break; case STOPPING: break; case READY: return; default: throw new IllegalStateException("application in unexpected state: " + currentStatus); } Thread.sleep(statusPollingInterval); } throw new IllegalStateException("timed out waiting for application to stop"); } ApplicationLifecycleManager(String applicationName);  ApplicationLifecycleManager(KinesisAnalyticsClient client,
                                       String applicationName,
                                       long statusPollingIntervalMs); }
ApplicationLifecycleManager { public void ensureStopped() throws InterruptedException { for (int i = 0; i < 30; i++) { ApplicationStatus currentStatus = detailSupplier.get().applicationStatus(); switch (currentStatus) { case RUNNING: stop(); break; case STOPPING: break; case READY: return; default: throw new IllegalStateException("application in unexpected state: " + currentStatus); } Thread.sleep(statusPollingInterval); } throw new IllegalStateException("timed out waiting for application to stop"); } ApplicationLifecycleManager(String applicationName);  ApplicationLifecycleManager(KinesisAnalyticsClient client,
                                       String applicationName,
                                       long statusPollingIntervalMs); void ensureRunning(); void ensureStopped(); }
ApplicationLifecycleManager { public void ensureStopped() throws InterruptedException { for (int i = 0; i < 30; i++) { ApplicationStatus currentStatus = detailSupplier.get().applicationStatus(); switch (currentStatus) { case RUNNING: stop(); break; case STOPPING: break; case READY: return; default: throw new IllegalStateException("application in unexpected state: " + currentStatus); } Thread.sleep(statusPollingInterval); } throw new IllegalStateException("timed out waiting for application to stop"); } ApplicationLifecycleManager(String applicationName);  ApplicationLifecycleManager(KinesisAnalyticsClient client,
                                       String applicationName,
                                       long statusPollingIntervalMs); void ensureRunning(); void ensureStopped();  }