* Use java 11 * Use .of - Replace Arrays.asList with List.of - Replace HashSet<>(List.of()) with Set.of * Formatting
This commit is contained in:
@ -23,17 +23,7 @@
|
||||
|
||||
package com.iluwatar.specification.app;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.iluwatar.specification.creature.Creature;
|
||||
import com.iluwatar.specification.creature.Dragon;
|
||||
import com.iluwatar.specification.creature.Goblin;
|
||||
import com.iluwatar.specification.creature.KillerBee;
|
||||
import com.iluwatar.specification.creature.Octopus;
|
||||
import com.iluwatar.specification.creature.Shark;
|
||||
import com.iluwatar.specification.creature.Troll;
|
||||
import com.iluwatar.specification.creature.*;
|
||||
import com.iluwatar.specification.property.Color;
|
||||
import com.iluwatar.specification.property.Movement;
|
||||
import com.iluwatar.specification.selector.ColorSelector;
|
||||
@ -41,6 +31,9 @@ import com.iluwatar.specification.selector.MovementSelector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* The central idea of the Specification pattern is to separate the statement of how to match a
|
||||
@ -64,8 +57,7 @@ public class App {
|
||||
public static void main(String[] args) {
|
||||
// initialize creatures list
|
||||
List<Creature> creatures =
|
||||
Arrays.asList(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(),
|
||||
new KillerBee());
|
||||
List.of(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(), new KillerBee());
|
||||
// find all walking creatures
|
||||
LOGGER.info("Find all walking creatures");
|
||||
List<Creature> walkingCreatures =
|
||||
|
@ -29,8 +29,8 @@ import com.iluwatar.specification.property.Size;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
@ -46,7 +46,7 @@ public class CreatureTest {
|
||||
* @return The tested {@link Creature} instance and its expected specs
|
||||
*/
|
||||
public static Collection<Object[]> dataProvider() {
|
||||
return Arrays.asList(
|
||||
return List.of(
|
||||
new Object[]{new Dragon(), "Dragon", Size.LARGE, Movement.FLYING, Color.RED},
|
||||
new Object[]{new Goblin(), "Goblin", Size.SMALL, Movement.WALKING, Color.GREEN},
|
||||
new Object[]{new KillerBee(), "KillerBee", Size.SMALL, Movement.FLYING, Color.LIGHT},
|
||||
@ -76,15 +76,13 @@ public class CreatureTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetColor(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color) {
|
||||
public void testGetColor(Creature testedCreature, String name, Size size, Movement movement, Color color) {
|
||||
assertEquals(color, testedCreature.getColor());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testToString(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color) {
|
||||
public void testToString(Creature testedCreature, String name, Size size, Movement movement, Color color) {
|
||||
final String toString = testedCreature.toString();
|
||||
assertNotNull(toString);
|
||||
assertEquals(
|
||||
|
Reference in New Issue
Block a user