@Test public void testTimePasses() { final Race observer = mock(Race.class); final GWeather weather = new GWeather(); weather.addObserver(observer); final InOrder inOrder = inOrder(observer); final WeatherType[] weatherTypes = WeatherType.values(); for (int i = 1; i < 20; i++) { weather.timePasses(); inOrder.verify(observer).update(weather, weatherTypes[i % weatherTypes.length]); } verifyNoMoreInteractions(observer); }
public void timePasses() { WeatherType[] enumValues = WeatherType.values(); currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length]; LOGGER.info("The weather changed to {}.", currentWeather); notifyObservers(currentWeather); }
GWeather extends Observable<GWeather, Race, WeatherType> { public void timePasses() { WeatherType[] enumValues = WeatherType.values(); currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length]; LOGGER.info("The weather changed to {}.", currentWeather); notifyObservers(currentWeather); } }
GWeather extends Observable<GWeather, Race, WeatherType> { public void timePasses() { WeatherType[] enumValues = WeatherType.values(); currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length]; LOGGER.info("The weather changed to {}.", currentWeather); notifyObservers(currentWeather); } GWeather(); }
GWeather extends Observable<GWeather, Race, WeatherType> { public void timePasses() { WeatherType[] enumValues = WeatherType.values(); currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length]; LOGGER.info("The weather changed to {}.", currentWeather); notifyObservers(currentWeather); } GWeather(); void timePasses(); }
GWeather extends Observable<GWeather, Race, WeatherType> { public void timePasses() { WeatherType[] enumValues = WeatherType.values(); currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length]; LOGGER.info("The weather changed to {}.", currentWeather); notifyObservers(currentWeather); } GWeather(); void timePasses();  }