Java 11 migration: ambassador async-method-invocation balking bridge builder (#1076)

* Moves ambassador pattern to java 11

* Moves async-method-invocation pattern  to java 11

* Moves balking pattern  to java 11

* Moves bridge pattern  to java 11

* Moves builder pattern  to java 11
This commit is contained in:
Anurag Agarwal
2019-11-12 01:17:09 +05:30
committed by Ilkka Seppälä
parent f0f0143d48
commit c4418311c6
27 changed files with 173 additions and 176 deletions

View File

@ -50,13 +50,13 @@ public class App {
*/
public static void main(String[] args) {
LOGGER.info("The knight receives an enchanted sword.");
Sword enchantedSword = new Sword(new SoulEatingEnchantment());
var enchantedSword = new Sword(new SoulEatingEnchantment());
enchantedSword.wield();
enchantedSword.swing();
enchantedSword.unwield();
LOGGER.info("The valkyrie receives an enchanted hammer.");
Hammer hammer = new Hammer(new FlyingEnchantment());
var hammer = new Hammer(new FlyingEnchantment());
hammer.wield();
hammer.swing();
hammer.unwield();

View File

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

View File

@ -23,23 +23,23 @@
package com.iluwatar.bridge;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import org.junit.jupiter.api.Test;
/**
* Tests for hammer
*/
public class HammerTest extends WeaponTest {
class HammerTest extends WeaponTest {
/**
* Invoke all possible actions on the weapon and check if the actions are executed on the actual
* underlying weapon implementation.
*/
@Test
public void testHammer() {
final Hammer hammer = spy(new Hammer(mock(FlyingEnchantment.class)));
void testHammer() {
final var hammer = spy(new Hammer(mock(FlyingEnchantment.class)));
testBasicWeaponActions(hammer);
}
}

View File

@ -23,23 +23,23 @@
package com.iluwatar.bridge;
import org.junit.jupiter.api.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import org.junit.jupiter.api.Test;
/**
* Tests for sword
*/
public class SwordTest extends WeaponTest {
class SwordTest extends WeaponTest {
/**
* Invoke all possible actions on the weapon and check if the actions are executed on the actual
* underlying weapon implementation.
*/
@Test
public void testSword() {
final Sword sword = spy(new Sword(mock(FlyingEnchantment.class)));
void testSword() {
final var sword = spy(new Sword(mock(FlyingEnchantment.class)));
testBasicWeaponActions(sword);
}
}

View File

@ -23,8 +23,6 @@
package com.iluwatar.bridge;
import org.junit.jupiter.api.Disabled;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@ -32,16 +30,15 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
/**
* Base class for weapon tests
*/
public abstract class WeaponTest {
abstract class WeaponTest {
/**
* Invoke the basic actions of the given weapon, and test if the underlying enchantment implementation
* is invoked
*
* Invoke the basic actions of the given weapon, and test if the underlying enchantment
* implementation is invoked
*/
protected final void testBasicWeaponActions(final Weapon weapon) {
final void testBasicWeaponActions(final Weapon weapon) {
assertNotNull(weapon);
Enchantment enchantment = weapon.getEnchantment();
var enchantment = weapon.getEnchantment();
assertNotNull(enchantment);
assertNotNull(weapon.getEnchantment());