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