Java 11 migrate remaining p (#1122)
* Moves partial-response to Java 11 * Moves pipeline to Java 11 * Moves poison-pill to Java 11 * Moves priority-queue to Java 11 * Moves private-class-data to Java 11 * Moves producer-consumer to Java 11 * Moves promise to Java 11 * Moves property to Java 11 * Moves prototype to Java 11 * Moves proxy to Java 11 * Corrects checkstyle errors * Fixes build for pipeline pattern
This commit is contained in:
committed by
Ilkka Seppälä
parent
1401accb4f
commit
428efc7d53
@ -100,7 +100,7 @@ public class WizardTowerProxy implements WizardTower {
|
||||
And here is tower entering scenario
|
||||
|
||||
```java
|
||||
WizardTowerProxy proxy = new WizardTowerProxy(new IvoryTower());
|
||||
var proxy = new WizardTowerProxy(new IvoryTower());
|
||||
proxy.enter(new Wizard("Red wizard")); // Red wizard enters the tower.
|
||||
proxy.enter(new Wizard("White wizard")); // White wizard enters the tower.
|
||||
proxy.enter(new Wizard("Black wizard")); // Black wizard enters the tower.
|
||||
|
@ -44,7 +44,7 @@ public class App {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
WizardTowerProxy proxy = new WizardTowerProxy(new IvoryTower());
|
||||
var proxy = new WizardTowerProxy(new IvoryTower());
|
||||
proxy.enter(new Wizard("Red wizard"));
|
||||
proxy.enter(new Wizard("White wizard"));
|
||||
proxy.enter(new Wizard("Black wizard"));
|
||||
|
@ -26,15 +26,12 @@ package com.iluwatar.proxy;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
App.main(new String[]{});
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,15 @@
|
||||
|
||||
package com.iluwatar.proxy;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.iluwatar.proxy.utils.InMemoryAppender;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link IvoryTower}
|
||||
*/
|
||||
@ -49,18 +50,16 @@ public class IvoryTowerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnter() throws Exception {
|
||||
final Wizard[] wizards = new Wizard[]{
|
||||
public void testEnter() {
|
||||
final var wizards = List.of(
|
||||
new Wizard("Gandalf"),
|
||||
new Wizard("Dumbledore"),
|
||||
new Wizard("Oz"),
|
||||
new Wizard("Merlin")
|
||||
};
|
||||
);
|
||||
|
||||
IvoryTower tower = new IvoryTower();
|
||||
for (Wizard wizard : wizards) {
|
||||
tower.enter(wizard);
|
||||
}
|
||||
var tower = new IvoryTower();
|
||||
wizards.forEach(tower::enter);
|
||||
|
||||
assertTrue(appender.logContains("Gandalf enters the tower."));
|
||||
assertTrue(appender.logContains("Dumbledore enters the tower."));
|
||||
|
@ -23,20 +23,19 @@
|
||||
|
||||
package com.iluwatar.proxy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link Wizard}
|
||||
*/
|
||||
public class WizardTest {
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
final String[] wizardNames = {"Gandalf", "Dumbledore", "Oz", "Merlin"};
|
||||
for (String name : wizardNames) {
|
||||
assertEquals(name, new Wizard(name).toString());
|
||||
}
|
||||
public void testToString() {
|
||||
List.of("Gandalf", "Dumbledore", "Oz", "Merlin")
|
||||
.forEach(name -> assertEquals(name, new Wizard(name).toString()));
|
||||
}
|
||||
}
|
@ -23,14 +23,15 @@
|
||||
|
||||
package com.iluwatar.proxy;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.iluwatar.proxy.utils.InMemoryAppender;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link WizardTowerProxy}
|
||||
*/
|
||||
@ -50,17 +51,15 @@ public class WizardTowerProxyTest {
|
||||
|
||||
@Test
|
||||
public void testEnter() throws Exception {
|
||||
final Wizard[] wizards = new Wizard[]{
|
||||
final var wizards = List.of(
|
||||
new Wizard("Gandalf"),
|
||||
new Wizard("Dumbledore"),
|
||||
new Wizard("Oz"),
|
||||
new Wizard("Merlin")
|
||||
};
|
||||
);
|
||||
|
||||
final WizardTowerProxy proxy = new WizardTowerProxy(new IvoryTower());
|
||||
for (Wizard wizard : wizards) {
|
||||
proxy.enter(wizard);
|
||||
}
|
||||
final var proxy = new WizardTowerProxy(new IvoryTower());
|
||||
wizards.forEach(proxy::enter);
|
||||
|
||||
assertTrue(appender.logContains("Gandalf enters the tower."));
|
||||
assertTrue(appender.logContains("Dumbledore enters the tower."));
|
||||
|
@ -26,10 +26,9 @@ package com.iluwatar.proxy.utils;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
@ -54,7 +53,7 @@ public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
}
|
||||
|
||||
public boolean logContains(String message) {
|
||||
return log.stream().anyMatch(event -> event.getFormattedMessage().equals(message));
|
||||
return log.stream().map(ILoggingEvent::getFormattedMessage).anyMatch(message::equals);
|
||||
}
|
||||
|
||||
public int getLogSize() {
|
||||
|
Reference in New Issue
Block a user