Add java 11 (#1048)
This commit is contained in:
parent
b50189e283
commit
63fb8dc318
@ -23,14 +23,13 @@
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.iluwatar.abstractdocument.domain.Car;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.iluwatar.abstractdocument.domain.Car;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The Abstract Document pattern enables handling additional, non-static
|
||||
@ -52,21 +51,20 @@ public class App {
|
||||
public App() {
|
||||
LOGGER.info("Constructing parts and car");
|
||||
|
||||
var carProperties = new HashMap<String, Object>();
|
||||
carProperties.put(Property.MODEL.toString(), "300SL");
|
||||
carProperties.put(Property.PRICE.toString(), 10000L);
|
||||
var wheelProperties = Map.of(
|
||||
Property.TYPE.toString(), "wheel",
|
||||
Property.MODEL.toString(), "15C",
|
||||
Property.PRICE.toString(), 100L);
|
||||
|
||||
var wheelProperties = new HashMap<String, Object>();
|
||||
wheelProperties.put(Property.TYPE.toString(), "wheel");
|
||||
wheelProperties.put(Property.MODEL.toString(), "15C");
|
||||
wheelProperties.put(Property.PRICE.toString(), 100L);
|
||||
var doorProperties = Map.of(
|
||||
Property.TYPE.toString(), "door",
|
||||
Property.MODEL.toString(), "Lambo",
|
||||
Property.PRICE.toString(), 300L);
|
||||
|
||||
var doorProperties = new HashMap<String, Object>();
|
||||
doorProperties.put(Property.TYPE.toString(), "door");
|
||||
doorProperties.put(Property.MODEL.toString(), "Lambo");
|
||||
doorProperties.put(Property.PRICE.toString(), 300L);
|
||||
|
||||
carProperties.put(Property.PARTS.toString(), Arrays.asList(wheelProperties, doorProperties));
|
||||
var carProperties = Map.of(
|
||||
Property.MODEL.toString(), "300SL",
|
||||
Property.PRICE.toString(), 10000L,
|
||||
Property.PARTS.toString(), List.of(wheelProperties, doorProperties));
|
||||
|
||||
var car = new Car(carProperties);
|
||||
|
||||
|
@ -31,9 +31,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* AbstractDocument test class
|
||||
@ -60,9 +58,7 @@ public class AbstractDocumentTest {
|
||||
|
||||
@Test
|
||||
public void shouldRetrieveChildren() {
|
||||
Map<String, Object> child1 = new HashMap<>();
|
||||
Map<String, Object> child2 = new HashMap<>();
|
||||
List<Map<String, Object>> children = Arrays.asList(child1, child2);
|
||||
var children = List.of(Map.of(), Map.of());
|
||||
|
||||
document.put(KEY, children);
|
||||
|
||||
@ -80,8 +76,7 @@ public class AbstractDocumentTest {
|
||||
|
||||
@Test
|
||||
public void shouldIncludePropsInToString() {
|
||||
Map<String, Object> props = new HashMap<>();
|
||||
props.put(KEY, VALUE);
|
||||
Map<String, Object> props = Map.of(KEY, VALUE);
|
||||
DocumentImplementation document = new DocumentImplementation(props);
|
||||
assertTrue(document.toString().contains(KEY));
|
||||
assertTrue(document.toString().contains(VALUE));
|
||||
|
@ -23,17 +23,16 @@
|
||||
|
||||
package com.iluwatar.abstractdocument;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.abstractdocument.domain.Car;
|
||||
import com.iluwatar.abstractdocument.domain.Part;
|
||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Test for Part and Car
|
||||
@ -49,10 +48,10 @@ public class DomainTest {
|
||||
|
||||
@Test
|
||||
public void shouldConstructPart() {
|
||||
Map<String, Object> partProperties = new HashMap<>();
|
||||
partProperties.put(Property.TYPE.toString(), TEST_PART_TYPE);
|
||||
partProperties.put(Property.MODEL.toString(), TEST_PART_MODEL);
|
||||
partProperties.put(Property.PRICE.toString(), TEST_PART_PRICE);
|
||||
Map<String, Object> partProperties = Map.of(
|
||||
Property.TYPE.toString(), TEST_PART_TYPE,
|
||||
Property.MODEL.toString(), TEST_PART_MODEL,
|
||||
Property.PRICE.toString(), TEST_PART_PRICE);
|
||||
Part part = new Part(partProperties);
|
||||
|
||||
assertEquals(TEST_PART_TYPE, part.getType().get());
|
||||
@ -62,10 +61,10 @@ public class DomainTest {
|
||||
|
||||
@Test
|
||||
public void shouldConstructCar() {
|
||||
Map<String, Object> carProperties = new HashMap<>();
|
||||
carProperties.put(Property.MODEL.toString(), TEST_CAR_MODEL);
|
||||
carProperties.put(Property.PRICE.toString(), TEST_CAR_PRICE);
|
||||
carProperties.put(Property.PARTS.toString(), Arrays.asList(new HashMap<>(), new HashMap<>()));
|
||||
Map<String, Object> carProperties = Map.of(
|
||||
Property.MODEL.toString(), TEST_CAR_MODEL,
|
||||
Property.PRICE.toString(), TEST_CAR_PRICE,
|
||||
Property.PARTS.toString(), List.of(new HashMap<>(), new HashMap<>()));
|
||||
Car car = new Car(carProperties);
|
||||
|
||||
assertEquals(TEST_CAR_MODEL, car.getModel().get());
|
||||
|
@ -23,17 +23,15 @@
|
||||
|
||||
package com.iluwatar.collectionpipeline;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests that Collection Pipeline methods work as expected.
|
||||
*/
|
||||
@ -44,27 +42,27 @@ public class AppTest {
|
||||
|
||||
@Test
|
||||
public void testGetModelsAfter2000UsingFor() {
|
||||
List<String> models = ImperativeProgramming.getModelsAfter2000(cars);
|
||||
assertEquals(Arrays.asList("Avenger", "Wrangler", "Focus", "Cascada"), models);
|
||||
var models = ImperativeProgramming.getModelsAfter2000(cars);
|
||||
assertEquals(List.of("Avenger", "Wrangler", "Focus", "Cascada"), models);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetModelsAfter2000UsingPipeline() {
|
||||
List<String> models = FunctionalProgramming.getModelsAfter2000(cars);
|
||||
assertEquals(Arrays.asList("Avenger", "Wrangler", "Focus", "Cascada"), models);
|
||||
var models = FunctionalProgramming.getModelsAfter2000(cars);
|
||||
assertEquals(List.of("Avenger", "Wrangler", "Focus", "Cascada"), models);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGroupingOfCarsByCategory() {
|
||||
Map<Category, List<Car>> modelsExpected = new HashMap<>();
|
||||
modelsExpected.put(Category.CONVERTIBLE, Arrays.asList(new Car("Buick", "Cascada", 2016, Category.CONVERTIBLE),
|
||||
new Car("Chevrolet", "Geo Metro", 1992, Category.CONVERTIBLE)));
|
||||
modelsExpected.put(Category.SEDAN, Arrays.asList(new Car("Dodge", "Avenger", 2010, Category.SEDAN),
|
||||
new Car("Ford", "Focus", 2012, Category.SEDAN)));
|
||||
modelsExpected.put(Category.JEEP, Arrays.asList(new Car("Jeep", "Wrangler", 2011, Category.JEEP),
|
||||
new Car("Jeep", "Comanche", 1990, Category.JEEP)));
|
||||
Map<Category, List<Car>> modelsFunctional = FunctionalProgramming.getGroupingOfCarsByCategory(cars);
|
||||
Map<Category, List<Car>> modelsImperative = ImperativeProgramming.getGroupingOfCarsByCategory(cars);
|
||||
var modelsExpected = Map.of(
|
||||
Category.CONVERTIBLE, List.of(new Car("Buick", "Cascada", 2016, Category.CONVERTIBLE),
|
||||
new Car("Chevrolet", "Geo Metro", 1992, Category.CONVERTIBLE)),
|
||||
Category.SEDAN, List.of(new Car("Dodge", "Avenger", 2010, Category.SEDAN),
|
||||
new Car("Ford", "Focus", 2012, Category.SEDAN)),
|
||||
Category.JEEP, List.of(new Car("Jeep", "Wrangler", 2011, Category.JEEP),
|
||||
new Car("Jeep", "Comanche", 1990, Category.JEEP)));
|
||||
var modelsFunctional = FunctionalProgramming.getGroupingOfCarsByCategory(cars);
|
||||
var modelsImperative = ImperativeProgramming.getGroupingOfCarsByCategory(cars);
|
||||
LOGGER.info("Category " + modelsFunctional);
|
||||
assertEquals(modelsExpected, modelsFunctional);
|
||||
assertEquals(modelsExpected, modelsImperative);
|
||||
@ -72,11 +70,11 @@ public class AppTest {
|
||||
|
||||
@Test
|
||||
public void testGetSedanCarsOwnedSortedByDate() {
|
||||
Person john = new Person(cars);
|
||||
List<Car> modelsExpected = Arrays.asList(new Car("Dodge", "Avenger", 2010, Category.SEDAN),
|
||||
var john = new Person(cars);
|
||||
var modelsExpected = List.of(new Car("Dodge", "Avenger", 2010, Category.SEDAN),
|
||||
new Car("Ford", "Focus", 2012, Category.SEDAN));
|
||||
List<Car> modelsFunctional = FunctionalProgramming.getSedanCarsOwnedSortedByDate(Arrays.asList(john));
|
||||
List<Car> modelsImperative = ImperativeProgramming.getSedanCarsOwnedSortedByDate(Arrays.asList(john));
|
||||
var modelsFunctional = FunctionalProgramming.getSedanCarsOwnedSortedByDate(List.of(john));
|
||||
var modelsImperative = ImperativeProgramming.getSedanCarsOwnedSortedByDate(List.of(john));
|
||||
assertEquals(modelsExpected, modelsFunctional);
|
||||
assertEquals(modelsExpected, modelsImperative);
|
||||
}
|
||||
|
@ -23,10 +23,8 @@
|
||||
|
||||
package com.iluwatar.commander;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
|
||||
import com.iluwatar.commander.exceptions.DatabaseUnavailableException;
|
||||
|
||||
/**
|
||||
@ -49,7 +47,7 @@ public abstract class Service {
|
||||
|
||||
protected Service(Database db, Exception...exc) {
|
||||
this.database = db;
|
||||
this.exceptionsList = new ArrayList<Exception>(Arrays.asList(exc));
|
||||
this.exceptionsList = new ArrayList<>(List.of(exc));
|
||||
}
|
||||
|
||||
public abstract String receiveRequest(Object...parameters) throws DatabaseUnavailableException;
|
||||
|
@ -23,12 +23,13 @@
|
||||
|
||||
package com.iluwatar.commander.queue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import com.iluwatar.commander.Database;
|
||||
import com.iluwatar.commander.exceptions.DatabaseUnavailableException;
|
||||
import com.iluwatar.commander.exceptions.IsEmptyException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* QueueDatabase id where the instructions to be implemented are queued.
|
||||
*/
|
||||
@ -39,8 +40,8 @@ public class QueueDatabase extends Database<QueueTask> {
|
||||
public ArrayList<Exception> exceptionsList;
|
||||
|
||||
public QueueDatabase(Exception...exc) {
|
||||
this.data = new Queue<QueueTask>();
|
||||
this.exceptionsList = new ArrayList<Exception>(Arrays.asList(exc));
|
||||
this.data = new Queue<>();
|
||||
this.exceptionsList = new ArrayList<>(List.of(exc));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,18 +23,14 @@
|
||||
|
||||
package com.iluwatar.commander;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.iluwatar.commander.Order;
|
||||
import com.iluwatar.commander.Retry;
|
||||
import com.iluwatar.commander.User;
|
||||
import com.iluwatar.commander.Retry.HandleErrorIssue;
|
||||
import com.iluwatar.commander.Retry.Operation;
|
||||
import com.iluwatar.commander.exceptions.DatabaseUnavailableException;
|
||||
import com.iluwatar.commander.exceptions.ItemUnavailableException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class RetryTest {
|
||||
|
||||
@ -55,15 +51,15 @@ class RetryTest {
|
||||
e -> DatabaseUnavailableException.class.isAssignableFrom(e.getClass()));
|
||||
User user = new User("Jim", "ABCD");
|
||||
Order order = new Order(user, "book", 10f);
|
||||
ArrayList<Exception> arr1 = new ArrayList<Exception>(Arrays.asList(new Exception[]
|
||||
{new ItemUnavailableException(), new DatabaseUnavailableException()}));
|
||||
ArrayList<Exception> arr1 = new ArrayList<>(List.of(
|
||||
new ItemUnavailableException(), new DatabaseUnavailableException()));
|
||||
try {
|
||||
r1.perform(arr1, order);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
ArrayList<Exception> arr2 = new ArrayList<Exception>(Arrays.asList(new Exception[]
|
||||
{new DatabaseUnavailableException(), new ItemUnavailableException()}));
|
||||
ArrayList<Exception> arr2 = new ArrayList<>(List.of(
|
||||
new DatabaseUnavailableException(), new ItemUnavailableException()));
|
||||
try {
|
||||
r2.perform(arr2, order);
|
||||
} catch (Exception e1) {
|
||||
|
@ -94,27 +94,27 @@ Then we have a messenger to carry messages
|
||||
```java
|
||||
public class Messenger {
|
||||
LetterComposite messageFromOrcs() {
|
||||
List<Word> words = new ArrayList<>();
|
||||
words.add(new Word(Arrays.asList(new Letter('W'), new Letter('h'), new Letter('e'), new Letter('r'), new Letter('e'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('t'), new Letter('h'), new Letter('e'), new Letter('r'), new Letter('e'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('i'), new Letter('s'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('a'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('w'), new Letter('h'), new Letter('i'), new Letter('p'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('t'), new Letter('h'), new Letter('e'), new Letter('r'), new Letter('e'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('i'), new Letter('s'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('a'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('w'), new Letter('a'), new Letter('y'))));
|
||||
List<Word> words = List.of(
|
||||
new Word(List.of(new Letter('W'), new Letter('h'), new Letter('e'), new Letter('r'), new Letter('e'))),
|
||||
new Word(List.of(new Letter('t'), new Letter('h'), new Letter('e'), new Letter('r'), new Letter('e'))),
|
||||
new Word(List.of(new Letter('i'), new Letter('s'))),
|
||||
new Word(List.of(new Letter('a'))),
|
||||
new Word(List.of(new Letter('w'), new Letter('h'), new Letter('i'), new Letter('p'))),
|
||||
new Word(List.of(new Letter('t'), new Letter('h'), new Letter('e'), new Letter('r'), new Letter('e'))),
|
||||
new Word(List.of(new Letter('i'), new Letter('s'))),
|
||||
new Word(List.of(new Letter('a'))),
|
||||
new Word(List.of(new Letter('w'), new Letter('a'), new Letter('y'))));
|
||||
return new Sentence(words);
|
||||
}
|
||||
|
||||
LetterComposite messageFromElves() {
|
||||
List<Word> words = new ArrayList<>();
|
||||
words.add(new Word(Arrays.asList(new Letter('M'), new Letter('u'), new Letter('c'), new Letter('h'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('w'), new Letter('i'), new Letter('n'), new Letter('d'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('p'), new Letter('o'), new Letter('u'), new Letter('r'), new Letter('s'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('f'), new Letter('r'), new Letter('o'), new Letter('m'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('y'), new Letter('o'), new Letter('u'), new Letter('r'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('m'), new Letter('o'), new Letter('u'), new Letter('t'), new Letter('h'))));
|
||||
List<Word> words = List.of(
|
||||
new Word(List.of(new Letter('M'), new Letter('u'), new Letter('c'), new Letter('h'))),
|
||||
new Word(List.of(new Letter('w'), new Letter('i'), new Letter('n'), new Letter('d'))),
|
||||
new Word(List.of(new Letter('p'), new Letter('o'), new Letter('u'), new Letter('r'), new Letter('s'))),
|
||||
new Word(List.of(new Letter('f'), new Letter('r'), new Letter('o'), new Letter('m'))),
|
||||
new Word(List.of(new Letter('y'), new Letter('o'), new Letter('u'), new Letter('r'))),
|
||||
new Word(List.of(new Letter('m'), new Letter('o'), new Letter('u'), new Letter('t'), new Letter('h'))));
|
||||
return new Sentence(words);
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
package com.iluwatar.composite;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -36,21 +34,20 @@ public class Messenger {
|
||||
|
||||
LetterComposite messageFromOrcs() {
|
||||
|
||||
List<Word> words = new ArrayList<>();
|
||||
|
||||
words.add(new Word(Arrays.asList(new Letter('W'), new Letter('h'), new Letter('e'), new Letter(
|
||||
'r'), new Letter('e'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('t'), new Letter('h'), new Letter('e'), new Letter(
|
||||
'r'), new Letter('e'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('i'), new Letter('s'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('a'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('w'), new Letter('h'), new Letter('i'), new Letter(
|
||||
'p'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('t'), new Letter('h'), new Letter('e'), new Letter(
|
||||
'r'), new Letter('e'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('i'), new Letter('s'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('a'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('w'), new Letter('a'), new Letter('y'))));
|
||||
List<Word> words = List.of(
|
||||
new Word(List.of(new Letter('W'), new Letter('h'), new Letter('e'), new Letter(
|
||||
'r'), new Letter('e'))),
|
||||
new Word(List.of(new Letter('t'), new Letter('h'), new Letter('e'), new Letter(
|
||||
'r'), new Letter('e'))),
|
||||
new Word(List.of(new Letter('i'), new Letter('s'))),
|
||||
new Word(List.of(new Letter('a'))),
|
||||
new Word(List.of(new Letter('w'), new Letter('h'), new Letter('i'), new Letter(
|
||||
'p'))),
|
||||
new Word(List.of(new Letter('t'), new Letter('h'), new Letter('e'), new Letter(
|
||||
'r'), new Letter('e'))),
|
||||
new Word(List.of(new Letter('i'), new Letter('s'))),
|
||||
new Word(List.of(new Letter('a'))),
|
||||
new Word(List.of(new Letter('w'), new Letter('a'), new Letter('y'))));
|
||||
|
||||
return new Sentence(words);
|
||||
|
||||
@ -58,20 +55,15 @@ public class Messenger {
|
||||
|
||||
LetterComposite messageFromElves() {
|
||||
|
||||
List<Word> words = new ArrayList<>();
|
||||
|
||||
words.add(new Word(Arrays.asList(new Letter('M'), new Letter('u'), new Letter('c'), new Letter(
|
||||
'h'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('w'), new Letter('i'), new Letter('n'), new Letter(
|
||||
'd'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('p'), new Letter('o'), new Letter('u'), new Letter(
|
||||
'r'), new Letter('s'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('f'), new Letter('r'), new Letter('o'), new Letter(
|
||||
'm'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('y'), new Letter('o'), new Letter('u'), new Letter(
|
||||
'r'))));
|
||||
words.add(new Word(Arrays.asList(new Letter('m'), new Letter('o'), new Letter('u'), new Letter(
|
||||
't'), new Letter('h'))));
|
||||
List<Word> words = List.of(
|
||||
new Word(List.of(new Letter('M'), new Letter('u'), new Letter('c'), new Letter('h'))),
|
||||
new Word(List.of(new Letter('w'), new Letter('i'), new Letter('n'), new Letter('d'))),
|
||||
new Word(List.of(new Letter('p'), new Letter('o'), new Letter('u'), new Letter('r'),
|
||||
new Letter('s'))),
|
||||
new Word(List.of(new Letter('f'), new Letter('r'), new Letter('o'), new Letter('m'))),
|
||||
new Word(List.of(new Letter('y'), new Letter('o'), new Letter('u'), new Letter('r'))),
|
||||
new Word(List.of(new Letter('m'), new Letter('o'), new Letter('u'), new Letter('t'),
|
||||
new Letter('h'))));
|
||||
|
||||
return new Sentence(words);
|
||||
|
||||
|
@ -24,11 +24,9 @@
|
||||
package com.iluwatar.converter;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -38,7 +36,7 @@ import java.util.List;
|
||||
* objects between types.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
/**
|
||||
* Program entry point
|
||||
@ -52,7 +50,7 @@ public class App {
|
||||
User user = userConverter.convertFromDto(dtoUser);
|
||||
LOGGER.info("Entity converted from DTO:" + user);
|
||||
|
||||
ArrayList<User> users = Lists.newArrayList(new User("Camile", "Tough", false, "124sad"),
|
||||
var users = List.of(new User("Camile", "Tough", false, "124sad"),
|
||||
new User("Marti", "Luther", true, "42309fd"), new User("Kate", "Smith", true, "if0243"));
|
||||
LOGGER.info("Domain entities:");
|
||||
users.stream().map(User::toString).forEach(LOGGER::info);
|
||||
|
@ -23,10 +23,8 @@
|
||||
|
||||
package com.iluwatar.converter;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@ -81,8 +79,9 @@ public class ConverterTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCollectionConversion() {
|
||||
ArrayList<User> users = Lists.newArrayList(new User("Camile", "Tough", false, "124sad"),
|
||||
new User("Marti", "Luther", true, "42309fd"), new User("Kate", "Smith", true, "if0243"));
|
||||
List<User> users = List.of(new User("Camile", "Tough", false, "124sad"),
|
||||
new User("Marti", "Luther", true, "42309fd"),
|
||||
new User("Kate", "Smith", true, "if0243"));
|
||||
List<User> fromDtos = userConverter.createFromDtos(userConverter.createFromEntities(users));
|
||||
assertEquals(users, fromDtos);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user