Search in sources :

Example 1 with WeatherType

use of com.iluwatar.observer.WeatherType in project java-design-patterns by iluwatar.

the class GWeatherTest method testTimePasses.

/**
 * Verify if the weather passes in the order of the {@link WeatherType}s
 */
@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);
}
Also used : InOrder(org.mockito.InOrder) WeatherType(com.iluwatar.observer.WeatherType) Test(org.junit.jupiter.api.Test)

Aggregations

WeatherType (com.iluwatar.observer.WeatherType)1 Test (org.junit.jupiter.api.Test)1 InOrder (org.mockito.InOrder)1