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:
committed by
Ilkka Seppälä
parent
f0f0143d48
commit
c4418311c6
@ -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();
|
||||
|
@ -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[]{});
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
||||
|
Reference in New Issue
Block a user