### Question:
GWeather extends Observable<GWeather, Race, WeatherType> { public void timePasses() { var enumValues = WeatherType.values(); currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length]; LOGGER.info("The weather changed to {}.", currentWeather); notifyObservers(currentWeather); } GWeather(); void timePasses();  }### Answer:
@Test public void testAddRemoveObserver() { final var observer = mock(Race.class); final var weather = new GWeather(); weather.addObserver(observer); verifyZeroInteractions(observer); weather.timePasses(); assertEquals("The weather changed to rainy.", appender.getLastMessage()); verify(observer).update(weather, WeatherType.RAINY); weather.removeObserver(observer); weather.timePasses(); assertEquals("The weather changed to windy.", appender.getLastMessage()); verifyNoMoreInteractions(observer); assertEquals(2, appender.getLogSize()); }
@Test public void testTimePasses() { final var observer = mock(Race.class); final var weather = new GWeather(); weather.addObserver(observer); final var inOrder = inOrder(observer); final var weatherTypes = WeatherType.values(); for (var i = 1; i < 20; i++) { weather.timePasses(); inOrder.verify(observer).update(weather, weatherTypes[i % weatherTypes.length]); } verifyNoMoreInteractions(observer); }