Java 11 migrate c-d (remaining) (#1111)

* Moves converter pattern to Java 11

* Moves cqrs pattern to Java 11

* Moves dao pattern to Java 11

* Moves data-bus pattern to Java 11

* Moves data-locality pattern to Java 11

* Moves data-mapper pattern to Java 11

* Moves data-transfer-object pattern to Java 11

* Moves decorator pattern to Java 11

* Moves delegation pattern to Java 11

* Moves dependency-injection to Java 11

* Moves dirty-flag to Java 11

* Moves double-buffer to Java 11

* Moves double-checked-locking to Java 11

* Moves double-dispatch to Java 11

* Corrects with changes thats breaking test cases
This commit is contained in:
Anurag Agarwal
2019-12-15 00:02:45 +05:30
committed by Ilkka Seppälä
parent 5681684157
commit ea57934db6
75 changed files with 576 additions and 713 deletions

View File

@ -98,12 +98,12 @@ Here's the troll in action
```java
// simple troll
Troll troll = new SimpleTroll();
var troll = new SimpleTroll();
troll.attack(); // The troll tries to grab you!
troll.fleeBattle(); // The troll shrieks in horror and runs away!
// change the behavior of the simple troll by adding a decorator
Troll clubbedTroll = new ClubbedTroll(troll);
var clubbedTroll = new ClubbedTroll(troll);
clubbedTroll.attack(); // The troll tries to grab you! The troll swings at you with a club!
clubbedTroll.fleeBattle(); // The troll shrieks in horror and runs away!
```

View File

@ -49,14 +49,14 @@ public class App {
// simple troll
LOGGER.info("A simple looking troll approaches.");
Troll troll = new SimpleTroll();
var troll = new SimpleTroll();
troll.attack();
troll.fleeBattle();
LOGGER.info("Simple troll power {}.\n", troll.getAttackPower());
// change the behavior of the simple troll by adding a decorator
LOGGER.info("A troll with huge club surprises you.");
Troll clubbedTroll = new ClubbedTroll(troll);
var clubbedTroll = new ClubbedTroll(troll);
clubbedTroll.attack();
clubbedTroll.fleeBattle();
LOGGER.info("Clubbed troll power {}.\n", clubbedTroll.getAttackPower());

View File

@ -26,15 +26,12 @@ package com.iluwatar.decorator;
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,14 +23,14 @@
package com.iluwatar.decorator;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.internal.verification.VerificationModeFactory.times;
import org.junit.jupiter.api.Test;
/**
* Tests for {@link ClubbedTroll}
*/
@ -39,10 +39,10 @@ public class ClubbedTrollTest {
@Test
public void testClubbedTroll() {
// Create a normal troll first, but make sure we can spy on it later on.
final Troll simpleTroll = spy(new SimpleTroll());
final var simpleTroll = spy(new SimpleTroll());
// Now we want to decorate the troll to make it stronger ...
final Troll clubbed = new ClubbedTroll(simpleTroll);
final var clubbed = new ClubbedTroll(simpleTroll);
assertEquals(20, clubbed.getAttackPower());
verify(simpleTroll, times(1)).getAttackPower();

View File

@ -23,19 +23,18 @@
package com.iluwatar.decorator;
import static org.junit.jupiter.api.Assertions.assertEquals;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for {@link SimpleTroll}
*/
@ -55,7 +54,7 @@ public class SimpleTrollTest {
@Test
public void testTrollActions() {
final SimpleTroll troll = new SimpleTroll();
final var troll = new SimpleTroll();
assertEquals(10, troll.getAttackPower());
troll.attack();