@Test public void testReadyToTerminate() throws Exception { AbstractJobTerminationStateService service = new AbstractJobTerminationStateService() { }; service.setServiceRegistry(serviceRegistry); Assert.assertEquals(false, service.readyToTerminate()); service.setState(TerminationStateService.TerminationState.WAIT); Assert.assertEquals(false, service.readyToTerminate()); Assert.assertEquals(true, service.readyToTerminate()); Assert.assertEquals(TerminationStateService.TerminationState.READY, service.getState()); }
protected boolean readyToTerminate() { if (state == TerminationState.WAIT) { try { if (countJobs() == 0) { state = TerminationState.READY; return true; } } catch (ServiceRegistryException ex) { logger.warn("Can't determine number of running Jobs, setting Termination State to READ"); state = TerminationState.READY; return true; } } else if (state == TerminationState.READY) { return true; } return false; }
AbstractJobTerminationStateService implements TerminationStateService { protected boolean readyToTerminate() { if (state == TerminationState.WAIT) { try { if (countJobs() == 0) { state = TerminationState.READY; return true; } } catch (ServiceRegistryException ex) { logger.warn("Can't determine number of running Jobs, setting Termination State to READ"); state = TerminationState.READY; return true; } } else if (state == TerminationState.READY) { return true; } return false; } }
AbstractJobTerminationStateService implements TerminationStateService { protected boolean readyToTerminate() { if (state == TerminationState.WAIT) { try { if (countJobs() == 0) { state = TerminationState.READY; return true; } } catch (ServiceRegistryException ex) { logger.warn("Can't determine number of running Jobs, setting Termination State to READ"); state = TerminationState.READY; return true; } } else if (state == TerminationState.READY) { return true; } return false; }  }
AbstractJobTerminationStateService implements TerminationStateService { protected boolean readyToTerminate() { if (state == TerminationState.WAIT) { try { if (countJobs() == 0) { state = TerminationState.READY; return true; } } catch (ServiceRegistryException ex) { logger.warn("Can't determine number of running Jobs, setting Termination State to READ"); state = TerminationState.READY; return true; } } else if (state == TerminationState.READY) { return true; } return false; }  @Override void setState(TerminationState state); @Override TerminationState getState(); void setServiceRegistry(ServiceRegistry service); }
AbstractJobTerminationStateService implements TerminationStateService { protected boolean readyToTerminate() { if (state == TerminationState.WAIT) { try { if (countJobs() == 0) { state = TerminationState.READY; return true; } } catch (ServiceRegistryException ex) { logger.warn("Can't determine number of running Jobs, setting Termination State to READ"); state = TerminationState.READY; return true; } } else if (state == TerminationState.READY) { return true; } return false; }  @Override void setState(TerminationState state); @Override TerminationState getState(); void setServiceRegistry(ServiceRegistry service);  }