* Use java 11 * Use .of - Replace Arrays.asList with List.of - Replace HashSet<>(List.of()) with Set.of * Formatting
This commit is contained in:
parent
dd971d8c19
commit
c8a481bb77
@ -25,7 +25,6 @@ package com.iluwatar.abstractdocument;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -28,7 +28,6 @@ import com.iluwatar.abstractdocument.domain.Part;
|
|||||||
import com.iluwatar.abstractdocument.domain.enums.Property;
|
import com.iluwatar.abstractdocument.domain.enums.Property;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -64,7 +63,7 @@ public class DomainTest {
|
|||||||
Map<String, Object> carProperties = Map.of(
|
Map<String, Object> carProperties = Map.of(
|
||||||
Property.MODEL.toString(), TEST_CAR_MODEL,
|
Property.MODEL.toString(), TEST_CAR_MODEL,
|
||||||
Property.PRICE.toString(), TEST_CAR_PRICE,
|
Property.PRICE.toString(), TEST_CAR_PRICE,
|
||||||
Property.PARTS.toString(), List.of(new HashMap<>(), new HashMap<>()));
|
Property.PARTS.toString(), List.of(Map.of(), Map.of()));
|
||||||
Car car = new Car(carProperties);
|
Car car = new Car(carProperties);
|
||||||
|
|
||||||
assertEquals(TEST_CAR_MODEL, car.getModel().get());
|
assertEquals(TEST_CAR_MODEL, car.getModel().get());
|
||||||
|
@ -23,13 +23,12 @@
|
|||||||
|
|
||||||
package com.iluwatar.collectionpipeline;
|
package com.iluwatar.collectionpipeline;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In imperative-style programming, it is common to use for and while loops for
|
* In imperative-style programming, it is common to use for and while loops for
|
||||||
* most kinds of data processing. Function composition is a simple technique
|
* most kinds of data processing. Function composition is a simple technique
|
||||||
@ -67,11 +66,11 @@ public class App {
|
|||||||
LOGGER.info(groupingByCategoryFunctional.toString());
|
LOGGER.info(groupingByCategoryFunctional.toString());
|
||||||
|
|
||||||
Person john = new Person(cars);
|
Person john = new Person(cars);
|
||||||
|
|
||||||
List<Car> sedansOwnedImperative = ImperativeProgramming.getSedanCarsOwnedSortedByDate(Arrays.asList(john));
|
List<Car> sedansOwnedImperative = ImperativeProgramming.getSedanCarsOwnedSortedByDate(List.of(john));
|
||||||
LOGGER.info(sedansOwnedImperative.toString());
|
LOGGER.info(sedansOwnedImperative.toString());
|
||||||
|
|
||||||
List<Car> sedansOwnedFunctional = FunctionalProgramming.getSedanCarsOwnedSortedByDate(Arrays.asList(john));
|
List<Car> sedansOwnedFunctional = FunctionalProgramming.getSedanCarsOwnedSortedByDate(List.of(john));
|
||||||
LOGGER.info(sedansOwnedFunctional.toString());
|
LOGGER.info(sedansOwnedFunctional.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
package com.iluwatar.collectionpipeline;
|
package com.iluwatar.collectionpipeline;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +37,7 @@ public class CarFactory {
|
|||||||
* @return {@link List} of {@link Car}
|
* @return {@link List} of {@link Car}
|
||||||
*/
|
*/
|
||||||
public static List<Car> createCars() {
|
public static List<Car> createCars() {
|
||||||
return Arrays.asList(new Car("Jeep", "Wrangler", 2011, Category.JEEP),
|
return List.of(new Car("Jeep", "Wrangler", 2011, Category.JEEP),
|
||||||
new Car("Jeep", "Comanche", 1990, Category.JEEP),
|
new Car("Jeep", "Comanche", 1990, Category.JEEP),
|
||||||
new Car("Dodge", "Avenger", 2010, Category.SEDAN),
|
new Car("Dodge", "Avenger", 2010, Category.SEDAN),
|
||||||
new Car("Buick", "Cascada", 2016, Category.CONVERTIBLE),
|
new Car("Buick", "Cascada", 2016, Category.CONVERTIBLE),
|
||||||
|
@ -43,7 +43,7 @@ public abstract class Service {
|
|||||||
public ArrayList<Exception> exceptionsList;
|
public ArrayList<Exception> exceptionsList;
|
||||||
private static final Random RANDOM = new Random();
|
private static final Random RANDOM = new Random();
|
||||||
private static final String ALL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
private static final String ALL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||||
private static final Hashtable<String, Boolean> USED_IDS = new Hashtable<String, Boolean>();
|
private static final Hashtable<String, Boolean> USED_IDS = new Hashtable<>();
|
||||||
|
|
||||||
protected Service(Database db, Exception...exc) {
|
protected Service(Database db, Exception...exc) {
|
||||||
this.database = db;
|
this.database = db;
|
||||||
|
@ -45,9 +45,9 @@ class RetryTest {
|
|||||||
Retry.HandleErrorIssue<Order> handleError = (o,e) -> {
|
Retry.HandleErrorIssue<Order> handleError = (o,e) -> {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
Retry<Order> r1 = new Retry<Order>(op, handleError, 3, 30000,
|
Retry<Order> r1 = new Retry<>(op, handleError, 3, 30000,
|
||||||
e -> DatabaseUnavailableException.class.isAssignableFrom(e.getClass()));
|
e -> DatabaseUnavailableException.class.isAssignableFrom(e.getClass()));
|
||||||
Retry<Order> r2 = new Retry<Order>(op, handleError, 3, 30000,
|
Retry<Order> r2 = new Retry<>(op, handleError, 3, 30000,
|
||||||
e -> DatabaseUnavailableException.class.isAssignableFrom(e.getClass()));
|
e -> DatabaseUnavailableException.class.isAssignableFrom(e.getClass()));
|
||||||
User user = new User("Jim", "ABCD");
|
User user = new User("Jim", "ABCD");
|
||||||
Order order = new Order(user, "book", 10f);
|
Order order = new Order(user, "book", 10f);
|
||||||
|
@ -23,21 +23,20 @@
|
|||||||
|
|
||||||
package com.iluwatar.fluentinterface.app;
|
package com.iluwatar.fluentinterface.app;
|
||||||
|
|
||||||
import static java.lang.String.valueOf;
|
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
|
||||||
|
import com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable;
|
||||||
|
import com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
|
import static java.lang.String.valueOf;
|
||||||
import com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable;
|
|
||||||
import com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Fluent Interface pattern is useful when you want to provide an easy readable, flowing API.
|
* The Fluent Interface pattern is useful when you want to provide an easy readable, flowing API.
|
||||||
@ -61,7 +60,7 @@ public class App {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
List<Integer> integerList = new ArrayList<>();
|
List<Integer> integerList = new ArrayList<>();
|
||||||
integerList.addAll(Arrays.asList(1, -61, 14, -22, 18, -87, 6, 64, -82, 26, -98, 97, 45, 23, 2,
|
integerList.addAll(List.of(1, -61, 14, -22, 18, -87, 6, 64, -82, 26, -98, 97, 45, 23, 2,
|
||||||
-68, 45));
|
-68, 45));
|
||||||
|
|
||||||
prettyPrint("The initial list contains: ", integerList);
|
prettyPrint("The initial list contains: ", integerList);
|
||||||
|
@ -25,21 +25,14 @@ package com.iluwatar.fluentinterface.fluentiterable;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date: 12/12/15 - 7:00 PM
|
* Date: 12/12/15 - 7:00 PM
|
||||||
@ -58,7 +51,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFirst() throws Exception {
|
public void testFirst() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3, 10, 9, 8);
|
final List<Integer> integers = List.of(1, 2, 3, 10, 9, 8);
|
||||||
final Optional<Integer> first = createFluentIterable(integers).first();
|
final Optional<Integer> first = createFluentIterable(integers).first();
|
||||||
assertNotNull(first);
|
assertNotNull(first);
|
||||||
assertTrue(first.isPresent());
|
assertTrue(first.isPresent());
|
||||||
@ -75,7 +68,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFirstCount() throws Exception {
|
public void testFirstCount() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3, 10, 9, 8);
|
final List<Integer> integers = List.of(1, 2, 3, 10, 9, 8);
|
||||||
final List<Integer> first4 = createFluentIterable(integers)
|
final List<Integer> first4 = createFluentIterable(integers)
|
||||||
.first(4)
|
.first(4)
|
||||||
.asList();
|
.asList();
|
||||||
@ -91,7 +84,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFirstCountLessItems() throws Exception {
|
public void testFirstCountLessItems() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3);
|
final List<Integer> integers = List.of(1, 2, 3);
|
||||||
final List<Integer> first4 = createFluentIterable(integers)
|
final List<Integer> first4 = createFluentIterable(integers)
|
||||||
.first(4)
|
.first(4)
|
||||||
.asList();
|
.asList();
|
||||||
@ -106,7 +99,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLast() throws Exception {
|
public void testLast() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3, 10, 9, 8);
|
final List<Integer> integers = List.of(1, 2, 3, 10, 9, 8);
|
||||||
final Optional<Integer> last = createFluentIterable(integers).last();
|
final Optional<Integer> last = createFluentIterable(integers).last();
|
||||||
assertNotNull(last);
|
assertNotNull(last);
|
||||||
assertTrue(last.isPresent());
|
assertTrue(last.isPresent());
|
||||||
@ -123,7 +116,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLastCount() throws Exception {
|
public void testLastCount() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3, 10, 9, 8);
|
final List<Integer> integers = List.of(1, 2, 3, 10, 9, 8);
|
||||||
final List<Integer> last4 = createFluentIterable(integers)
|
final List<Integer> last4 = createFluentIterable(integers)
|
||||||
.last(4)
|
.last(4)
|
||||||
.asList();
|
.asList();
|
||||||
@ -138,7 +131,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLastCountLessItems() throws Exception {
|
public void testLastCountLessItems() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3);
|
final List<Integer> integers = List.of(1, 2, 3);
|
||||||
final List<Integer> last4 = createFluentIterable(integers)
|
final List<Integer> last4 = createFluentIterable(integers)
|
||||||
.last(4)
|
.last(4)
|
||||||
.asList();
|
.asList();
|
||||||
@ -153,7 +146,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFilter() throws Exception {
|
public void testFilter() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3, 10, 9, 8);
|
final List<Integer> integers = List.of(1, 2, 3, 10, 9, 8);
|
||||||
final List<Integer> evenItems = createFluentIterable(integers)
|
final List<Integer> evenItems = createFluentIterable(integers)
|
||||||
.filter(i -> i % 2 == 0)
|
.filter(i -> i % 2 == 0)
|
||||||
.asList();
|
.asList();
|
||||||
@ -167,7 +160,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMap() throws Exception {
|
public void testMap() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3);
|
final List<Integer> integers = List.of(1, 2, 3);
|
||||||
final List<Long> longs = createFluentIterable(integers)
|
final List<Long> longs = createFluentIterable(integers)
|
||||||
.map(Integer::longValue)
|
.map(Integer::longValue)
|
||||||
.asList();
|
.asList();
|
||||||
@ -181,7 +174,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForEach() {
|
public void testForEach() {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3);
|
final List<Integer> integers = List.of(1, 2, 3);
|
||||||
|
|
||||||
final Consumer<Integer> consumer = mock(Consumer.class);
|
final Consumer<Integer> consumer = mock(Consumer.class);
|
||||||
createFluentIterable(integers).forEach(consumer);
|
createFluentIterable(integers).forEach(consumer);
|
||||||
@ -195,7 +188,7 @@ public abstract class FluentIterableTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpliterator() throws Exception {
|
public void testSpliterator() throws Exception {
|
||||||
final List<Integer> integers = Arrays.asList(1, 2, 3);
|
final List<Integer> integers = List.of(1, 2, 3);
|
||||||
final Spliterator<Integer> split = createFluentIterable(integers).spliterator();
|
final Spliterator<Integer> split = createFluentIterable(integers).spliterator();
|
||||||
assertNotNull(split);
|
assertNotNull(split);
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,9 @@ package com.iluwatar.hexagonal.domain;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -43,8 +38,7 @@ class LotteryNumbersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGivenNumbers() {
|
void testGivenNumbers() {
|
||||||
LotteryNumbers numbers = LotteryNumbers.create(
|
LotteryNumbers numbers = LotteryNumbers.create(Set.of(1, 2, 3, 4));
|
||||||
Set.of(1, 2, 3, 4));
|
|
||||||
assertEquals(numbers.getNumbers().size(), 4);
|
assertEquals(numbers.getNumbers().size(), 4);
|
||||||
assertTrue(numbers.getNumbers().contains(1));
|
assertTrue(numbers.getNumbers().contains(1));
|
||||||
assertTrue(numbers.getNumbers().contains(2));
|
assertTrue(numbers.getNumbers().contains(2));
|
||||||
@ -54,8 +48,7 @@ class LotteryNumbersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testNumbersCantBeModified() {
|
void testNumbersCantBeModified() {
|
||||||
LotteryNumbers numbers = LotteryNumbers.create(
|
LotteryNumbers numbers = LotteryNumbers.create(Set.of(1, 2, 3, 4));
|
||||||
Set.of(1, 2, 3, 4));
|
|
||||||
assertThrows(UnsupportedOperationException.class, () -> numbers.getNumbers().add(5));
|
assertThrows(UnsupportedOperationException.class, () -> numbers.getNumbers().add(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,13 +60,10 @@ class LotteryNumbersTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testEquals() {
|
void testEquals() {
|
||||||
LotteryNumbers numbers1 = LotteryNumbers.create(
|
LotteryNumbers numbers1 = LotteryNumbers.create(Set.of(1, 2, 3, 4));
|
||||||
Set.of(1, 2, 3, 4));
|
LotteryNumbers numbers2 = LotteryNumbers.create(Set.of(1, 2, 3, 4));
|
||||||
LotteryNumbers numbers2 = LotteryNumbers.create(
|
|
||||||
Set.of(1, 2, 3, 4));
|
|
||||||
assertEquals(numbers1, numbers2);
|
assertEquals(numbers1, numbers2);
|
||||||
LotteryNumbers numbers3 = LotteryNumbers.create(
|
LotteryNumbers numbers3 = LotteryNumbers.create(Set.of(11, 12, 13, 14));
|
||||||
Set.of(11, 12, 13, 14));
|
|
||||||
assertNotEquals(numbers1, numbers3);
|
assertNotEquals(numbers1, numbers3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -25,8 +25,6 @@ package com.iluwatar.hexagonal.domain;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
@ -23,15 +23,13 @@
|
|||||||
|
|
||||||
package com.iluwatar.hexagonal.test;
|
package com.iluwatar.hexagonal.test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.iluwatar.hexagonal.domain.LotteryNumbers;
|
import com.iluwatar.hexagonal.domain.LotteryNumbers;
|
||||||
import com.iluwatar.hexagonal.domain.LotteryTicket;
|
import com.iluwatar.hexagonal.domain.LotteryTicket;
|
||||||
import com.iluwatar.hexagonal.domain.LotteryTicketId;
|
import com.iluwatar.hexagonal.domain.LotteryTicketId;
|
||||||
import com.iluwatar.hexagonal.domain.PlayerDetails;
|
import com.iluwatar.hexagonal.domain.PlayerDetails;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Utilities for lottery tests
|
* Utilities for lottery tests
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
package com.iluwatar.layers;
|
package com.iluwatar.layers;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -99,16 +99,18 @@ public class App {
|
|||||||
cakeBakingService.saveNewTopping(new CakeToppingInfo("cherry", 350));
|
cakeBakingService.saveNewTopping(new CakeToppingInfo("cherry", 350));
|
||||||
|
|
||||||
CakeInfo cake1 =
|
CakeInfo cake1 =
|
||||||
new CakeInfo(new CakeToppingInfo("candies", 0), Arrays.asList(new CakeLayerInfo(
|
new CakeInfo(new CakeToppingInfo("candies", 0), List.of(
|
||||||
"chocolate", 0), new CakeLayerInfo("banana", 0), new CakeLayerInfo("strawberry", 0)));
|
new CakeLayerInfo("chocolate", 0),
|
||||||
|
new CakeLayerInfo("banana", 0),
|
||||||
|
new CakeLayerInfo("strawberry", 0)));
|
||||||
try {
|
try {
|
||||||
cakeBakingService.bakeNewCake(cake1);
|
cakeBakingService.bakeNewCake(cake1);
|
||||||
} catch (CakeBakingException e) {
|
} catch (CakeBakingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
CakeInfo cake2 =
|
CakeInfo cake2 =
|
||||||
new CakeInfo(new CakeToppingInfo("cherry", 0), Arrays.asList(
|
new CakeInfo(new CakeToppingInfo("cherry", 0), List.of(
|
||||||
new CakeLayerInfo("vanilla", 0), new CakeLayerInfo("lemon", 0), new CakeLayerInfo(
|
new CakeLayerInfo("vanilla", 0), new CakeLayerInfo("lemon", 0), new CakeLayerInfo(
|
||||||
"strawberry", 0)));
|
"strawberry", 0)));
|
||||||
try {
|
try {
|
||||||
cakeBakingService.bakeNewCake(cake2);
|
cakeBakingService.bakeNewCake(cake2);
|
||||||
|
@ -25,15 +25,10 @@ package com.iluwatar.layers;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date: 12/15/15 - 9:55 PM
|
* Date: 12/15/15 - 9:55 PM
|
||||||
@ -108,7 +103,7 @@ public class CakeBakingServiceImplTest {
|
|||||||
service.saveNewLayer(layer2);
|
service.saveNewLayer(layer2);
|
||||||
service.saveNewLayer(layer3);
|
service.saveNewLayer(layer3);
|
||||||
|
|
||||||
service.bakeNewCake(new CakeInfo(topping1, Arrays.asList(layer1, layer2)));
|
service.bakeNewCake(new CakeInfo(topping1, List.of(layer1, layer2)));
|
||||||
service.bakeNewCake(new CakeInfo(topping2, Collections.singletonList(layer3)));
|
service.bakeNewCake(new CakeInfo(topping2, Collections.singletonList(layer3)));
|
||||||
|
|
||||||
final List<CakeInfo> allCakes = service.getAllCakes();
|
final List<CakeInfo> allCakes = service.getAllCakes();
|
||||||
@ -136,7 +131,7 @@ public class CakeBakingServiceImplTest {
|
|||||||
|
|
||||||
final CakeToppingInfo missingTopping = new CakeToppingInfo("Topping1", 1000);
|
final CakeToppingInfo missingTopping = new CakeToppingInfo("Topping1", 1000);
|
||||||
assertThrows(CakeBakingException.class, () -> {
|
assertThrows(CakeBakingException.class, () -> {
|
||||||
service.bakeNewCake(new CakeInfo(missingTopping, Arrays.asList(layer1, layer2)));
|
service.bakeNewCake(new CakeInfo(missingTopping, List.of(layer1, layer2)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +151,7 @@ public class CakeBakingServiceImplTest {
|
|||||||
|
|
||||||
final CakeLayerInfo missingLayer = new CakeLayerInfo("Layer2", 2000);
|
final CakeLayerInfo missingLayer = new CakeLayerInfo("Layer2", 2000);
|
||||||
assertThrows(CakeBakingException.class, () -> {
|
assertThrows(CakeBakingException.class, () -> {
|
||||||
service.bakeNewCake(new CakeInfo(topping1, Arrays.asList(layer1, missingLayer)));
|
service.bakeNewCake(new CakeInfo(topping1, List.of(layer1, missingLayer)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +173,7 @@ public class CakeBakingServiceImplTest {
|
|||||||
service.saveNewLayer(layer1);
|
service.saveNewLayer(layer1);
|
||||||
service.saveNewLayer(layer2);
|
service.saveNewLayer(layer2);
|
||||||
|
|
||||||
service.bakeNewCake(new CakeInfo(topping1, Arrays.asList(layer1, layer2)));
|
service.bakeNewCake(new CakeInfo(topping1, List.of(layer1, layer2)));
|
||||||
assertThrows(CakeBakingException.class, () -> {
|
assertThrows(CakeBakingException.class, () -> {
|
||||||
service.bakeNewCake(new CakeInfo(topping2, Collections.singletonList(layer2)));
|
service.bakeNewCake(new CakeInfo(topping2, Collections.singletonList(layer2)));
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,6 @@ import org.junit.jupiter.params.ParameterizedTest;
|
|||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -50,7 +49,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
public class PartyMemberTest {
|
public class PartyMemberTest {
|
||||||
|
|
||||||
static Collection<Supplier<PartyMember>[]> dataProvider() {
|
static Collection<Supplier<PartyMember>[]> dataProvider() {
|
||||||
return Arrays.asList(
|
return List.of(
|
||||||
new Supplier[]{Hobbit::new},
|
new Supplier[]{Hobbit::new},
|
||||||
new Supplier[]{Hunter::new},
|
new Supplier[]{Hunter::new},
|
||||||
new Supplier[]{Rogue::new},
|
new Supplier[]{Rogue::new},
|
||||||
|
@ -23,17 +23,14 @@
|
|||||||
|
|
||||||
package domainapp.fixture.scenarios;
|
package domainapp.fixture.scenarios;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import org.apache.isis.applib.fixturescripts.FixtureScript;
|
|
||||||
|
|
||||||
import domainapp.dom.modules.simple.SimpleObject;
|
import domainapp.dom.modules.simple.SimpleObject;
|
||||||
import domainapp.fixture.modules.simple.SimpleObjectCreate;
|
import domainapp.fixture.modules.simple.SimpleObjectCreate;
|
||||||
import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
|
import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
|
||||||
|
import org.apache.isis.applib.fixturescripts.FixtureScript;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,8 +38,8 @@ import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
|
|||||||
*/
|
*/
|
||||||
public class RecreateSimpleObjects extends FixtureScript {
|
public class RecreateSimpleObjects extends FixtureScript {
|
||||||
|
|
||||||
public final List<String> names = Collections.unmodifiableList(Arrays.asList("Foo", "Bar", "Baz",
|
public final List<String> names = Collections.unmodifiableList(List.of("Foo", "Bar", "Baz",
|
||||||
"Frodo", "Froyo", "Fizz", "Bip", "Bop", "Bang", "Boo"));
|
"Frodo", "Froyo", "Fizz", "Bip", "Bop", "Bang", "Boo"));
|
||||||
|
|
||||||
// region > number (optional input)
|
// region > number (optional input)
|
||||||
private Integer number;
|
private Integer number;
|
||||||
|
@ -25,15 +25,10 @@ package com.iluwatar.object.pool;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static java.time.Duration.ofMillis;
|
import static java.time.Duration.ofMillis;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTimeout;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date: 12/27/15 - 1:05 AM
|
* Date: 12/27/15 - 1:05 AM
|
||||||
@ -115,7 +110,7 @@ public class OliphauntPoolTest {
|
|||||||
|
|
||||||
// The order of the returned instances is not determined, so just put them in a list
|
// The order of the returned instances is not determined, so just put them in a list
|
||||||
// and verify if both expected instances are in there.
|
// and verify if both expected instances are in there.
|
||||||
final List<Oliphaunt> oliphaunts = Arrays.asList(pool.checkOut(), pool.checkOut());
|
final List<Oliphaunt> oliphaunts = List.of(pool.checkOut(), pool.checkOut());
|
||||||
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
assertEquals(pool.toString(), "Pool available=0 inUse=2");
|
||||||
assertTrue(oliphaunts.contains(firstOliphaunt));
|
assertTrue(oliphaunts.contains(firstOliphaunt));
|
||||||
assertTrue(oliphaunts.contains(secondOliphaunt));
|
assertTrue(oliphaunts.contains(secondOliphaunt));
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
package com.iluwatar.observer;
|
package com.iluwatar.observer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -36,12 +35,11 @@ public class HobbitsTest extends WeatherObserverTest<Hobbits> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Object[]> dataProvider() {
|
public Collection<Object[]> dataProvider() {
|
||||||
final List<Object[]> testData = new ArrayList<>();
|
return List.of(
|
||||||
testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."});
|
new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."},
|
||||||
testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."});
|
new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."},
|
||||||
testData.add(new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."});
|
new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."},
|
||||||
testData.add(new Object[]{WeatherType.COLD, "The hobbits are shivering in the cold weather."});
|
new Object[]{WeatherType.COLD, "The hobbits are shivering in the cold weather."});
|
||||||
return testData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
package com.iluwatar.observer;
|
package com.iluwatar.observer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -36,12 +35,11 @@ public class OrcsTest extends WeatherObserverTest<Orcs> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Object[]> dataProvider() {
|
public Collection<Object[]> dataProvider() {
|
||||||
final List<Object[]> testData = new ArrayList<>();
|
return List.of(
|
||||||
testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."});
|
new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."},
|
||||||
testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."});
|
new Object[]{WeatherType.RAINY, "The orcs are dripping wet."},
|
||||||
testData.add(new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."});
|
new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."},
|
||||||
testData.add(new Object[]{WeatherType.COLD, "The orcs are freezing cold."});
|
new Object[]{WeatherType.COLD, "The orcs are freezing cold."});
|
||||||
return testData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,6 @@ package com.iluwatar.observer.generic;
|
|||||||
|
|
||||||
import com.iluwatar.observer.WeatherType;
|
import com.iluwatar.observer.WeatherType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -38,12 +37,12 @@ public class GHobbitsTest extends ObserverTest<GHobbits> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Object[]> dataProvider() {
|
public Collection<Object[]> dataProvider() {
|
||||||
final List<Object[]> testData = new ArrayList<>();
|
return List.of(
|
||||||
testData.add(new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."});
|
new Object[]{WeatherType.SUNNY, "The happy hobbits bade in the warm sun."},
|
||||||
testData.add(new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."});
|
new Object[]{WeatherType.RAINY, "The hobbits look for cover from the rain."},
|
||||||
testData.add(new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."});
|
new Object[]{WeatherType.WINDY, "The hobbits hold their hats tightly in the windy weather."},
|
||||||
testData.add(new Object[]{WeatherType.COLD, "The hobbits are shivering in the cold weather."});
|
new Object[]{WeatherType.COLD, "The hobbits are shivering in the cold weather."}
|
||||||
return testData;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,6 @@ package com.iluwatar.observer.generic;
|
|||||||
|
|
||||||
import com.iluwatar.observer.WeatherType;
|
import com.iluwatar.observer.WeatherType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -38,12 +37,12 @@ public class OrcsTest extends ObserverTest<GOrcs> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Object[]> dataProvider() {
|
public Collection<Object[]> dataProvider() {
|
||||||
final List<Object[]> testData = new ArrayList<>();
|
return List.of(
|
||||||
testData.add(new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."});
|
new Object[]{WeatherType.SUNNY, "The sun hurts the orcs' eyes."},
|
||||||
testData.add(new Object[]{WeatherType.RAINY, "The orcs are dripping wet."});
|
new Object[]{WeatherType.RAINY, "The orcs are dripping wet."},
|
||||||
testData.add(new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."});
|
new Object[]{WeatherType.WINDY, "The orc smell almost vanishes in the wind."},
|
||||||
testData.add(new Object[]{WeatherType.COLD, "The orcs are freezing cold."});
|
new Object[]{WeatherType.COLD, "The orcs are freezing cold."}
|
||||||
return testData;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,6 @@ package com.iluwatar.partialresponse;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,10 +46,13 @@ public class App {
|
|||||||
* @param args program argument.
|
* @param args program argument.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Map<Integer, Video> videos = new HashMap<>();
|
Map<Integer, Video> videos = Map.of(
|
||||||
videos.put(1, new Video(1, "Avatar", 178, "epic science fiction film", "James Cameron", "English"));
|
1, new Video(1, "Avatar", 178, "epic science fiction film",
|
||||||
videos.put(2, new Video(2, "Godzilla Resurgence", 120, "Action & drama movie|", "Hideaki Anno", "Japanese"));
|
"James Cameron", "English"),
|
||||||
videos.put(3, new Video(3, "Interstellar", 169, "Adventure & Sci-Fi", "Christopher Nolan", "English"));
|
2, new Video(2, "Godzilla Resurgence", 120, "Action & drama movie|",
|
||||||
|
"Hideaki Anno", "Japanese"),
|
||||||
|
3, new Video(3, "Interstellar", 169, "Adventure & Sci-Fi",
|
||||||
|
"Christopher Nolan", "English"));
|
||||||
VideoResource videoResource = new VideoResource(new FieldJsonMapper(), videos);
|
VideoResource videoResource = new VideoResource(new FieldJsonMapper(), videos);
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.runners.MockitoJUnitRunner;
|
import org.mockito.runners.MockitoJUnitRunner;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@ -49,10 +48,13 @@ public class VideoResourceTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
Map<Integer, Video> videos = new HashMap<>();
|
Map<Integer, Video> videos = Map.of(
|
||||||
videos.put(1, new Video(1, "Avatar", 178, "epic science fiction film", "James Cameron", "English"));
|
1, new Video(1, "Avatar", 178, "epic science fiction film",
|
||||||
videos.put(2, new Video(2, "Godzilla Resurgence", 120, "Action & drama movie|", "Hideaki Anno", "Japanese"));
|
"James Cameron", "English"),
|
||||||
videos.put(3, new Video(3, "Interstellar", 169, "Adventure & Sci-Fi", "Christopher Nolan", "English"));
|
2, new Video(2, "Godzilla Resurgence", 120, "Action & drama movie|",
|
||||||
|
"Hideaki Anno", "Japanese"),
|
||||||
|
3, new Video(3, "Interstellar", 169, "Adventure & Sci-Fi",
|
||||||
|
"Christopher Nolan", "English"));
|
||||||
resource = new VideoResource(fieldJsonMapper, videos);
|
resource = new VideoResource(fieldJsonMapper, videos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,13 +26,10 @@ package com.iluwatar.prototype;
|
|||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date: 12/28/15 - 8:45 PM
|
* Date: 12/28/15 - 8:45 PM
|
||||||
@ -41,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
|
|||||||
*/
|
*/
|
||||||
public class PrototypeTest<P extends Prototype> {
|
public class PrototypeTest<P extends Prototype> {
|
||||||
static Collection<Object[]> dataProvider() {
|
static Collection<Object[]> dataProvider() {
|
||||||
return Arrays.asList(
|
return List.of(
|
||||||
new Object[]{new OrcBeast("axe"), "Orcish wolf attacks with axe"},
|
new Object[]{new OrcBeast("axe"), "Orcish wolf attacks with axe"},
|
||||||
new Object[]{new OrcMage("sword"), "Orcish mage attacks with sword"},
|
new Object[]{new OrcMage("sword"), "Orcish mage attacks with sword"},
|
||||||
new Object[]{new OrcWarlord("laser"), "Orcish warlord attacks with laser"},
|
new Object[]{new OrcWarlord("laser"), "Orcish warlord attacks with laser"},
|
||||||
|
@ -23,16 +23,7 @@
|
|||||||
|
|
||||||
package com.iluwatar.repository;
|
package com.iluwatar.repository;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import com.google.common.collect.Lists;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -40,7 +31,11 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case to test the functions of {@link PersonRepository}, beside the CRUD functions, the query
|
* Test case to test the functions of {@link PersonRepository}, beside the CRUD functions, the query
|
||||||
@ -59,7 +54,7 @@ public class AnnotationBasedRepositoryTest {
|
|||||||
Person john = new Person("John", "lawrence", 35);
|
Person john = new Person("John", "lawrence", 35);
|
||||||
Person terry = new Person("Terry", "Law", 36);
|
Person terry = new Person("Terry", "Law", 36);
|
||||||
|
|
||||||
List<Person> persons = Arrays.asList(peter, nasta, john, terry);
|
List<Person> persons = List.of(peter, nasta, john, terry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare data for test
|
* Prepare data for test
|
||||||
|
@ -23,16 +23,7 @@
|
|||||||
|
|
||||||
package com.iluwatar.repository;
|
package com.iluwatar.repository;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import com.google.common.collect.Lists;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -40,7 +31,11 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case to test the functions of {@link PersonRepository}, beside the CRUD functions, the query
|
* Test case to test the functions of {@link PersonRepository}, beside the CRUD functions, the query
|
||||||
@ -58,7 +53,7 @@ public class RepositoryTest {
|
|||||||
Person john = new Person("John", "lawrence", 35);
|
Person john = new Person("John", "lawrence", 35);
|
||||||
Person terry = new Person("Terry", "Law", 36);
|
Person terry = new Person("Terry", "Law", 36);
|
||||||
|
|
||||||
List<Person> persons = Arrays.asList(peter, nasta, john, terry);
|
List<Person> persons = List.of(peter, nasta, john, terry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare data for test
|
* Prepare data for test
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
package com.iluwatar.retry;
|
package com.iluwatar.retry;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a customer, returning its ID from our records.
|
* Finds a customer, returning its ID from our records.
|
||||||
@ -48,7 +48,7 @@ public final class FindCustomer implements BusinessOperation<String> {
|
|||||||
*/
|
*/
|
||||||
public FindCustomer(String customerId, BusinessException... errors) {
|
public FindCustomer(String customerId, BusinessException... errors) {
|
||||||
this.customerId = customerId;
|
this.customerId = customerId;
|
||||||
this.errors = new ArrayDeque<>(Arrays.asList(errors));
|
this.errors = new ArrayDeque<>(List.of(errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,6 @@ package com.iluwatar.servant;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@ -60,9 +59,7 @@ public class App {
|
|||||||
King k = new King();
|
King k = new King();
|
||||||
Queen q = new Queen();
|
Queen q = new Queen();
|
||||||
|
|
||||||
List<Royalty> guests = new ArrayList<>();
|
List<Royalty> guests = List.of(k, q);
|
||||||
guests.add(k);
|
|
||||||
guests.add(q);
|
|
||||||
|
|
||||||
// feed
|
// feed
|
||||||
servant.feed(k);
|
servant.feed(k);
|
||||||
|
@ -25,7 +25,6 @@ package com.iluwatar.servant;
|
|||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@ -76,15 +75,9 @@ public class ServantTest {
|
|||||||
final Royalty badMoodRoyalty = mock(Royalty.class);
|
final Royalty badMoodRoyalty = mock(Royalty.class);
|
||||||
when(badMoodRoyalty.getMood()).thenReturn(true);
|
when(badMoodRoyalty.getMood()).thenReturn(true);
|
||||||
|
|
||||||
final List<Royalty> goodCompany = new ArrayList<>();
|
final List<Royalty> goodCompany = List.of(goodMoodRoyalty, goodMoodRoyalty, goodMoodRoyalty);
|
||||||
goodCompany.add(goodMoodRoyalty);
|
|
||||||
goodCompany.add(goodMoodRoyalty);
|
|
||||||
goodCompany.add(goodMoodRoyalty);
|
|
||||||
|
|
||||||
final List<Royalty> badCompany = new ArrayList<>();
|
final List<Royalty> badCompany = List.of(goodMoodRoyalty, goodMoodRoyalty, badMoodRoyalty);
|
||||||
goodCompany.add(goodMoodRoyalty);
|
|
||||||
goodCompany.add(goodMoodRoyalty);
|
|
||||||
goodCompany.add(badMoodRoyalty);
|
|
||||||
|
|
||||||
assertTrue(new Servant("test").checkIfYouWillBeHanged(goodCompany));
|
assertTrue(new Servant("test").checkIfYouWillBeHanged(goodCompany));
|
||||||
assertTrue(new Servant("test").checkIfYouWillBeHanged(badCompany));
|
assertTrue(new Servant("test").checkIfYouWillBeHanged(badCompany));
|
||||||
|
@ -97,11 +97,10 @@ public class MagicServiceImplTest {
|
|||||||
public void testFindWizardsWithSpellbook() throws Exception {
|
public void testFindWizardsWithSpellbook() throws Exception {
|
||||||
final String bookname = "bookname";
|
final String bookname = "bookname";
|
||||||
final Spellbook spellbook = mock(Spellbook.class);
|
final Spellbook spellbook = mock(Spellbook.class);
|
||||||
final Set<Wizard> wizards = new HashSet<>();
|
final Set<Wizard> wizards = Set.of(
|
||||||
wizards.add(mock(Wizard.class));
|
mock(Wizard.class),
|
||||||
wizards.add(mock(Wizard.class));
|
mock(Wizard.class),
|
||||||
wizards.add(mock(Wizard.class));
|
mock(Wizard.class));
|
||||||
|
|
||||||
when(spellbook.getWizards()).thenReturn(wizards);
|
when(spellbook.getWizards()).thenReturn(wizards);
|
||||||
|
|
||||||
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
|
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
|
||||||
@ -126,11 +125,10 @@ public class MagicServiceImplTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindWizardsWithSpell() throws Exception {
|
public void testFindWizardsWithSpell() throws Exception {
|
||||||
final Set<Wizard> wizards = new HashSet<>();
|
final Set<Wizard> wizards = Set.of(
|
||||||
wizards.add(mock(Wizard.class));
|
mock(Wizard.class),
|
||||||
wizards.add(mock(Wizard.class));
|
mock(Wizard.class),
|
||||||
wizards.add(mock(Wizard.class));
|
mock(Wizard.class));
|
||||||
|
|
||||||
final Spellbook spellbook = mock(Spellbook.class);
|
final Spellbook spellbook = mock(Spellbook.class);
|
||||||
when(spellbook.getWizards()).thenReturn(wizards);
|
when(spellbook.getWizards()).thenReturn(wizards);
|
||||||
|
|
||||||
|
@ -23,17 +23,7 @@
|
|||||||
|
|
||||||
package com.iluwatar.specification.app;
|
package com.iluwatar.specification.app;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import com.iluwatar.specification.creature.*;
|
||||||
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.property.Color;
|
import com.iluwatar.specification.property.Color;
|
||||||
import com.iluwatar.specification.property.Movement;
|
import com.iluwatar.specification.property.Movement;
|
||||||
import com.iluwatar.specification.selector.ColorSelector;
|
import com.iluwatar.specification.selector.ColorSelector;
|
||||||
@ -41,6 +31,9 @@ import com.iluwatar.specification.selector.MovementSelector;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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
|
* 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) {
|
public static void main(String[] args) {
|
||||||
// initialize creatures list
|
// initialize creatures list
|
||||||
List<Creature> creatures =
|
List<Creature> creatures =
|
||||||
Arrays.asList(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(),
|
List.of(new Goblin(), new Octopus(), new Dragon(), new Shark(), new Troll(), new KillerBee());
|
||||||
new KillerBee());
|
|
||||||
// find all walking creatures
|
// find all walking creatures
|
||||||
LOGGER.info("Find all walking creatures");
|
LOGGER.info("Find all walking creatures");
|
||||||
List<Creature> walkingCreatures =
|
List<Creature> walkingCreatures =
|
||||||
|
@ -29,8 +29,8 @@ import com.iluwatar.specification.property.Size;
|
|||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
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
|
* @return The tested {@link Creature} instance and its expected specs
|
||||||
*/
|
*/
|
||||||
public static Collection<Object[]> dataProvider() {
|
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 Dragon(), "Dragon", Size.LARGE, Movement.FLYING, Color.RED},
|
||||||
new Object[]{new Goblin(), "Goblin", Size.SMALL, Movement.WALKING, Color.GREEN},
|
new Object[]{new Goblin(), "Goblin", Size.SMALL, Movement.WALKING, Color.GREEN},
|
||||||
new Object[]{new KillerBee(), "KillerBee", Size.SMALL, Movement.FLYING, Color.LIGHT},
|
new Object[]{new KillerBee(), "KillerBee", Size.SMALL, Movement.FLYING, Color.LIGHT},
|
||||||
@ -76,15 +76,13 @@ public class CreatureTest {
|
|||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("dataProvider")
|
@MethodSource("dataProvider")
|
||||||
public void testGetColor(Creature testedCreature, String name, Size size, Movement movement,
|
public void testGetColor(Creature testedCreature, String name, Size size, Movement movement, Color color) {
|
||||||
Color color) {
|
|
||||||
assertEquals(color, testedCreature.getColor());
|
assertEquals(color, testedCreature.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("dataProvider")
|
@MethodSource("dataProvider")
|
||||||
public void testToString(Creature testedCreature, String name, Size size, Movement movement,
|
public void testToString(Creature testedCreature, String name, Size size, Movement movement, Color color) {
|
||||||
Color color) {
|
|
||||||
final String toString = testedCreature.toString();
|
final String toString = testedCreature.toString();
|
||||||
assertNotNull(toString);
|
assertNotNull(toString);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -32,7 +32,6 @@ import org.junit.jupiter.params.ParameterizedTest;
|
|||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -50,19 +49,19 @@ public class DragonSlayingStrategyTest {
|
|||||||
* @return The test parameters for each cycle
|
* @return The test parameters for each cycle
|
||||||
*/
|
*/
|
||||||
static Collection<Object[]> dataProvider() {
|
static Collection<Object[]> dataProvider() {
|
||||||
return Arrays.asList(
|
return List.of(
|
||||||
new Object[]{
|
new Object[]{
|
||||||
new MeleeStrategy(),
|
new MeleeStrategy(),
|
||||||
"With your Excalibur you sever the dragon's head!"
|
"With your Excalibur you sever the dragon's head!"
|
||||||
},
|
},
|
||||||
new Object[]{
|
new Object[]{
|
||||||
new ProjectileStrategy(),
|
new ProjectileStrategy(),
|
||||||
"You shoot the dragon with the magical crossbow and it falls dead on the ground!"
|
"You shoot the dragon with the magical crossbow and it falls dead on the ground!"
|
||||||
},
|
},
|
||||||
new Object[]{
|
new Object[]{
|
||||||
new SpellStrategy(),
|
new SpellStrategy(),
|
||||||
"You cast the spell of disintegration and the dragon vaporizes in a pile of dust!"
|
"You cast the spell of disintegration and the dragon vaporizes in a pile of dust!"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,22 +60,22 @@ public class App {
|
|||||||
LOGGER.info("Program started");
|
LOGGER.info("Program started");
|
||||||
|
|
||||||
// Create a list of tasks to be executed
|
// Create a list of tasks to be executed
|
||||||
List<Task> tasks = new ArrayList<>();
|
List<Task> tasks = List.of(
|
||||||
tasks.add(new PotatoPeelingTask(3));
|
new PotatoPeelingTask(3),
|
||||||
tasks.add(new PotatoPeelingTask(6));
|
new PotatoPeelingTask(6),
|
||||||
tasks.add(new CoffeeMakingTask(2));
|
new CoffeeMakingTask(2),
|
||||||
tasks.add(new CoffeeMakingTask(6));
|
new CoffeeMakingTask(6),
|
||||||
tasks.add(new PotatoPeelingTask(4));
|
new PotatoPeelingTask(4),
|
||||||
tasks.add(new CoffeeMakingTask(2));
|
new CoffeeMakingTask(2),
|
||||||
tasks.add(new PotatoPeelingTask(4));
|
new PotatoPeelingTask(4),
|
||||||
tasks.add(new CoffeeMakingTask(9));
|
new CoffeeMakingTask(9),
|
||||||
tasks.add(new PotatoPeelingTask(3));
|
new PotatoPeelingTask(3),
|
||||||
tasks.add(new CoffeeMakingTask(2));
|
new CoffeeMakingTask(2),
|
||||||
tasks.add(new PotatoPeelingTask(4));
|
new PotatoPeelingTask(4),
|
||||||
tasks.add(new CoffeeMakingTask(2));
|
new CoffeeMakingTask(2),
|
||||||
tasks.add(new CoffeeMakingTask(7));
|
new CoffeeMakingTask(7),
|
||||||
tasks.add(new PotatoPeelingTask(4));
|
new PotatoPeelingTask(4),
|
||||||
tasks.add(new PotatoPeelingTask(5));
|
new PotatoPeelingTask(5));
|
||||||
|
|
||||||
// Creates a thread pool that reuses a fixed number of threads operating off a shared
|
// Creates a thread pool that reuses a fixed number of threads operating off a shared
|
||||||
// unbounded queue. At any point, at most nThreads threads will be active processing
|
// unbounded queue. At any point, at most nThreads threads will be active processing
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
|
|
||||||
package com.iluwatar.tls;
|
package com.iluwatar.tls;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,9 +34,6 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ public class DateFormatCallableTest {
|
|||||||
/**
|
/**
|
||||||
* Expected content of the list containing the date values created by the run of DateFormatRunnalbe
|
* Expected content of the list containing the date values created by the run of DateFormatRunnalbe
|
||||||
*/
|
*/
|
||||||
List<String> expectedDateValues = Arrays.asList("15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015");
|
List<String> expectedDateValues = List.of("15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Callable and prepare results for usage in the test methods
|
* Run Callable and prepare results for usage in the test methods
|
||||||
|
@ -23,16 +23,15 @@
|
|||||||
|
|
||||||
package com.iluwatar.tls;
|
package com.iluwatar.tls;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
@ -76,7 +75,7 @@ public class DateFormatCallableTestIncorrectDateFormat {
|
|||||||
/**
|
/**
|
||||||
* Expected content of the list containing the exceptions created by the run of DateFormatRunnalbe
|
* Expected content of the list containing the exceptions created by the run of DateFormatRunnalbe
|
||||||
*/
|
*/
|
||||||
List<String> expectedExceptions = Arrays.asList("class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
List<String> expectedExceptions = List.of("class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
||||||
"class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
"class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
||||||
"class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
"class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
||||||
"class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
"class java.text.ParseException: Unparseable date: \"15.12.2015\"",
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
|
|
||||||
package com.iluwatar.tls;
|
package com.iluwatar.tls;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,9 +34,6 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
@ -86,7 +85,7 @@ public class DateFormatCallableTestMultiThread {
|
|||||||
/**
|
/**
|
||||||
* Expected content of the list containing the date values created by each thread
|
* Expected content of the list containing the date values created by each thread
|
||||||
*/
|
*/
|
||||||
List<String> expectedDateValues = Arrays.asList("15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015");
|
List<String> expectedDateValues = List.of("15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015", "15.11.2015");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Callable and prepare results for usage in the test methods
|
* Run Callable and prepare results for usage in the test methods
|
||||||
|
Loading…
x
Reference in New Issue
Block a user