Java 11 migration: patterns (remaining b-c) (#1081)

* Moves business-delegate pattern  to java 11

* Moves bytecode pattern  to java 11

* Moves caching pattern  to java 11

* Moves callback pattern  to java 11

* Moves chain pattern  to java 11

* Moves circuit-breaker pattern  to java 11

* Moves collection-pipeline pattern  to java 11

* Moves command pattern  to java 11

* Moves commander pattern  to java 11

* Moves composite pattern  to java 11

* Corrects test cases
This commit is contained in:
Anurag Agarwal
2019-11-13 01:26:46 +05:30
committed by Ilkka Seppälä
parent 6ef840f3cf
commit 33ea7335b1
63 changed files with 798 additions and 979 deletions

View File

@ -43,7 +43,7 @@ public class App {
*/
public static void main(String[] args) {
OrcKing king = new OrcKing();
var king = new OrcKing();
king.makeRequest(new Request(RequestType.DEFEND_CASTLE, "defend castle"));
king.makeRequest(new Request(RequestType.TORTURE_PRISONER, "torture prisoner"));
king.makeRequest(new Request(RequestType.COLLECT_TAX, "collect tax"));

View File

@ -28,7 +28,7 @@ package com.iluwatar.chain;
*/
public class OrcKing {
RequestHandler chain;
private RequestHandler chain;
public OrcKing() {
buildChain();

View File

@ -26,15 +26,12 @@ package com.iluwatar.chain;
import org.junit.jupiter.api.Test;
/**
*
* Application test
*
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
App.main(new String[]{});
}
}

View File

@ -23,10 +23,11 @@
package com.iluwatar.chain;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.junit.jupiter.api.Test;
/**
* Date: 12/6/15 - 9:29 PM
*
@ -37,24 +38,23 @@ public class OrcKingTest {
/**
* All possible requests
*/
private static final Request[] REQUESTS = new Request[]{
private static final List<Request> REQUESTS = List.of(
new Request(RequestType.DEFEND_CASTLE, "Don't let the barbarians enter my castle!!"),
new Request(RequestType.TORTURE_PRISONER, "Don't just stand there, tickle him!"),
new Request(RequestType.COLLECT_TAX, "Don't steal, the King hates competition ..."),
};
new Request(RequestType.COLLECT_TAX, "Don't steal, the King hates competition ...")
);
@Test
public void testMakeRequest() {
final OrcKing king = new OrcKing();
final var king = new OrcKing();
for (final Request request : REQUESTS) {
REQUESTS.forEach(request -> {
king.makeRequest(request);
assertTrue(
request.isHandled(),
"Expected all requests from King to be handled, but [" + request + "] was not!"
);
}
});
}
}