mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-18 09:25:54 +00:00
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
@@ -26,15 +26,12 @@ package com.iluwatar.property;
|
||||
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.property;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static com.iluwatar.property.Character.Type;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/28/15 - 7:46 PM
|
||||
*
|
||||
@@ -40,13 +41,13 @@ public class CharacterTest {
|
||||
|
||||
@Test
|
||||
public void testPrototypeStats() throws Exception {
|
||||
final Character prototype = new Character();
|
||||
final var prototype = new Character();
|
||||
|
||||
for (final Stats stat : Stats.values()) {
|
||||
for (final var stat : Stats.values()) {
|
||||
assertFalse(prototype.has(stat));
|
||||
assertNull(prototype.get(stat));
|
||||
|
||||
final Integer expectedValue = stat.ordinal();
|
||||
final var expectedValue = stat.ordinal();
|
||||
prototype.set(stat, expectedValue);
|
||||
assertTrue(prototype.has(stat));
|
||||
assertEquals(expectedValue, prototype.get(stat));
|
||||
@@ -59,15 +60,13 @@ public class CharacterTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCharacterStats() throws Exception {
|
||||
final Character prototype = new Character();
|
||||
for (final Stats stat : Stats.values()) {
|
||||
prototype.set(stat, stat.ordinal());
|
||||
}
|
||||
public void testCharacterStats() {
|
||||
final var prototype = new Character();
|
||||
Arrays.stream(Stats.values()).forEach(stat -> prototype.set(stat, stat.ordinal()));
|
||||
|
||||
final Character mage = new Character(Type.MAGE, prototype);
|
||||
for (final Stats stat : Stats.values()) {
|
||||
final Integer expectedValue = stat.ordinal();
|
||||
final var mage = new Character(Type.MAGE, prototype);
|
||||
for (final var stat : Stats.values()) {
|
||||
final var expectedValue = stat.ordinal();
|
||||
assertTrue(mage.has(stat));
|
||||
assertEquals(expectedValue, mage.get(stat));
|
||||
}
|
||||
@@ -75,17 +74,17 @@ public class CharacterTest {
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
final Character prototype = new Character();
|
||||
final var prototype = new Character();
|
||||
prototype.set(Stats.ARMOR, 1);
|
||||
prototype.set(Stats.AGILITY, 2);
|
||||
prototype.set(Stats.INTELLECT, 3);
|
||||
assertEquals("Stats:\n - AGILITY:2\n - ARMOR:1\n - INTELLECT:3\n", prototype.toString());
|
||||
|
||||
final Character stupid = new Character(Type.ROGUE, prototype);
|
||||
final var stupid = new Character(Type.ROGUE, prototype);
|
||||
stupid.remove(Stats.INTELLECT);
|
||||
assertEquals("Character type: ROGUE\nStats:\n - AGILITY:2\n - ARMOR:1\n", stupid.toString());
|
||||
|
||||
final Character weak = new Character("weak", prototype);
|
||||
final var weak = new Character("weak", prototype);
|
||||
weak.remove(Stats.ARMOR);
|
||||
assertEquals("Player: weak\nStats:\n - AGILITY:2\n - INTELLECT:3\n", weak.toString());
|
||||
|
||||
@@ -93,32 +92,32 @@ public class CharacterTest {
|
||||
|
||||
@Test
|
||||
public void testName() {
|
||||
final Character prototype = new Character();
|
||||
final var prototype = new Character();
|
||||
prototype.set(Stats.ARMOR, 1);
|
||||
prototype.set(Stats.INTELLECT, 2);
|
||||
assertNull(prototype.name());
|
||||
|
||||
final Character stupid = new Character(Type.ROGUE, prototype);
|
||||
final var stupid = new Character(Type.ROGUE, prototype);
|
||||
stupid.remove(Stats.INTELLECT);
|
||||
assertNull(stupid.name());
|
||||
|
||||
final Character weak = new Character("weak", prototype);
|
||||
final var weak = new Character("weak", prototype);
|
||||
weak.remove(Stats.ARMOR);
|
||||
assertEquals("weak", weak.name());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testType() {
|
||||
final Character prototype = new Character();
|
||||
final var prototype = new Character();
|
||||
prototype.set(Stats.ARMOR, 1);
|
||||
prototype.set(Stats.INTELLECT, 2);
|
||||
assertNull(prototype.type());
|
||||
|
||||
final Character stupid = new Character(Type.ROGUE, prototype);
|
||||
final var stupid = new Character(Type.ROGUE, prototype);
|
||||
stupid.remove(Stats.INTELLECT);
|
||||
assertEquals(Type.ROGUE, stupid.type());
|
||||
|
||||
final Character weak = new Character("weak", prototype);
|
||||
final var weak = new Character("weak", prototype);
|
||||
weak.remove(Stats.ARMOR);
|
||||
assertNull(weak.type());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user