add java 11 support (o) (#1222)
This commit is contained in:
parent
751b3b9452
commit
845da1fa16
@ -60,7 +60,7 @@ public class King implements Royalty {
|
|||||||
* @param queen Queen which should be flirted.
|
* @param queen Queen which should be flirted.
|
||||||
*/
|
*/
|
||||||
public void flirt(Queen queen) {
|
public void flirt(Queen queen) {
|
||||||
boolean flirtStatus = queen.getFlirted(this);
|
var flirtStatus = queen.getFlirted(this);
|
||||||
if (!flirtStatus) {
|
if (!flirtStatus) {
|
||||||
this.makeUnhappy();
|
this.makeUnhappy();
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +43,7 @@ public final class RoyaltyObjectMother {
|
|||||||
* @return A drunk {@link com.iluwatar.objectmother.King}.
|
* @return A drunk {@link com.iluwatar.objectmother.King}.
|
||||||
*/
|
*/
|
||||||
public static King createDrunkKing() {
|
public static King createDrunkKing() {
|
||||||
King king = new King();
|
var king = new King();
|
||||||
king.makeDrunk();
|
king.makeDrunk();
|
||||||
return king;
|
return king;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ public final class RoyaltyObjectMother {
|
|||||||
* @return A happy {@link com.iluwatar.objectmother.King}.
|
* @return A happy {@link com.iluwatar.objectmother.King}.
|
||||||
*/
|
*/
|
||||||
public static King createHappyKing() {
|
public static King createHappyKing() {
|
||||||
King king = new King();
|
var king = new King();
|
||||||
king.makeHappy();
|
king.makeHappy();
|
||||||
return king;
|
return king;
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ public final class RoyaltyObjectMother {
|
|||||||
* @return A drunk and happy {@link com.iluwatar.objectmother.King}.
|
* @return A drunk and happy {@link com.iluwatar.objectmother.King}.
|
||||||
*/
|
*/
|
||||||
public static King createHappyDrunkKing() {
|
public static King createHappyDrunkKing() {
|
||||||
King king = new King();
|
var king = new King();
|
||||||
king.makeHappy();
|
king.makeHappy();
|
||||||
king.makeDrunk();
|
king.makeDrunk();
|
||||||
return king;
|
return king;
|
||||||
@ -77,7 +77,7 @@ public final class RoyaltyObjectMother {
|
|||||||
* @return A flirty {@link com.iluwatar.objectmother.Queen}.
|
* @return A flirty {@link com.iluwatar.objectmother.Queen}.
|
||||||
*/
|
*/
|
||||||
public static Queen createFlirtyQueen() {
|
public static Queen createFlirtyQueen() {
|
||||||
Queen queen = new Queen();
|
var queen = new Queen();
|
||||||
queen.setFlirtiness(true);
|
queen.setFlirtiness(true);
|
||||||
return queen;
|
return queen;
|
||||||
}
|
}
|
||||||
|
@ -40,50 +40,50 @@ public class RoyaltyObjectMotherTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void unsuccessfulKingFlirt() {
|
public void unsuccessfulKingFlirt() {
|
||||||
King soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
|
var soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
|
||||||
Queen flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
|
var flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
|
||||||
soberUnhappyKing.flirt(flirtyQueen);
|
soberUnhappyKing.flirt(flirtyQueen);
|
||||||
assertFalse(soberUnhappyKing.isHappy());
|
assertFalse(soberUnhappyKing.isHappy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queenIsBlockingFlirtCauseDrunkKing() {
|
public void queenIsBlockingFlirtCauseDrunkKing() {
|
||||||
King drunkUnhappyKing = RoyaltyObjectMother.createDrunkKing();
|
var drunkUnhappyKing = RoyaltyObjectMother.createDrunkKing();
|
||||||
Queen notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
|
var notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
|
||||||
drunkUnhappyKing.flirt(notFlirtyQueen);
|
drunkUnhappyKing.flirt(notFlirtyQueen);
|
||||||
assertFalse(drunkUnhappyKing.isHappy());
|
assertFalse(drunkUnhappyKing.isHappy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queenIsBlockingFlirt() {
|
public void queenIsBlockingFlirt() {
|
||||||
King soberHappyKing = RoyaltyObjectMother.createHappyKing();
|
var soberHappyKing = RoyaltyObjectMother.createHappyKing();
|
||||||
Queen notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
|
var notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
|
||||||
soberHappyKing.flirt(notFlirtyQueen);
|
soberHappyKing.flirt(notFlirtyQueen);
|
||||||
assertFalse(soberHappyKing.isHappy());
|
assertFalse(soberHappyKing.isHappy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void successfullKingFlirt() {
|
public void successfullKingFlirt() {
|
||||||
King soberHappyKing = RoyaltyObjectMother.createHappyKing();
|
var soberHappyKing = RoyaltyObjectMother.createHappyKing();
|
||||||
Queen flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
|
var flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
|
||||||
soberHappyKing.flirt(flirtyQueen);
|
soberHappyKing.flirt(flirtyQueen);
|
||||||
assertTrue(soberHappyKing.isHappy());
|
assertTrue(soberHappyKing.isHappy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testQueenType() {
|
public void testQueenType() {
|
||||||
Royalty flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
|
var flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
|
||||||
Royalty notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
|
var notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
|
||||||
assertEquals(flirtyQueen.getClass(), Queen.class);
|
assertEquals(flirtyQueen.getClass(), Queen.class);
|
||||||
assertEquals(notFlirtyQueen.getClass(), Queen.class);
|
assertEquals(notFlirtyQueen.getClass(), Queen.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKingType() {
|
public void testKingType() {
|
||||||
Royalty drunkKing = RoyaltyObjectMother.createDrunkKing();
|
var drunkKing = RoyaltyObjectMother.createDrunkKing();
|
||||||
Royalty happyDrunkKing = RoyaltyObjectMother.createHappyDrunkKing();
|
var happyDrunkKing = RoyaltyObjectMother.createHappyDrunkKing();
|
||||||
Royalty happyKing = RoyaltyObjectMother.createHappyKing();
|
var happyKing = RoyaltyObjectMother.createHappyKing();
|
||||||
Royalty soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
|
var soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
|
||||||
assertEquals(drunkKing.getClass(), King.class);
|
assertEquals(drunkKing.getClass(), King.class);
|
||||||
assertEquals(happyDrunkKing.getClass(), King.class);
|
assertEquals(happyDrunkKing.getClass(), King.class);
|
||||||
assertEquals(happyKing.getClass(), King.class);
|
assertEquals(happyKing.getClass(), King.class);
|
||||||
|
@ -54,14 +54,14 @@ public class App {
|
|||||||
* @param args command line args
|
* @param args command line args
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
OliphauntPool pool = new OliphauntPool();
|
var pool = new OliphauntPool();
|
||||||
LOGGER.info(pool.toString());
|
LOGGER.info(pool.toString());
|
||||||
Oliphaunt oliphaunt1 = pool.checkOut();
|
var oliphaunt1 = pool.checkOut();
|
||||||
LOGGER.info("Checked out {}", oliphaunt1);
|
LOGGER.info("Checked out {}", oliphaunt1);
|
||||||
LOGGER.info(pool.toString());
|
LOGGER.info(pool.toString());
|
||||||
Oliphaunt oliphaunt2 = pool.checkOut();
|
var oliphaunt2 = pool.checkOut();
|
||||||
LOGGER.info("Checked out {}", oliphaunt2);
|
LOGGER.info("Checked out {}", oliphaunt2);
|
||||||
Oliphaunt oliphaunt3 = pool.checkOut();
|
var oliphaunt3 = pool.checkOut();
|
||||||
LOGGER.info("Checked out {}", oliphaunt3);
|
LOGGER.info("Checked out {}", oliphaunt3);
|
||||||
LOGGER.info(pool.toString());
|
LOGGER.info(pool.toString());
|
||||||
LOGGER.info("Checking in {}", oliphaunt1);
|
LOGGER.info("Checking in {}", oliphaunt1);
|
||||||
@ -69,9 +69,9 @@ public class App {
|
|||||||
LOGGER.info("Checking in {}", oliphaunt2);
|
LOGGER.info("Checking in {}", oliphaunt2);
|
||||||
pool.checkIn(oliphaunt2);
|
pool.checkIn(oliphaunt2);
|
||||||
LOGGER.info(pool.toString());
|
LOGGER.info(pool.toString());
|
||||||
Oliphaunt oliphaunt4 = pool.checkOut();
|
var oliphaunt4 = pool.checkOut();
|
||||||
LOGGER.info("Checked out {}", oliphaunt4);
|
LOGGER.info("Checked out {}", oliphaunt4);
|
||||||
Oliphaunt oliphaunt5 = pool.checkOut();
|
var oliphaunt5 = pool.checkOut();
|
||||||
LOGGER.info("Checked out {}", oliphaunt5);
|
LOGGER.info("Checked out {}", oliphaunt5);
|
||||||
LOGGER.info(pool.toString());
|
LOGGER.info(pool.toString());
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public abstract class ObjectPool<T> {
|
|||||||
if (available.isEmpty()) {
|
if (available.isEmpty()) {
|
||||||
available.add(create());
|
available.add(create());
|
||||||
}
|
}
|
||||||
T instance = available.iterator().next();
|
var instance = available.iterator().next();
|
||||||
available.remove(instance);
|
available.remove(instance);
|
||||||
inUse.add(instance);
|
inUse.add(instance);
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -44,17 +44,17 @@ public class OliphauntPoolTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testSubsequentCheckinCheckout() {
|
public void testSubsequentCheckinCheckout() {
|
||||||
assertTimeout(ofMillis(5000), () -> {
|
assertTimeout(ofMillis(5000), () -> {
|
||||||
final OliphauntPool pool = new OliphauntPool();
|
final var pool = new OliphauntPool();
|
||||||
assertEquals("Pool available=0 inUse=0", pool.toString());
|
assertEquals("Pool available=0 inUse=0", pool.toString());
|
||||||
|
|
||||||
final Oliphaunt expectedOliphaunt = pool.checkOut();
|
final var expectedOliphaunt = pool.checkOut();
|
||||||
assertEquals("Pool available=0 inUse=1", pool.toString());
|
assertEquals("Pool available=0 inUse=1", pool.toString());
|
||||||
|
|
||||||
pool.checkIn(expectedOliphaunt);
|
pool.checkIn(expectedOliphaunt);
|
||||||
assertEquals("Pool available=1 inUse=0", pool.toString());
|
assertEquals("Pool available=1 inUse=0", pool.toString());
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
final Oliphaunt oliphaunt = pool.checkOut();
|
final var oliphaunt = pool.checkOut();
|
||||||
assertEquals("Pool available=0 inUse=1", pool.toString());
|
assertEquals("Pool available=0 inUse=1", pool.toString());
|
||||||
assertSame(expectedOliphaunt, oliphaunt);
|
assertSame(expectedOliphaunt, oliphaunt);
|
||||||
assertEquals(expectedOliphaunt.getId(), oliphaunt.getId());
|
assertEquals(expectedOliphaunt.getId(), oliphaunt.getId());
|
||||||
@ -73,13 +73,13 @@ public class OliphauntPoolTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testConcurrentCheckinCheckout() {
|
public void testConcurrentCheckinCheckout() {
|
||||||
assertTimeout(ofMillis(5000), () -> {
|
assertTimeout(ofMillis(5000), () -> {
|
||||||
final OliphauntPool pool = new OliphauntPool();
|
final var pool = new OliphauntPool();
|
||||||
assertEquals(pool.toString(), "Pool available=0 inUse=0");
|
assertEquals(pool.toString(), "Pool available=0 inUse=0");
|
||||||
|
|
||||||
final Oliphaunt firstOliphaunt = pool.checkOut();
|
final var firstOliphaunt = pool.checkOut();
|
||||||
assertEquals(pool.toString(), "Pool available=0 inUse=1");
|
assertEquals(pool.toString(), "Pool available=0 inUse=1");
|
||||||
|
|
||||||
final Oliphaunt secondOliphaunt = pool.checkOut();
|
final var secondOliphaunt = pool.checkOut();
|
||||||
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
||||||
|
|
||||||
assertNotSame(firstOliphaunt, secondOliphaunt);
|
assertNotSame(firstOliphaunt, secondOliphaunt);
|
||||||
@ -89,7 +89,7 @@ public class OliphauntPoolTest {
|
|||||||
pool.checkIn(secondOliphaunt);
|
pool.checkIn(secondOliphaunt);
|
||||||
assertEquals(pool.toString(), "Pool available=1 inUse=1");
|
assertEquals(pool.toString(), "Pool available=1 inUse=1");
|
||||||
|
|
||||||
final Oliphaunt oliphaunt3 = pool.checkOut();
|
final var oliphaunt3 = pool.checkOut();
|
||||||
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
||||||
assertSame(secondOliphaunt, oliphaunt3);
|
assertSame(secondOliphaunt, oliphaunt3);
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class OliphauntPoolTest {
|
|||||||
pool.checkIn(firstOliphaunt);
|
pool.checkIn(firstOliphaunt);
|
||||||
assertEquals(pool.toString(), "Pool available=1 inUse=1");
|
assertEquals(pool.toString(), "Pool available=1 inUse=1");
|
||||||
|
|
||||||
final Oliphaunt oliphaunt4 = pool.checkOut();
|
final var oliphaunt4 = pool.checkOut();
|
||||||
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
||||||
assertSame(firstOliphaunt, oliphaunt4);
|
assertSame(firstOliphaunt, oliphaunt4);
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ public class OliphauntPoolTest {
|
|||||||
|
|
||||||
// The order of the returned instances is not determined, so just put them in a list
|
// The order of the returned instances is not determined, so just put them in a list
|
||||||
// and verify if both expected instances are in there.
|
// and verify if both expected instances are in there.
|
||||||
final List<Oliphaunt> oliphaunts = List.of(pool.checkOut(), pool.checkOut());
|
final var oliphaunts = List.of(pool.checkOut(), pool.checkOut());
|
||||||
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
||||||
assertTrue(oliphaunts.contains(firstOliphaunt));
|
assertTrue(oliphaunts.contains(firstOliphaunt));
|
||||||
assertTrue(oliphaunts.contains(secondOliphaunt));
|
assertTrue(oliphaunts.contains(secondOliphaunt));
|
||||||
|
@ -51,7 +51,7 @@ public class App {
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
Weather weather = new Weather();
|
var weather = new Weather();
|
||||||
weather.addObserver(new Orcs());
|
weather.addObserver(new Orcs());
|
||||||
weather.addObserver(new Hobbits());
|
weather.addObserver(new Hobbits());
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class App {
|
|||||||
|
|
||||||
// Generic observer inspired by Java Generics and Collection by Naftalin & Wadler
|
// Generic observer inspired by Java Generics and Collection by Naftalin & Wadler
|
||||||
LOGGER.info("--Running generic version--");
|
LOGGER.info("--Running generic version--");
|
||||||
GWeather genericWeather = new GWeather();
|
var genericWeather = new GWeather();
|
||||||
genericWeather.addObserver(new GOrcs());
|
genericWeather.addObserver(new GOrcs());
|
||||||
genericWeather.addObserver(new GHobbits());
|
genericWeather.addObserver(new GHobbits());
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@ public class Weather {
|
|||||||
* Makes time pass for weather.
|
* Makes time pass for weather.
|
||||||
*/
|
*/
|
||||||
public void timePasses() {
|
public void timePasses() {
|
||||||
WeatherType[] enumValues = WeatherType.values();
|
var enumValues = WeatherType.values();
|
||||||
currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length];
|
currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length];
|
||||||
LOGGER.info("The weather changed to {}.", currentWeather);
|
LOGGER.info("The weather changed to {}.", currentWeather);
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyObservers() {
|
private void notifyObservers() {
|
||||||
for (WeatherObserver obs : observers) {
|
for (var obs : observers) {
|
||||||
obs.update(currentWeather);
|
obs.update(currentWeather);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class GWeather extends Observable<GWeather, Race, WeatherType> {
|
|||||||
* Makes time pass for weather.
|
* Makes time pass for weather.
|
||||||
*/
|
*/
|
||||||
public void timePasses() {
|
public void timePasses() {
|
||||||
WeatherType[] enumValues = WeatherType.values();
|
var enumValues = WeatherType.values();
|
||||||
currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length];
|
currentWeather = enumValues[(currentWeather.ordinal() + 1) % enumValues.length];
|
||||||
LOGGER.info("The weather changed to {}.", currentWeather);
|
LOGGER.info("The weather changed to {}.", currentWeather);
|
||||||
notifyObservers(currentWeather);
|
notifyObservers(currentWeather);
|
||||||
|
@ -54,7 +54,7 @@ public abstract class Observable<S extends Observable<S, O, A>, O extends Observ
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void notifyObservers(A argument) {
|
public void notifyObservers(A argument) {
|
||||||
for (O observer : observers) {
|
for (var observer : observers) {
|
||||||
observer.update((S) this, argument);
|
observer.update((S) this, argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public abstract class WeatherObserverTest<O extends WeatherObserver> {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("dataProvider")
|
@MethodSource("dataProvider")
|
||||||
public void testObserver(WeatherType weather, String response) {
|
public void testObserver(WeatherType weather, String response) {
|
||||||
final O observer = this.factory.get();
|
final var observer = this.factory.get();
|
||||||
assertEquals(0, appender.getLogSize());
|
assertEquals(0, appender.getLogSize());
|
||||||
|
|
||||||
observer.update(weather);
|
observer.update(weather);
|
||||||
|
@ -61,9 +61,9 @@ public class WeatherTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAddRemoveObserver() {
|
public void testAddRemoveObserver() {
|
||||||
final WeatherObserver observer = mock(WeatherObserver.class);
|
final var observer = mock(WeatherObserver.class);
|
||||||
|
|
||||||
final Weather weather = new Weather();
|
final var weather = new Weather();
|
||||||
weather.addObserver(observer);
|
weather.addObserver(observer);
|
||||||
verifyZeroInteractions(observer);
|
verifyZeroInteractions(observer);
|
||||||
|
|
||||||
@ -84,13 +84,13 @@ public class WeatherTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testTimePasses() {
|
public void testTimePasses() {
|
||||||
final WeatherObserver observer = mock(WeatherObserver.class);
|
final var observer = mock(WeatherObserver.class);
|
||||||
final Weather weather = new Weather();
|
final var weather = new Weather();
|
||||||
weather.addObserver(observer);
|
weather.addObserver(observer);
|
||||||
|
|
||||||
final InOrder inOrder = inOrder(observer);
|
final var inOrder = inOrder(observer);
|
||||||
final WeatherType[] weatherTypes = WeatherType.values();
|
final var weatherTypes = WeatherType.values();
|
||||||
for (int i = 1; i < 20; i++) {
|
for (var i = 1; i < 20; i++) {
|
||||||
weather.timePasses();
|
weather.timePasses();
|
||||||
inOrder.verify(observer).update(weatherTypes[i % weatherTypes.length]);
|
inOrder.verify(observer).update(weatherTypes[i % weatherTypes.length]);
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,9 @@ public class GWeatherTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAddRemoveObserver() {
|
public void testAddRemoveObserver() {
|
||||||
final Race observer = mock(Race.class);
|
final var observer = mock(Race.class);
|
||||||
|
|
||||||
final GWeather weather = new GWeather();
|
final var weather = new GWeather();
|
||||||
weather.addObserver(observer);
|
weather.addObserver(observer);
|
||||||
verifyZeroInteractions(observer);
|
verifyZeroInteractions(observer);
|
||||||
|
|
||||||
@ -82,13 +82,13 @@ public class GWeatherTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testTimePasses() {
|
public void testTimePasses() {
|
||||||
final Race observer = mock(Race.class);
|
final var observer = mock(Race.class);
|
||||||
final GWeather weather = new GWeather();
|
final var weather = new GWeather();
|
||||||
weather.addObserver(observer);
|
weather.addObserver(observer);
|
||||||
|
|
||||||
final InOrder inOrder = inOrder(observer);
|
final var inOrder = inOrder(observer);
|
||||||
final WeatherType[] weatherTypes = WeatherType.values();
|
final var weatherTypes = WeatherType.values();
|
||||||
for (int i = 1; i < 20; i++) {
|
for (var i = 1; i < 20; i++) {
|
||||||
weather.timePasses();
|
weather.timePasses();
|
||||||
inOrder.verify(observer).update(weather, weatherTypes[i % weatherTypes.length]);
|
inOrder.verify(observer).update(weather, weatherTypes[i % weatherTypes.length]);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public abstract class ObserverTest<O extends Observer<?, ?, WeatherType>> {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("dataProvider")
|
@MethodSource("dataProvider")
|
||||||
public void testObserver(WeatherType weather, String response) {
|
public void testObserver(WeatherType weather, String response) {
|
||||||
final O observer = this.factory.get();
|
final var observer = this.factory.get();
|
||||||
assertEquals(0, appender.getLogSize());
|
assertEquals(0, appender.getLogSize());
|
||||||
|
|
||||||
observer.update(null, weather);
|
observer.update(null, weather);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user