From 7f72112c9778b426d7c9e9efd3bece1b62ec06c9 Mon Sep 17 00:00:00 2001 From: Cindy Turpin Date: Wed, 14 Dec 2016 14:10:56 -0600 Subject: [PATCH] adding tests --- .../lambdasinaction/appc/StreamForker.java | 2 +- .../chap10/ReadPositiveIntParam.java | 14 +- src/main/java/lambdasinaction/chap4/Dish.java | 2 +- .../chap5/BuildingStreams.java | 2 +- .../java/lambdasinaction/chap5/Finding.java | 2 +- src/main/java/lambdasinaction/chap6/Dish.java | 2 +- .../java/lambdasinaction/chap6/Grouping.java | 4 +- .../chap8/OnlineBankingLambda.java | 2 +- .../java/lambdasinaction/dsl/Grouping.java | 2 +- .../java/lambdasinaction/appa/BookTest.java | 27 ++ .../appc/StreamForkerExampleTest.java | 27 ++ .../appc/StreamForkerTest.java | 63 ++++ .../lambdasinaction/appd/InnerClassTest.java | 27 ++ .../java/lambdasinaction/appd/LambdaTest.java | 27 ++ .../chap1/FilteringApplesTest.java | 210 +++++++++++++ .../java/lambdasinaction/chap10/CarTest.java | 32 ++ .../lambdasinaction/chap10/InsuranceTest.java | 30 ++ .../chap10/OperationsWithOptionalTest.java | 43 +++ .../chap10/OptionalMainTest.java | 33 ++ .../lambdasinaction/chap10/PersonTest.java | 32 ++ .../chap11/AsyncShopClientTest.java | 30 ++ .../lambdasinaction/chap11/AsyncShopTest.java | 47 +++ .../chap11/BestPriceFinderMainTest.java | 36 +++ .../chap11/BestPriceFinderTest.java | 155 ++++++++++ .../lambdasinaction/chap11/DiscountTest.java | 30 ++ .../chap11/ExchangeServiceTest.java | 31 ++ .../lambdasinaction/chap11/QuoteTest.java | 94 ++++++ .../java/lambdasinaction/chap11/ShopTest.java | 76 +++++ .../java/lambdasinaction/chap11/UtilTest.java | 84 +++++ .../chap11/v1/BestPriceFinderMainTest.java | 36 +++ .../chap11/v1/BestPriceFinderTest.java | 291 ++++++++++++++++++ .../chap11/v1/ShopMainTest.java | 26 ++ .../lambdasinaction/chap11/v1/ShopTest.java | 77 +++++ .../chap12/DateTimeExamplesTest.java | 36 +++ .../lambdasinaction/chap13/RecursionTest.java | 112 +++++++ .../chap13/SubsetsMainTest.java | 117 +++++++ .../chap14/CombinatorsTest.java | 71 +++++ .../lambdasinaction/chap14/CurryingTest.java | 67 ++++ .../lambdasinaction/chap14/LazyListsTest.java | 90 ++++++ .../chap14/PatternMatchingTest.java | 104 +++++++ .../chap14/PersistentTrainJourneyTest.java | 100 ++++++ .../chap14/PersistentTreeTest.java | 174 +++++++++++ .../chap2/FilteringApplesTest.java | 218 +++++++++++++ .../chap2/MeaningOfThisTest.java | 44 +++ .../chap3/ExecuteAroundTest.java | 108 +++++++ .../lambdasinaction/chap3/LambdasTest.java | 79 +++++ .../lambdasinaction/chap3/SortingTest.java | 27 ++ .../java/lambdasinaction/chap4/DishTest.java | 101 ++++++ .../chap4/StreamBasicTest.java | 91 ++++++ .../chap4/StreamVsCollectionTest.java | 26 ++ .../chap5/BuildingStreamsTest.java | 34 ++ .../lambdasinaction/chap5/FilteringTest.java | 25 ++ .../lambdasinaction/chap5/FindingTest.java | 35 +++ .../lambdasinaction/chap5/LazinessTest.java | 27 ++ .../lambdasinaction/chap5/MappingTest.java | 26 ++ .../chap5/NumericStreamsTest.java | 56 ++++ .../chap5/PuttingIntoPracticeTest.java | 25 ++ .../lambdasinaction/chap5/ReducingTest.java | 26 ++ .../lambdasinaction/chap5/TraderTest.java | 74 +++++ .../chap5/TransactionTest.java | 78 +++++ .../chap6/CollectorHarnessTest.java | 27 ++ .../java/lambdasinaction/chap6/DishTest.java | 100 ++++++ .../lambdasinaction/chap6/GroupingTest.java | 26 ++ .../chap6/GroupingTransactionsTest.java | 35 +++ .../chap6/PartitionPrimeNumbersTest.java | 178 +++++++++++ .../chap6/PartitioningTest.java | 26 ++ .../lambdasinaction/chap6/ReducingTest.java | 26 ++ .../chap6/SummarizingTest.java | 26 ++ .../chap6/ToListCollectorTest.java | 79 +++++ .../chap7/ForkJoinSumCalculatorTest.java | 86 ++++++ .../chap7/ParallelStreamsHarnessTest.java | 0 .../chap7/ParallelStreamsTest.java | 100 ++++++ .../lambdasinaction/chap7/WordCountTest.java | 107 +++++++ .../chap8/ChainOfResponsibilityMainTest.java | 27 ++ .../lambdasinaction/chap8/DebuggingTest.java | 40 +++ .../chap8/FactoryMainTest.java | 36 +++ .../chap8/ObserverMainTest.java | 27 ++ .../chap8/OnlineBankingLambdaTest.java | 43 +++ .../chap8/OnlineBankingTest.java | 16 + .../java/lambdasinaction/chap8/PeekTest.java | 27 ++ .../chap8/StrategyMainTest.java | 27 ++ .../lambdasinaction/chap9/AmbiguousTest.java | 26 ++ .../lambdasinaction/chap9/DiamondTest.java | 27 ++ .../lambdasinaction/chap9/DrawableTest.java | 17 + .../lambdasinaction/chap9/EllipseTest.java | 17 + .../java/lambdasinaction/chap9/GameTest.java | 26 ++ .../java/lambdasinaction/chap9/IntroTest.java | 26 ++ .../lambdasinaction/chap9/LetterTest.java | 58 ++++ .../chap9/MostSpecificTest.java | 26 ++ .../lambdasinaction/chap9/ResizableTest.java | 17 + .../lambdasinaction/chap9/SquareTest.java | 17 + .../lambdasinaction/chap9/TriangleTest.java | 17 + .../java/lambdasinaction/chap9/UtilsTest.java | 33 ++ .../lambdasinaction/dsl/GroupingTest.java | 46 +++ .../dsl/LambdaOrderBuilderTest.java | 81 +++++ .../java/lambdasinaction/dsl/MainTest.java | 54 ++++ .../dsl/MethodChainingOrderBuilderTest.java | 66 ++++ .../lambdasinaction/dsl/MixedBuilderTest.java | 62 ++++ .../java/lambdasinaction/dsl/MixedTest.java | 28 ++ .../dsl/NestedFunctionOrderBuilderTest.java | 99 ++++++ .../dsl/TaxCalculatorTest.java | 142 +++++++++ .../lambdasinaction/dsl/model/OrderTest.java | 75 +++++ .../lambdasinaction/dsl/model/StockTest.java | 67 ++++ .../lambdasinaction/dsl/model/TaxTest.java | 50 +++ .../lambdasinaction/dsl/model/TradeTest.java | 151 +++++++++ 105 files changed, 5840 insertions(+), 14 deletions(-) create mode 100644 src/test/java/lambdasinaction/appa/BookTest.java create mode 100644 src/test/java/lambdasinaction/appc/StreamForkerExampleTest.java create mode 100644 src/test/java/lambdasinaction/appc/StreamForkerTest.java create mode 100644 src/test/java/lambdasinaction/appd/InnerClassTest.java create mode 100644 src/test/java/lambdasinaction/appd/LambdaTest.java create mode 100644 src/test/java/lambdasinaction/chap1/FilteringApplesTest.java create mode 100644 src/test/java/lambdasinaction/chap10/CarTest.java create mode 100644 src/test/java/lambdasinaction/chap10/InsuranceTest.java create mode 100644 src/test/java/lambdasinaction/chap10/OperationsWithOptionalTest.java create mode 100644 src/test/java/lambdasinaction/chap10/OptionalMainTest.java create mode 100644 src/test/java/lambdasinaction/chap10/PersonTest.java create mode 100644 src/test/java/lambdasinaction/chap11/AsyncShopClientTest.java create mode 100644 src/test/java/lambdasinaction/chap11/AsyncShopTest.java create mode 100644 src/test/java/lambdasinaction/chap11/BestPriceFinderMainTest.java create mode 100644 src/test/java/lambdasinaction/chap11/BestPriceFinderTest.java create mode 100644 src/test/java/lambdasinaction/chap11/DiscountTest.java create mode 100644 src/test/java/lambdasinaction/chap11/ExchangeServiceTest.java create mode 100644 src/test/java/lambdasinaction/chap11/QuoteTest.java create mode 100644 src/test/java/lambdasinaction/chap11/ShopTest.java create mode 100644 src/test/java/lambdasinaction/chap11/UtilTest.java create mode 100644 src/test/java/lambdasinaction/chap11/v1/BestPriceFinderMainTest.java create mode 100644 src/test/java/lambdasinaction/chap11/v1/BestPriceFinderTest.java create mode 100644 src/test/java/lambdasinaction/chap11/v1/ShopMainTest.java create mode 100644 src/test/java/lambdasinaction/chap11/v1/ShopTest.java create mode 100644 src/test/java/lambdasinaction/chap12/DateTimeExamplesTest.java create mode 100644 src/test/java/lambdasinaction/chap13/RecursionTest.java create mode 100644 src/test/java/lambdasinaction/chap13/SubsetsMainTest.java create mode 100644 src/test/java/lambdasinaction/chap14/CombinatorsTest.java create mode 100644 src/test/java/lambdasinaction/chap14/CurryingTest.java create mode 100644 src/test/java/lambdasinaction/chap14/LazyListsTest.java create mode 100644 src/test/java/lambdasinaction/chap14/PatternMatchingTest.java create mode 100644 src/test/java/lambdasinaction/chap14/PersistentTrainJourneyTest.java create mode 100644 src/test/java/lambdasinaction/chap14/PersistentTreeTest.java create mode 100644 src/test/java/lambdasinaction/chap2/FilteringApplesTest.java create mode 100644 src/test/java/lambdasinaction/chap2/MeaningOfThisTest.java create mode 100644 src/test/java/lambdasinaction/chap3/ExecuteAroundTest.java create mode 100644 src/test/java/lambdasinaction/chap3/LambdasTest.java create mode 100644 src/test/java/lambdasinaction/chap3/SortingTest.java create mode 100644 src/test/java/lambdasinaction/chap4/DishTest.java create mode 100644 src/test/java/lambdasinaction/chap4/StreamBasicTest.java create mode 100644 src/test/java/lambdasinaction/chap4/StreamVsCollectionTest.java create mode 100644 src/test/java/lambdasinaction/chap5/BuildingStreamsTest.java create mode 100644 src/test/java/lambdasinaction/chap5/FilteringTest.java create mode 100644 src/test/java/lambdasinaction/chap5/FindingTest.java create mode 100644 src/test/java/lambdasinaction/chap5/LazinessTest.java create mode 100644 src/test/java/lambdasinaction/chap5/MappingTest.java create mode 100644 src/test/java/lambdasinaction/chap5/NumericStreamsTest.java create mode 100644 src/test/java/lambdasinaction/chap5/PuttingIntoPracticeTest.java create mode 100644 src/test/java/lambdasinaction/chap5/ReducingTest.java create mode 100644 src/test/java/lambdasinaction/chap5/TraderTest.java create mode 100644 src/test/java/lambdasinaction/chap5/TransactionTest.java create mode 100644 src/test/java/lambdasinaction/chap6/CollectorHarnessTest.java create mode 100644 src/test/java/lambdasinaction/chap6/DishTest.java create mode 100644 src/test/java/lambdasinaction/chap6/GroupingTest.java create mode 100644 src/test/java/lambdasinaction/chap6/GroupingTransactionsTest.java create mode 100644 src/test/java/lambdasinaction/chap6/PartitionPrimeNumbersTest.java create mode 100644 src/test/java/lambdasinaction/chap6/PartitioningTest.java create mode 100644 src/test/java/lambdasinaction/chap6/ReducingTest.java create mode 100644 src/test/java/lambdasinaction/chap6/SummarizingTest.java create mode 100644 src/test/java/lambdasinaction/chap6/ToListCollectorTest.java create mode 100644 src/test/java/lambdasinaction/chap7/ForkJoinSumCalculatorTest.java create mode 100644 src/test/java/lambdasinaction/chap7/ParallelStreamsHarnessTest.java create mode 100644 src/test/java/lambdasinaction/chap7/ParallelStreamsTest.java create mode 100644 src/test/java/lambdasinaction/chap7/WordCountTest.java create mode 100644 src/test/java/lambdasinaction/chap8/ChainOfResponsibilityMainTest.java create mode 100644 src/test/java/lambdasinaction/chap8/DebuggingTest.java create mode 100644 src/test/java/lambdasinaction/chap8/FactoryMainTest.java create mode 100644 src/test/java/lambdasinaction/chap8/ObserverMainTest.java create mode 100644 src/test/java/lambdasinaction/chap8/OnlineBankingLambdaTest.java create mode 100644 src/test/java/lambdasinaction/chap8/OnlineBankingTest.java create mode 100644 src/test/java/lambdasinaction/chap8/PeekTest.java create mode 100644 src/test/java/lambdasinaction/chap8/StrategyMainTest.java create mode 100644 src/test/java/lambdasinaction/chap9/AmbiguousTest.java create mode 100644 src/test/java/lambdasinaction/chap9/DiamondTest.java create mode 100644 src/test/java/lambdasinaction/chap9/DrawableTest.java create mode 100644 src/test/java/lambdasinaction/chap9/EllipseTest.java create mode 100644 src/test/java/lambdasinaction/chap9/GameTest.java create mode 100644 src/test/java/lambdasinaction/chap9/IntroTest.java create mode 100644 src/test/java/lambdasinaction/chap9/LetterTest.java create mode 100644 src/test/java/lambdasinaction/chap9/MostSpecificTest.java create mode 100644 src/test/java/lambdasinaction/chap9/ResizableTest.java create mode 100644 src/test/java/lambdasinaction/chap9/SquareTest.java create mode 100644 src/test/java/lambdasinaction/chap9/TriangleTest.java create mode 100644 src/test/java/lambdasinaction/chap9/UtilsTest.java create mode 100644 src/test/java/lambdasinaction/dsl/GroupingTest.java create mode 100644 src/test/java/lambdasinaction/dsl/LambdaOrderBuilderTest.java create mode 100644 src/test/java/lambdasinaction/dsl/MainTest.java create mode 100644 src/test/java/lambdasinaction/dsl/MethodChainingOrderBuilderTest.java create mode 100644 src/test/java/lambdasinaction/dsl/MixedBuilderTest.java create mode 100644 src/test/java/lambdasinaction/dsl/MixedTest.java create mode 100644 src/test/java/lambdasinaction/dsl/NestedFunctionOrderBuilderTest.java create mode 100644 src/test/java/lambdasinaction/dsl/TaxCalculatorTest.java create mode 100644 src/test/java/lambdasinaction/dsl/model/OrderTest.java create mode 100644 src/test/java/lambdasinaction/dsl/model/StockTest.java create mode 100644 src/test/java/lambdasinaction/dsl/model/TaxTest.java create mode 100644 src/test/java/lambdasinaction/dsl/model/TradeTest.java diff --git a/src/main/java/lambdasinaction/appc/StreamForker.java b/src/main/java/lambdasinaction/appc/StreamForker.java index d8ed124c..7dc4e123 100644 --- a/src/main/java/lambdasinaction/appc/StreamForker.java +++ b/src/main/java/lambdasinaction/appc/StreamForker.java @@ -13,7 +13,7 @@ public class StreamForker { private final Stream stream; private final Map, ?>> forks = new HashMap<>(); - public StreamForker(Stream stream) { + public StreamForker(Stream stream) { this.stream = stream; } diff --git a/src/main/java/lambdasinaction/chap10/ReadPositiveIntParam.java b/src/main/java/lambdasinaction/chap10/ReadPositiveIntParam.java index acac12b9..f703392d 100644 --- a/src/main/java/lambdasinaction/chap10/ReadPositiveIntParam.java +++ b/src/main/java/lambdasinaction/chap10/ReadPositiveIntParam.java @@ -1,11 +1,15 @@ package lambdasinaction.chap10; -import org.junit.*; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; +import static org.junit.jupiter.api.Assertions.assertEquals; -import java.util.*; +import java.util.Optional; +import java.util.Properties; + +import org.junit.jupiter.api.Test; -import static java.util.Optional.*; -import static org.junit.Assert.assertEquals; public class ReadPositiveIntParam { @@ -31,7 +35,7 @@ public static int readDurationImperative(Properties props, String name) { String value = props.getProperty(name); if (value != null) { try { - int i = Integer.parseInt(value); + Integer i = Integer.parseInt(value); if (i > 0) { return i; } diff --git a/src/main/java/lambdasinaction/chap4/Dish.java b/src/main/java/lambdasinaction/chap4/Dish.java index 96307644..5519b4f8 100644 --- a/src/main/java/lambdasinaction/chap4/Dish.java +++ b/src/main/java/lambdasinaction/chap4/Dish.java @@ -8,7 +8,7 @@ public class Dish { private final int calories; private final Type type; - public Dish(String name, boolean vegetarian, int calories, Type type) { + public Dish(String name, boolean vegetarian, int calories, Type type) { this.name = name; this.vegetarian = vegetarian; this.calories = calories; diff --git a/src/main/java/lambdasinaction/chap5/BuildingStreams.java b/src/main/java/lambdasinaction/chap5/BuildingStreams.java index 15280a39..735c30ee 100644 --- a/src/main/java/lambdasinaction/chap5/BuildingStreams.java +++ b/src/main/java/lambdasinaction/chap5/BuildingStreams.java @@ -8,7 +8,7 @@ public class BuildingStreams { - public static void main(String...args) throws Exception{ + public static void main(String...args) throws Exception{ // Stream.of Stream stream = Stream.of("Java 8", "Lambdas", "In", "Action"); diff --git a/src/main/java/lambdasinaction/chap5/Finding.java b/src/main/java/lambdasinaction/chap5/Finding.java index acccc543..081a7ece 100644 --- a/src/main/java/lambdasinaction/chap5/Finding.java +++ b/src/main/java/lambdasinaction/chap5/Finding.java @@ -8,7 +8,7 @@ public class Finding{ - public static void main(String...args){ + public static void main(String...args){ if(isVegetarianFriendlyMenu()){ System.out.println("Vegetarian friendly"); } diff --git a/src/main/java/lambdasinaction/chap6/Dish.java b/src/main/java/lambdasinaction/chap6/Dish.java index a353f1bc..1f786fcf 100644 --- a/src/main/java/lambdasinaction/chap6/Dish.java +++ b/src/main/java/lambdasinaction/chap6/Dish.java @@ -9,7 +9,7 @@ public class Dish { private final int calories; private final Type type; - public Dish(String name, boolean vegetarian, int calories, Type type) { + public Dish(String name, boolean vegetarian, int calories, Type type) { this.name = name; this.vegetarian = vegetarian; this.calories = calories; diff --git a/src/main/java/lambdasinaction/chap6/Grouping.java b/src/main/java/lambdasinaction/chap6/Grouping.java index bedb3470..b2887107 100644 --- a/src/main/java/lambdasinaction/chap6/Grouping.java +++ b/src/main/java/lambdasinaction/chap6/Grouping.java @@ -9,7 +9,7 @@ public class Grouping { enum CaloricLevel { DIET, NORMAL, FAT }; - public static void main(String ... args) { + public static void main(String ... args) { System.out.println("Dishes grouped by type: " + groupDishesByType()); System.out.println("Dishes grouped by caloric level: " + groupDishesByCaloricLevel()); System.out.println("Dishes grouped by type and caloric level: " + groupDishedByTypeAndCaloricLevel()); @@ -20,7 +20,7 @@ public static void main(String ... args) { System.out.println("Caloric levels by type: " + caloricLevelsByType()); } - private static Map> groupDishesByType() { + private static Map> groupDishesByType() { return menu.stream().collect(groupingBy(Dish::getType)); } diff --git a/src/main/java/lambdasinaction/chap8/OnlineBankingLambda.java b/src/main/java/lambdasinaction/chap8/OnlineBankingLambda.java index 3bd9e049..dcd73ec4 100644 --- a/src/main/java/lambdasinaction/chap8/OnlineBankingLambda.java +++ b/src/main/java/lambdasinaction/chap8/OnlineBankingLambda.java @@ -15,7 +15,7 @@ public void processCustomer(int id, Consumer makeCustomerHappy){ } // dummy Customer class - static private class Customer {} + static class Customer {} // dummy Database class static private class Database{ static Customer getCustomerWithId(int id){ return new Customer();} diff --git a/src/main/java/lambdasinaction/dsl/Grouping.java b/src/main/java/lambdasinaction/dsl/Grouping.java index b1472cf0..db36ab0e 100644 --- a/src/main/java/lambdasinaction/dsl/Grouping.java +++ b/src/main/java/lambdasinaction/dsl/Grouping.java @@ -48,7 +48,7 @@ private static Map>> groupDishedByTypeAn ); } - public static Collector>>> twoLevelGroupingBy(Function f1, Function f2) { + public static Collector>>> twoLevelGroupingBy(Function f1, Function f2) { return groupingBy(f1, groupingBy(f2)); } diff --git a/src/test/java/lambdasinaction/appa/BookTest.java b/src/test/java/lambdasinaction/appa/BookTest.java new file mode 100644 index 00000000..852b41e2 --- /dev/null +++ b/src/test/java/lambdasinaction/appa/BookTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.appa; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BookTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + Book.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/appc/StreamForkerExampleTest.java b/src/test/java/lambdasinaction/appc/StreamForkerExampleTest.java new file mode 100644 index 00000000..22ff5976 --- /dev/null +++ b/src/test/java/lambdasinaction/appc/StreamForkerExampleTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.appc; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class StreamForkerExampleTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + StreamForkerExample.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/appc/StreamForkerTest.java b/src/test/java/lambdasinaction/appc/StreamForkerTest.java new file mode 100644 index 00000000..c3894f4f --- /dev/null +++ b/src/test/java/lambdasinaction/appc/StreamForkerTest.java @@ -0,0 +1,63 @@ +package lambdasinaction.appc; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.function.Function; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class StreamForkerTest { + @Test + public void testStreamForker_1() + throws Exception { + Stream stream = mock(Stream.class); + // add mock object expectations here + + + StreamForker result = new StreamForker(stream); + + assertNotNull(result); + } + + @Test + public void testFork_1() + throws Exception { + StreamForker fixture = new StreamForker(mock(Stream.class)); + Object key = mock(Object.class); + Function, Object> f = mock(Function.class); + // add mock object expectations here + + + StreamForker result = fixture.fork(key, f); + + assertNotNull(result); + } + + @Test + public void testGetResults_1() + throws Exception { + StreamForker fixture = new StreamForker(mock(Stream.class)); + + StreamForker.Results result = fixture.getResults(); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.appc.StreamForker.getResults(StreamForker.java:28) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/appd/InnerClassTest.java b/src/test/java/lambdasinaction/appd/InnerClassTest.java new file mode 100644 index 00000000..36cb99b8 --- /dev/null +++ b/src/test/java/lambdasinaction/appd/InnerClassTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.appd; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class InnerClassTest { + @Test + public void testInnerClass_1() + throws Exception { + InnerClass result = new InnerClass(); + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/appd/LambdaTest.java b/src/test/java/lambdasinaction/appd/LambdaTest.java new file mode 100644 index 00000000..bc20e121 --- /dev/null +++ b/src/test/java/lambdasinaction/appd/LambdaTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.appd; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class LambdaTest { + @Test + public void testLambda_1() + throws Exception { + Lambda result = new Lambda(); + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap1/FilteringApplesTest.java b/src/test/java/lambdasinaction/chap1/FilteringApplesTest.java new file mode 100644 index 00000000..11fb122d --- /dev/null +++ b/src/test/java/lambdasinaction/chap1/FilteringApplesTest.java @@ -0,0 +1,210 @@ +package lambdasinaction.chap1; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.List; +import java.util.function.Predicate; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class FilteringApplesTest { + @Test + public void testFilterApples_1() + throws Exception { + List inventory = mock(List.class); + Predicate p = mock(Predicate.class); + // add mock object expectations here + + + List result = FilteringApples.filterApples(inventory, p); + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterApples(FilteringApples.java:66) + assertNotNull(result); + } + + @Test + public void testFilterApples_2() + throws Exception { + List inventory = mock(List.class); + Predicate p = mock(Predicate.class); + // add mock object expectations here + + + List result = FilteringApples.filterApples(inventory, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterApples(FilteringApples.java:66) + assertNotNull(result); + } + + @Test + public void testFilterApples_3() + throws Exception { + List inventory = mock(List.class); + Predicate p = mock(Predicate.class); + // add mock object expectations here + + + List result = FilteringApples.filterApples(inventory, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterApples(FilteringApples.java:66) + assertNotNull(result); + } + + @Test + public void testFilterGreenApples_1() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterGreenApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterGreenApples(FilteringApples.java:38) + assertNotNull(result); + } + + @Test + public void testFilterGreenApples_2() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterGreenApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterGreenApples(FilteringApples.java:38) + assertNotNull(result); + } + + @Test + public void testFilterGreenApples_3() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterGreenApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterGreenApples(FilteringApples.java:38) + assertNotNull(result); + } + + @Test + public void testFilterHeavyApples_1() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterHeavyApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterHeavyApples(FilteringApples.java:48) + assertNotNull(result); + } + + @Test + public void testFilterHeavyApples_2() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterHeavyApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterHeavyApples(FilteringApples.java:48) + assertNotNull(result); + } + + @Test + public void testFilterHeavyApples_3() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterHeavyApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap1.FilteringApples.filterHeavyApples(FilteringApples.java:48) + assertNotNull(result); + } + + @Test + public void testIsGreenApple_1() + throws Exception { + FilteringApples.Apple apple = new FilteringApples.Apple(1, "green"); + + boolean result = FilteringApples.isGreenApple(apple); + + assertEquals(true, result); + } + + @Test + public void testIsGreenApple_2() + throws Exception { + FilteringApples.Apple apple = new FilteringApples.Apple(1, ""); + + boolean result = FilteringApples.isGreenApple(apple); + + assertEquals(false, result); + } + + @Test + public void testIsHeavyApple_1() + throws Exception { + FilteringApples.Apple apple = new FilteringApples.Apple(151, ""); + + boolean result = FilteringApples.isHeavyApple(apple); + + assertEquals(true, result); + } + + @Test + public void testIsHeavyApple_2() + throws Exception { + FilteringApples.Apple apple = new FilteringApples.Apple(1, ""); + + boolean result = FilteringApples.isHeavyApple(apple); + + assertEquals(false, result); + } + + @Test + public void testMain_1() + throws Exception { + + FilteringApples.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap10/CarTest.java b/src/test/java/lambdasinaction/chap10/CarTest.java new file mode 100644 index 00000000..38e784b0 --- /dev/null +++ b/src/test/java/lambdasinaction/chap10/CarTest.java @@ -0,0 +1,32 @@ +package lambdasinaction.chap10; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Optional; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CarTest { + @Test + public void testGetInsurance_1() + throws Exception { + Car fixture = new Car(); + + Optional result = fixture.getInsurance(); + + assertEquals(null, result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap10/InsuranceTest.java b/src/test/java/lambdasinaction/chap10/InsuranceTest.java new file mode 100644 index 00000000..e34c9e64 --- /dev/null +++ b/src/test/java/lambdasinaction/chap10/InsuranceTest.java @@ -0,0 +1,30 @@ +package lambdasinaction.chap10; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class InsuranceTest { + @Test + public void testGetName_1() + throws Exception { + Insurance fixture = new Insurance(); + + String result = fixture.getName(); + + assertEquals(null, result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap10/OperationsWithOptionalTest.java b/src/test/java/lambdasinaction/chap10/OperationsWithOptionalTest.java new file mode 100644 index 00000000..7ea16a90 --- /dev/null +++ b/src/test/java/lambdasinaction/chap10/OperationsWithOptionalTest.java @@ -0,0 +1,43 @@ +package lambdasinaction.chap10; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.Optional; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class OperationsWithOptionalTest { + @Test + public void testMain_1() + throws Exception { + + OperationsWithOptional.main(); + + } + + @Test + public void testMax_1() + throws Exception { + Optional i = Optional.empty(); + Optional j = Optional.empty(); + + Optional result = OperationsWithOptional.max(i, j); + + assertNotNull(result); + assertEquals("Optional.empty", result.toString()); + assertEquals(false, result.isPresent()); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap10/OptionalMainTest.java b/src/test/java/lambdasinaction/chap10/OptionalMainTest.java new file mode 100644 index 00000000..327aa293 --- /dev/null +++ b/src/test/java/lambdasinaction/chap10/OptionalMainTest.java @@ -0,0 +1,33 @@ +package lambdasinaction.chap10; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Optional; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class OptionalMainTest { + @Test + public void testGetCarInsuranceName_1() + throws Exception { + OptionalMain fixture = new OptionalMain(); + Optional person = Optional.empty(); + + String result = fixture.getCarInsuranceName(person); + + assertEquals("Unknown", result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap10/PersonTest.java b/src/test/java/lambdasinaction/chap10/PersonTest.java new file mode 100644 index 00000000..b476c68d --- /dev/null +++ b/src/test/java/lambdasinaction/chap10/PersonTest.java @@ -0,0 +1,32 @@ +package lambdasinaction.chap10; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Optional; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PersonTest { + @Test + public void testGetCar_1() + throws Exception { + Person fixture = new Person(); + + Optional result = fixture.getCar(); + + assertEquals(null, result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/AsyncShopClientTest.java b/src/test/java/lambdasinaction/chap11/AsyncShopClientTest.java new file mode 100644 index 00000000..2393d967 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/AsyncShopClientTest.java @@ -0,0 +1,30 @@ +package lambdasinaction.chap11; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class AsyncShopClientTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + AsyncShopClient.main(args); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: product not available + // at lambdasinaction.chap11.AsyncShopClient.main(AsyncShopClient.java:16) + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/AsyncShopTest.java b/src/test/java/lambdasinaction/chap11/AsyncShopTest.java new file mode 100644 index 00000000..f56feec1 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/AsyncShopTest.java @@ -0,0 +1,47 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.concurrent.Future; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class AsyncShopTest { + @Test + public void testAsyncShop_1() + throws Exception { + String name = "aaaa"; + + AsyncShop result = new AsyncShop(name); + + assertNotNull(result); + } + + @Test + public void testGetPrice_1() + throws Exception { + AsyncShop fixture = new AsyncShop(""); + String product = ""; + + Future result = fixture.getPrice(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.AsyncShop.(AsyncShop.java:17) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/BestPriceFinderMainTest.java b/src/test/java/lambdasinaction/chap11/BestPriceFinderMainTest.java new file mode 100644 index 00000000..aba34d85 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/BestPriceFinderMainTest.java @@ -0,0 +1,36 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BestPriceFinderMainTest { + @Test + public void testBestPriceFinderMain_1() + throws Exception { + BestPriceFinderMain result = new BestPriceFinderMain(); + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + BestPriceFinderMain.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/BestPriceFinderTest.java b/src/test/java/lambdasinaction/chap11/BestPriceFinderTest.java new file mode 100644 index 00000000..1a8a8c9e --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/BestPriceFinderTest.java @@ -0,0 +1,155 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Stream; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BestPriceFinderTest { + @Test + public void testBestPriceFinder_1() + throws Exception { + BestPriceFinder result = new BestPriceFinder(); + assertNotNull(result); + } + + @Test + public void testFindPricesFuture_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesFuture(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) + // at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + // at java.lang.Thread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.Shop.calculatePrice(Shop.java:26) + // at lambdasinaction.chap11.Shop.getPrice(Shop.java:19) + // at lambdasinaction.chap11.BestPriceFinder.lambda$7(BestPriceFinder.java:56) + // at lambdasinaction.chap11.BestPriceFinder$$Lambda$284/2064947022.get(Unknown Source) + // ... 4 more + assertNotNull(result); + } + + @Test + public void testFindPricesParallel_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesParallel(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.Shop.calculatePrice(Shop.java:26) + // at lambdasinaction.chap11.Shop.getPrice(Shop.java:19) + // at lambdasinaction.chap11.BestPriceFinder.lambda$1(BestPriceFinder.java:39) + // at lambdasinaction.chap11.BestPriceFinder$$Lambda$278/656460878.apply(Unknown Source) + // at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) + // at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) + // at java.util.stream.AbstractPipeline.copyInto(Unknown Source) + // at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) + // at java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source) + // at java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source) + // at java.util.stream.AbstractTask.compute(Unknown Source) + // at java.util.concurrent.CountedCompleter.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doInvoke(Unknown Source) + // at java.util.concurrent.ForkJoinTask.invoke(Unknown Source) + // at java.util.stream.ReduceOps$ReduceOp.evaluateParallel(Unknown Source) + // at java.util.stream.AbstractPipeline.evaluate(Unknown Source) + // at java.util.stream.ReferencePipeline.collect(Unknown Source) + // at lambdasinaction.chap11.BestPriceFinder.findPricesParallel(BestPriceFinder.java:42) + assertNotNull(result); + } + + @Test + public void testFindPricesSequential_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesSequential(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.Shop.calculatePrice(Shop.java:26) + // at lambdasinaction.chap11.Shop.getPrice(Shop.java:19) + // at lambdasinaction.chap11.BestPriceFinder.lambda$0(BestPriceFinder.java:31) + // at lambdasinaction.chap11.BestPriceFinder$$Lambda$275/418866340.apply(Unknown Source) + // at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) + // at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) + // at java.util.stream.AbstractPipeline.copyInto(Unknown Source) + // at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) + // at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) + // at java.util.stream.AbstractPipeline.evaluate(Unknown Source) + // at java.util.stream.ReferencePipeline.collect(Unknown Source) + // at lambdasinaction.chap11.BestPriceFinder.findPricesSequential(BestPriceFinder.java:34) + assertNotNull(result); + } + + @Test + public void testFindPricesStream_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + Stream> result = fixture.findPricesStream(product); + + assertNotNull(result); + assertEquals(5L, result.count()); + assertEquals(false, result.isParallel()); + } + + @Test + public void testPrintPricesStream_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + fixture.printPricesStream(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) + // at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + // at java.lang.Thread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.Shop.calculatePrice(Shop.java:26) + // at lambdasinaction.chap11.Shop.getPrice(Shop.java:19) + // at lambdasinaction.chap11.BestPriceFinder.lambda$7(BestPriceFinder.java:56) + // at lambdasinaction.chap11.BestPriceFinder$$Lambda$284/2064947022.get(Unknown Source) + // ... 4 more + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/DiscountTest.java b/src/test/java/lambdasinaction/chap11/DiscountTest.java new file mode 100644 index 00000000..7df433f7 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/DiscountTest.java @@ -0,0 +1,30 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DiscountTest { + @Test + public void testApplyDiscount_1() + throws Exception { + Quote quote = new Quote("", 1.0, Discount.Code.DIAMOND); + + String result = Discount.applyDiscount(quote); + + assertEquals(" price is 0.8", result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/ExchangeServiceTest.java b/src/test/java/lambdasinaction/chap11/ExchangeServiceTest.java new file mode 100644 index 00000000..3e6bc140 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/ExchangeServiceTest.java @@ -0,0 +1,31 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ExchangeServiceTest { + @Test + public void testGetRate_1() + throws Exception { + ExchangeService.Money source = ExchangeService.Money.CAD; + ExchangeService.Money destination = ExchangeService.Money.CAD; + + double result = ExchangeService.getRate(source, destination); + + assertEquals(1.0, result, 0.1); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/QuoteTest.java b/src/test/java/lambdasinaction/chap11/QuoteTest.java new file mode 100644 index 00000000..64f28112 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/QuoteTest.java @@ -0,0 +1,94 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class QuoteTest { + @Test + public void testQuote_1() + throws Exception { + String shopName = ""; + double price = 1.0; + Discount.Code discountCode = Discount.Code.DIAMOND; + + Quote result = new Quote(shopName, price, discountCode); + + assertNotNull(result); + assertEquals("", result.getShopName()); + assertEquals(1.0, result.getPrice(), 1.0); + } + + @Test + public void testGetDiscountCode_1() + throws Exception { + Quote fixture = new Quote("", 1.0, Discount.Code.DIAMOND); + + Discount.Code result = fixture.getDiscountCode(); + + assertNotNull(result); + assertEquals("DIAMOND", result.name()); + assertEquals("DIAMOND", result.toString()); + assertEquals(4, result.ordinal()); + } + + @Test + public void testGetPrice_1() + throws Exception { + Quote fixture = new Quote("", 1.0, Discount.Code.DIAMOND); + + double result = fixture.getPrice(); + + assertEquals(1.0, result, 0.1); + } + + @Test + public void testGetShopName_1() + throws Exception { + Quote fixture = new Quote("", 1.0, Discount.Code.DIAMOND); + + String result = fixture.getShopName(); + + assertEquals("", result); + } + + @Test + public void testParse_1() + throws Exception { + String s = ""; + + Quote result = Quote.parse(s); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.ArrayIndexOutOfBoundsException: 1 + // at lambdasinaction.chap11.Quote.parse(Quote.java:18) + assertNotNull(result); + } + + @Test + public void testParse_2() + throws Exception { + String s = ""; + + Quote result = Quote.parse(s); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.ArrayIndexOutOfBoundsException: 1 + // at lambdasinaction.chap11.Quote.parse(Quote.java:18) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/ShopTest.java b/src/test/java/lambdasinaction/chap11/ShopTest.java new file mode 100644 index 00000000..26c7b931 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/ShopTest.java @@ -0,0 +1,76 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ShopTest { + @Test + public void testShop_1() + throws Exception { + String name = "aaaa"; + + Shop result = new Shop(name); + + assertNotNull(result); + assertEquals("aaaa", result.getName()); + } + + @Test + public void testCalculatePrice_1() + throws Exception { + Shop fixture = new Shop(""); + String product = "aaa"; + + double result = fixture.calculatePrice(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.Shop.(Shop.java:15) + assertEquals(0.0, result, 0.1); + } + + @Test + public void testGetName_1() + throws Exception { + Shop fixture = new Shop(""); + + String result = fixture.getName(); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.Shop.(Shop.java:15) + assertNotNull(result); + } + + @Test + public void testGetPrice_1() + throws Exception { + Shop fixture = new Shop(""); + String product = ""; + + String result = fixture.getPrice(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.Shop.(Shop.java:15) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/UtilTest.java b/src/test/java/lambdasinaction/chap11/UtilTest.java new file mode 100644 index 00000000..49ac7f59 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/UtilTest.java @@ -0,0 +1,84 @@ +package lambdasinaction.chap11; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.List; +import java.util.concurrent.CompletableFuture; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class UtilTest { + @Test + public void testUtil_1() + throws Exception { + Util result = new Util(); + assertNotNull(result); + } + + @Test + public void testDelay_1() + throws Exception { + + Util.delay(); + + } + + @Test + public void testDelay_2() + throws Exception { + + Util.delay(); + + } + + @Test + public void testFormat_1() + throws Exception { + double number = 1.0; + + double result = Util.format(number); + + assertEquals(1.0, result, 0.1); + } + + @Test + public void testFormat_2() + throws Exception { + double number = 1.0; + + double result = Util.format(number); + + assertEquals(1.0, result, 0.1); + } + + @Test + public void testSequence_1() + throws Exception { + List> futures = mock(List.class); + // add mock object expectations here + + + CompletableFuture> result = Util.sequence(futures); + + assertNotNull(result); + assertEquals(false, result.isCancelled()); + assertEquals(true, result.isDone()); + assertEquals(0, result.getNumberOfDependents()); + assertEquals(true, result.isCompletedExceptionally()); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/v1/BestPriceFinderMainTest.java b/src/test/java/lambdasinaction/chap11/v1/BestPriceFinderMainTest.java new file mode 100644 index 00000000..b0bb7ca7 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/v1/BestPriceFinderMainTest.java @@ -0,0 +1,36 @@ +package lambdasinaction.chap11.v1; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BestPriceFinderMainTest { + @Test + public void testBestPriceFinderMain_1() + throws Exception { + BestPriceFinderMain result = new BestPriceFinderMain(); + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + BestPriceFinderMain.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/v1/BestPriceFinderTest.java b/src/test/java/lambdasinaction/chap11/v1/BestPriceFinderTest.java new file mode 100644 index 00000000..0c84f621 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/v1/BestPriceFinderTest.java @@ -0,0 +1,291 @@ +package lambdasinaction.chap11.v1; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BestPriceFinderTest { + @Test + public void testBestPriceFinder_1() + throws Exception { + BestPriceFinder result = new BestPriceFinder(); + assertNotNull(result); + } + + @Test + public void testFindPricesFuture_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesFuture(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) + // at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) + // at java.lang.Thread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$12(BestPriceFinder.java:53) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$379/579314863.get(Unknown Source) + // ... 4 more + assertNotNull(result); + } + + @Test + public void testFindPricesInUSD_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSD(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) + // at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) + // at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$3(BestPriceFinder.java:70) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$381/173024885.get(Unknown Source) + // ... 6 more + assertNotNull(result); + } + + @Test + public void testFindPricesInUSD_2() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSD(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) + // at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) + // at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$3(BestPriceFinder.java:70) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$381/173024885.get(Unknown Source) + // ... 6 more + assertNotNull(result); + } + + @Test + public void testFindPricesInUSD2_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSD2(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) + // at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) + // at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$7(BestPriceFinder.java:128) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$386/2131039473.get(Unknown Source) + // ... 6 more + assertNotNull(result); + } + + @Test + public void testFindPricesInUSD2_2() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSD2(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) + // at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) + // at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$7(BestPriceFinder.java:128) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$386/2131039473.get(Unknown Source) + // ... 6 more + assertNotNull(result); + } + + @Test + public void testFindPricesInUSD3_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSD3(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.util.concurrent.CompletionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source) + // at java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source) + // at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source) + // at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source) + // Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$13(BestPriceFinder.java:148) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$392/854656383.get(Unknown Source) + // ... 6 more + assertNotNull(result); + } + + @Test + public void testFindPricesInUSDJava7_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSDJava7(product); + + assertNotNull(result); + assertEquals(0, result.size()); + } + + @Test + public void testFindPricesInUSDJava7_2() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSDJava7(product); + + assertNotNull(result); + assertEquals(0, result.size()); + } + + @Test + public void testFindPricesInUSDJava7_3() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesInUSDJava7(product); + + assertNotNull(result); + assertEquals(0, result.size()); + } + + @Test + public void testFindPricesParallel_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesParallel(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$1(BestPriceFinder.java:45) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$377/1774483465.apply(Unknown Source) + // at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) + // at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) + // at java.util.stream.AbstractPipeline.copyInto(Unknown Source) + // at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) + // at java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source) + // at java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source) + // at java.util.stream.AbstractTask.compute(Unknown Source) + // at java.util.concurrent.CountedCompleter.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doInvoke(Unknown Source) + // at java.util.concurrent.ForkJoinTask.invoke(Unknown Source) + // at java.util.stream.ReduceOps$ReduceOp.evaluateParallel(Unknown Source) + // at java.util.stream.AbstractPipeline.evaluate(Unknown Source) + // at java.util.stream.ReferencePipeline.collect(Unknown Source) + // at lambdasinaction.chap11.v1.BestPriceFinder.findPricesParallel(BestPriceFinder.java:46) + assertNotNull(result); + } + + @Test + public void testFindPricesSequential_1() + throws Exception { + BestPriceFinder fixture = new BestPriceFinder(); + String product = ""; + + List result = fixture.findPricesSequential(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.calculatePrice(Shop.java:25) + // at lambdasinaction.chap11.v1.Shop.getPrice(Shop.java:20) + // at lambdasinaction.chap11.v1.BestPriceFinder.lambda$0(BestPriceFinder.java:39) + // at lambdasinaction.chap11.v1.BestPriceFinder$$Lambda$376/2024453511.apply(Unknown Source) + // at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) + // at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) + // at java.util.stream.AbstractPipeline.copyInto(Unknown Source) + // at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) + // at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) + // at java.util.stream.AbstractPipeline.evaluate(Unknown Source) + // at java.util.stream.ReferencePipeline.collect(Unknown Source) + // at lambdasinaction.chap11.v1.BestPriceFinder.findPricesSequential(BestPriceFinder.java:40) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/v1/ShopMainTest.java b/src/test/java/lambdasinaction/chap11/v1/ShopMainTest.java new file mode 100644 index 00000000..c6746c35 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/v1/ShopMainTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap11.v1; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ShopMainTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + ShopMain.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap11/v1/ShopTest.java b/src/test/java/lambdasinaction/chap11/v1/ShopTest.java new file mode 100644 index 00000000..7baa5339 --- /dev/null +++ b/src/test/java/lambdasinaction/chap11/v1/ShopTest.java @@ -0,0 +1,77 @@ +package lambdasinaction.chap11.v1; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.concurrent.Future; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +public class ShopTest { + @Test + public void testShop_1() + throws Exception { + String name = "aaaa"; + + Shop result = new Shop(name); + + assertNotNull(result); + assertEquals("aaaa", result.getName()); + } + + @Test + public void testGetName_1() + throws Exception { + Shop fixture = new Shop(""); + + String result = fixture.getName(); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.(Shop.java:16) + assertNotNull(result); + } + + @Test + public void testGetPrice_1() + throws Exception { + Shop fixture = new Shop(""); + String product = ""; + + double result = fixture.getPrice(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.(Shop.java:16) + assertEquals(0.0, result, 0.1); + } + + @Test + public void testGetPriceAsync_1() + throws Exception { + Shop fixture = new Shop(""); + String product = ""; + + Future result = fixture.getPriceAsync(product); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap11.v1.Shop.(Shop.java:16) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap12/DateTimeExamplesTest.java b/src/test/java/lambdasinaction/chap12/DateTimeExamplesTest.java new file mode 100644 index 00000000..33f4c930 --- /dev/null +++ b/src/test/java/lambdasinaction/chap12/DateTimeExamplesTest.java @@ -0,0 +1,36 @@ +package lambdasinaction.chap12; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DateTimeExamplesTest { + @Test + public void testDateTimeExamples_1() + throws Exception { + DateTimeExamples result = new DateTimeExamples(); + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + DateTimeExamples.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap13/RecursionTest.java b/src/test/java/lambdasinaction/chap13/RecursionTest.java new file mode 100644 index 00000000..415711ae --- /dev/null +++ b/src/test/java/lambdasinaction/chap13/RecursionTest.java @@ -0,0 +1,112 @@ +package lambdasinaction.chap13; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class RecursionTest { + @Test + public void testFactorialHelper_1() + throws Exception { + long acc = 1L; + long n = 2L; + + long result = Recursion.factorialHelper(acc, n); + + assertEquals(2L, result); + } + + @Test + public void testFactorialHelper_2() + throws Exception { + long acc = 1L; + long n = 1; + + long result = Recursion.factorialHelper(acc, n); + + assertEquals(1L, result); + } + + @Test + public void testFactorialIterative_1() + throws Exception { + int n = 1; + + int result = Recursion.factorialIterative(n); + + assertEquals(1, result); + } + + @Test + public void testFactorialIterative_2() + throws Exception { + int n = 0; + + int result = Recursion.factorialIterative(n); + + assertEquals(1, result); + } + + @Test + public void testFactorialRecursive_1() + throws Exception { + long n = 2L; + + long result = Recursion.factorialRecursive(n); + + assertEquals(2L, result); + } + + @Test + public void testFactorialRecursive_2() + throws Exception { + long n = 1; + + long result = Recursion.factorialRecursive(n); + + assertEquals(1L, result); + } + + @Test + public void testFactorialStreams_1() + throws Exception { + long n = 1L; + + long result = Recursion.factorialStreams(n); + + assertEquals(1L, result); + } + + @Test + public void testFactorialTailRecursive_1() + throws Exception { + long n = 1L; + + long result = Recursion.factorialTailRecursive(n); + + assertEquals(1L, result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + Recursion.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap13/SubsetsMainTest.java b/src/test/java/lambdasinaction/chap13/SubsetsMainTest.java new file mode 100644 index 00000000..c0d8cd7b --- /dev/null +++ b/src/test/java/lambdasinaction/chap13/SubsetsMainTest.java @@ -0,0 +1,117 @@ +package lambdasinaction.chap13; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class SubsetsMainTest { + @Test + public void testConcat_1() + throws Exception { + List> a = mock(List.class); + List> b = mock(List.class); + // add mock object expectations here + + + List> result = SubsetsMain.concat(a, b); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at java.util.ArrayList.(Unknown Source) + // at lambdasinaction.chap13.SubsetsMain.concat(SubsetsMain.java:40) + assertNotNull(result); + } + + @Test + public void testInsertAll_1() + throws Exception { + Integer first = new Integer(1); + List> lists = mock(List.class); + // add mock object expectations here + + + List> result = SubsetsMain.insertAll(first, lists); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap13.SubsetsMain.insertAll(SubsetsMain.java:30) + assertNotNull(result); + } + + @Test + public void testInsertAll_2() + throws Exception { + Integer first = new Integer(1); + List> lists = mock(List.class); + // add mock object expectations here + + + List> result = SubsetsMain.insertAll(first, lists); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap13.SubsetsMain.insertAll(SubsetsMain.java:30) + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + SubsetsMain.main(args); + + } + + @Test + public void testSubsets_1() + throws Exception { + List l = mock(List.class); + // add mock object expectations here + + + List> result = SubsetsMain.subsets(l); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.IllegalStateException: missing behavior definition for the preceding method call isEmpty() + // at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:41) + // at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:72) + // at com.sun.proxy.$Proxy59.get(Unknown Source) + // at lambdasinaction.chap13.SubsetsMain.subsets(SubsetsMain.java:21) + assertNotNull(result); + } + + @Test + public void testSubsets_2() + throws Exception { + List l = mock(List.class); + // add mock object expectations here + + + List> result = SubsetsMain.subsets(l); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.IllegalStateException: missing behavior definition for the preceding method call isEmpty() + // at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:41) + // at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:72) + // at com.sun.proxy.$Proxy59.get(Unknown Source) + // at lambdasinaction.chap13.SubsetsMain.subsets(SubsetsMain.java:21) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap14/CombinatorsTest.java b/src/test/java/lambdasinaction/chap14/CombinatorsTest.java new file mode 100644 index 00000000..74285f40 --- /dev/null +++ b/src/test/java/lambdasinaction/chap14/CombinatorsTest.java @@ -0,0 +1,71 @@ +package lambdasinaction.chap14; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.function.Function; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CombinatorsTest { + @Test + public void testCompose_1() + throws Exception { + Function g = mock(Function.class); + Function f = mock(Function.class); + // add mock object expectations here + + + Function result = Combinators.compose(g, f); + + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + Combinators.main(args); + + } + + @Test + public void testRepeat_1() + throws Exception { + int n = 1; + Function f = mock(Function.class); + // add mock object expectations here + + + Function result = Combinators.repeat(n, f); + + assertNotNull(result); + } + + @Test + public void testRepeat_2() + throws Exception { + int n = 0; + Function f = mock(Function.class); + // add mock object expectations here + + + Function result = Combinators.repeat(n, f); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap14/CurryingTest.java b/src/test/java/lambdasinaction/chap14/CurryingTest.java new file mode 100644 index 00000000..798260d3 --- /dev/null +++ b/src/test/java/lambdasinaction/chap14/CurryingTest.java @@ -0,0 +1,67 @@ +package lambdasinaction.chap14; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.function.DoubleUnaryOperator; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CurryingTest { + @Test + public void testConverter_1() + throws Exception { + double x = 1.0; + double y = 1.0; + double z = 1.0; + + double result = Currying.converter(x, y, z); + + assertEquals(2.0, result, 0.1); + } + + @Test + public void testCurriedConverter_1() + throws Exception { + double y = 1.0; + double z = 1.0; + + DoubleUnaryOperator result = Currying.curriedConverter(y, z); + + assertNotNull(result); + } + + @Test + public void testExpandedCurriedConverter_1() + throws Exception { + double w = 1.0; + double y = 1.0; + double z = 1.0; + + DoubleUnaryOperator result = Currying.expandedCurriedConverter(w, y, z); + + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + Currying.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap14/LazyListsTest.java b/src/test/java/lambdasinaction/chap14/LazyListsTest.java new file mode 100644 index 00000000..e90b577e --- /dev/null +++ b/src/test/java/lambdasinaction/chap14/LazyListsTest.java @@ -0,0 +1,90 @@ +package lambdasinaction.chap14; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class LazyListsTest { + @Test + public void testFrom_1() + throws Exception { + int n = 1; + + LazyLists.LazyList result = LazyLists.from(n); + + assertNotNull(result); + assertEquals(false, result.isEmpty()); + assertEquals(new Integer(1), result.head()); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + LazyLists.main(args); + + } + + @Test + public void testPrimes_1() + throws Exception { + LazyLists.MyList numbers = mock(LazyLists.MyList.class); + // add mock object expectations here + + + LazyLists.MyList result = LazyLists.primes(numbers); + + assertNotNull(result); + assertEquals(false, result.isEmpty()); + assertEquals(null, result.head()); + } + + @Test + public void testPrintAll_1() + throws Exception { + LazyLists.MyList numbers = mock(LazyLists.MyList.class); + // add mock object expectations here + + + LazyLists.printAll(numbers); + // An unexpected exception was thrown in user code while executing this test: + // java.lang.IllegalStateException: missing behavior definition for the preceding method call isEmpty() + // at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:41) + // at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:72) + // at lambdasinaction.chap14.$Proxy64.head(Unknown Source) + // at lambdasinaction.chap14.LazyLists.printAll(LazyLists.java:125) + } + + @Test + public void testPrintAll_2() + throws Exception { + LazyLists.MyList numbers = mock(LazyLists.MyList.class); + // add mock object expectations here + + + LazyLists.printAll(numbers); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.IllegalStateException: missing behavior definition for the preceding method call isEmpty() + // at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:41) + // at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:72) + // at lambdasinaction.chap14.$Proxy64.head(Unknown Source) + // at lambdasinaction.chap14.LazyLists.printAll(LazyLists.java:125) + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap14/PatternMatchingTest.java b/src/test/java/lambdasinaction/chap14/PatternMatchingTest.java new file mode 100644 index 00000000..bff69670 --- /dev/null +++ b/src/test/java/lambdasinaction/chap14/PatternMatchingTest.java @@ -0,0 +1,104 @@ +package lambdasinaction.chap14; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; + +import java.util.function.Function; +import java.util.function.Supplier; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PatternMatchingTest { + @Test + public void testMyIf_1() + throws Exception { + boolean b = false; + Supplier truecase = mock(Supplier.class); + Supplier falsecase = mock(Supplier.class); + // add mock object expectations here + + + Object result = PatternMatching.MyIf(b, truecase, falsecase); + + assertEquals(null, result); + } + + @Test + public void testMyIf_2() + throws Exception { + boolean b = true; + Supplier truecase = mock(Supplier.class); + Supplier falsecase = mock(Supplier.class); + // add mock object expectations here + + + Object result = PatternMatching.MyIf(b, truecase, falsecase); + + assertEquals(null, result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + PatternMatching.main(args); + + } + + @Test + public void testPatternMatchExpr_1() + throws Exception { + PatternMatching.Expr e = new PatternMatching.BinOp("", new PatternMatching.Expr(), new PatternMatching.Expr()); + PatternMatching.TriFunction binopcase = mock(PatternMatching.TriFunction.class); + Function numcase = mock(Function.class); + Supplier defaultcase = mock(Supplier.class); + // add mock object expectations here + + Object result = PatternMatching.patternMatchExpr(e, binopcase, numcase, defaultcase); + + assertEquals(null, result); + } + + @Test + public void testPatternMatchExpr_2() + throws Exception { + PatternMatching.Expr e = new PatternMatching.Number(1); + PatternMatching.TriFunction binopcase = mock(PatternMatching.TriFunction.class); + Function numcase = mock(Function.class); + Supplier defaultcase = mock(Supplier.class); + // add mock object expectations here + + + Object result = PatternMatching.patternMatchExpr(e, binopcase, numcase, defaultcase); + + assertEquals(null, result); + } + + @Test + public void testPatternMatchExpr_3() + throws Exception { + PatternMatching.Expr e = new PatternMatching.Expr(); + PatternMatching.TriFunction binopcase = mock(PatternMatching.TriFunction.class); + Function numcase = mock(Function.class); + Supplier defaultcase = mock(Supplier.class); + // add mock object expectations here + + + Object result = PatternMatching.patternMatchExpr(e, binopcase, numcase, defaultcase); + + assertEquals(null, result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap14/PersistentTrainJourneyTest.java b/src/test/java/lambdasinaction/chap14/PersistentTrainJourneyTest.java new file mode 100644 index 00000000..f4205285 --- /dev/null +++ b/src/test/java/lambdasinaction/chap14/PersistentTrainJourneyTest.java @@ -0,0 +1,100 @@ +package lambdasinaction.chap14; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.function.Consumer; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PersistentTrainJourneyTest { + @Test + public void testAppend_1() + throws Exception { + PersistentTrainJourney.TrainJourney a = new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(0, (PersistentTrainJourney.TrainJourney) null))); + PersistentTrainJourney.TrainJourney b = new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(0, (PersistentTrainJourney.TrainJourney) null)); + + PersistentTrainJourney.TrainJourney result = PersistentTrainJourney.append(a, b); + + assertNotNull(result); + } + + @Test + public void testAppend_2() + throws Exception { + PersistentTrainJourney.TrainJourney a = null; + PersistentTrainJourney.TrainJourney b = new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(0, (PersistentTrainJourney.TrainJourney) null)); + + PersistentTrainJourney.TrainJourney result = PersistentTrainJourney.append(a, b); + + assertNotNull(result); + } + + @Test + public void testLink_1() + throws Exception { + PersistentTrainJourney.TrainJourney a = null; + PersistentTrainJourney.TrainJourney b = new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(0, (PersistentTrainJourney.TrainJourney) null)); + + PersistentTrainJourney.TrainJourney result = PersistentTrainJourney.link(a, b); + + assertNotNull(result); + } + + @Test + public void testLink_2() + throws Exception { + PersistentTrainJourney.TrainJourney a = new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(0, (PersistentTrainJourney.TrainJourney) null))); + PersistentTrainJourney.TrainJourney b = new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(0, (PersistentTrainJourney.TrainJourney) null)); + + PersistentTrainJourney.TrainJourney result = PersistentTrainJourney.link(a, b); + + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + PersistentTrainJourney.main(args); + + } + + @Test + public void testVisit_1() + throws Exception { + PersistentTrainJourney.TrainJourney journey = new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(1, new PersistentTrainJourney.TrainJourney(0, (PersistentTrainJourney.TrainJourney) null))); + Consumer c = mock(Consumer.class); + // add mock object expectations here + + + PersistentTrainJourney.visit(journey, c); + + } + + @Test + public void testVisit_2() + throws Exception { + PersistentTrainJourney.TrainJourney journey = null; + Consumer c = mock(Consumer.class); + // add mock object expectations here + + + PersistentTrainJourney.visit(journey, c); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap14/PersistentTreeTest.java b/src/test/java/lambdasinaction/chap14/PersistentTreeTest.java new file mode 100644 index 00000000..3e88f8e2 --- /dev/null +++ b/src/test/java/lambdasinaction/chap14/PersistentTreeTest.java @@ -0,0 +1,174 @@ +package lambdasinaction.chap14; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PersistentTreeTest { + @Test + public void testFupdate_1() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + PersistentTree.Tree result = PersistentTree.fupdate(k, newval, t); + + assertNotNull(result); + } + + @Test + public void testFupdate_2() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + PersistentTree.Tree result = PersistentTree.fupdate(k, newval, t); + + assertNotNull(result); + } + + @Test + public void testFupdate_3() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + PersistentTree.Tree result = PersistentTree.fupdate(k, newval, t); + + assertNotNull(result); + } + + @Test + public void testFupdate_4() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = null; + + PersistentTree.Tree result = PersistentTree.fupdate(k, newval, t); + + assertNotNull(result); + } + + @Test + public void testLookup_1() + throws Exception { + String k = ""; + int defaultval = 1; + PersistentTree.Tree t = null; + + int result = PersistentTree.lookup(k, defaultval, t); + + assertEquals(1, result); + } + + @Test + public void testLookup_2() + throws Exception { + String k = ""; + int defaultval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + int result = PersistentTree.lookup(k, defaultval, t); + + assertEquals(1, result); + } + + @Test + public void testLookup_3() + throws Exception { + String k = ""; + int defaultval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + int result = PersistentTree.lookup(k, defaultval, t); + + assertEquals(1, result); + } + + @Test + public void testLookup_4() + throws Exception { + String k = ""; + int defaultval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + int result = PersistentTree.lookup(k, defaultval, t); + + assertEquals(1, result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + PersistentTree.main(args); + + } + + @Test + public void testUpdate_1() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + PersistentTree.Tree result = PersistentTree.update(k, newval, t); + + assertNotNull(result); + } + + @Test + public void testUpdate_2() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + PersistentTree.Tree result = PersistentTree.update(k, newval, t); + + assertNotNull(result); + } + + @Test + public void testUpdate_3() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null)), new PersistentTree.Tree("", 1, new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null), new PersistentTree.Tree("", 0, (PersistentTree.Tree) null, (PersistentTree.Tree) null))); + + PersistentTree.Tree result = PersistentTree.update(k, newval, t); + + assertNotNull(result); + } + + @Test + public void testUpdate_4() + throws Exception { + String k = ""; + int newval = 1; + PersistentTree.Tree t = null; + + PersistentTree.Tree result = PersistentTree.update(k, newval, t); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap2/FilteringApplesTest.java b/src/test/java/lambdasinaction/chap2/FilteringApplesTest.java new file mode 100644 index 00000000..77da0365 --- /dev/null +++ b/src/test/java/lambdasinaction/chap2/FilteringApplesTest.java @@ -0,0 +1,218 @@ +package lambdasinaction.chap2; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class FilteringApplesTest { + @Test + public void testFilter_1() + throws Exception { + List inventory = mock(List.class); + FilteringApples.ApplePredicate p = mock(FilteringApples.ApplePredicate.class); + // add mock object expectations here + + + List result = FilteringApples.filter(inventory, p); + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filter(FilteringApples.java:74) + assertNotNull(result); + } + + @Test + public void testFilter_2() + throws Exception { + List inventory = mock(List.class); + FilteringApples.ApplePredicate p = mock(FilteringApples.ApplePredicate.class); + // add mock object expectations here + + List result = FilteringApples.filter(inventory, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filter(FilteringApples.java:74) + assertNotNull(result); + } + + @Test + public void testFilter_3() + throws Exception { + List inventory = mock(List.class); + FilteringApples.ApplePredicate p = mock(FilteringApples.ApplePredicate.class); + // add mock object expectations here + + + List result = FilteringApples.filter(inventory, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filter(FilteringApples.java:74) + assertNotNull(result); + } + + @Test + public void testFilterApplesByColor_1() + throws Exception { + List inventory = mock(List.class); + String color = ""; + // add mock object expectations here + + + List result = FilteringApples.filterApplesByColor(inventory, color); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterApplesByColor(FilteringApples.java:53) + assertNotNull(result); + } + + @Test + public void testFilterApplesByColor_2() + throws Exception { + List inventory = mock(List.class); + String color = ""; + // add mock object expectations here + + + List result = FilteringApples.filterApplesByColor(inventory, color); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterApplesByColor(FilteringApples.java:53) + assertNotNull(result); + } + + @Test + public void testFilterApplesByColor_3() + throws Exception { + List inventory = mock(List.class); + String color = ""; + // add mock object expectations here + + + List result = FilteringApples.filterApplesByColor(inventory, color); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterApplesByColor(FilteringApples.java:53) + assertNotNull(result); + } + + @Test + public void testFilterApplesByWeight_1() + throws Exception { + List inventory = mock(List.class); + int weight = 1; + // add mock object expectations here + + + List result = FilteringApples.filterApplesByWeight(inventory, weight); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterApplesByWeight(FilteringApples.java:63) + assertNotNull(result); + } + + @Test + public void testFilterApplesByWeight_2() + throws Exception { + List inventory = mock(List.class); + int weight = 1; + // add mock object expectations here + + + List result = FilteringApples.filterApplesByWeight(inventory, weight); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterApplesByWeight(FilteringApples.java:63) + assertNotNull(result); + } + + @Test + public void testFilterApplesByWeight_3() + throws Exception { + List inventory = mock(List.class); + int weight = 1; + // add mock object expectations here + + + List result = FilteringApples.filterApplesByWeight(inventory, weight); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterApplesByWeight(FilteringApples.java:63) + assertNotNull(result); + } + + @Test + public void testFilterGreenApples_1() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterGreenApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterGreenApples(FilteringApples.java:43) + assertNotNull(result); + } + + @Test + public void testFilterGreenApples_2() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterGreenApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterGreenApples(FilteringApples.java:43) + assertNotNull(result); + } + + @Test + public void testFilterGreenApples_3() + throws Exception { + List inventory = mock(List.class); + // add mock object expectations here + + + List result = FilteringApples.filterGreenApples(inventory); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap2.FilteringApples.filterGreenApples(FilteringApples.java:43) + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + + FilteringApples.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap2/MeaningOfThisTest.java b/src/test/java/lambdasinaction/chap2/MeaningOfThisTest.java new file mode 100644 index 00000000..cc80293b --- /dev/null +++ b/src/test/java/lambdasinaction/chap2/MeaningOfThisTest.java @@ -0,0 +1,44 @@ +package lambdasinaction.chap2; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MeaningOfThisTest { + @Test + public void testMeaningOfThis_1() + throws Exception { + MeaningOfThis result = new MeaningOfThis(); + assertNotNull(result); + } + + @Test + public void testDoIt_1() + throws Exception { + MeaningOfThis fixture = new MeaningOfThis(); + + fixture.doIt(); + + } + + @Test + public void testMain_1() + throws Exception { + + MeaningOfThis.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap3/ExecuteAroundTest.java b/src/test/java/lambdasinaction/chap3/ExecuteAroundTest.java new file mode 100644 index 00000000..2a3f2901 --- /dev/null +++ b/src/test/java/lambdasinaction/chap3/ExecuteAroundTest.java @@ -0,0 +1,108 @@ +package lambdasinaction.chap3; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + + +public class ExecuteAroundTest { + + @Test + void fileNotFoundException() { + Throwable exception = assertThrows(java.io.FileNotFoundException.class, () -> { + throw new java.io.FileNotFoundException("file not found"); + }); + assertEquals("file not found", exception.getMessage()); + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testMain_1() + throws Exception { + + ExecuteAround.main(); + assertThrows(java.io.FileNotFoundException.class, () -> { + fileNotFoundException(); + }); + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testMain_2() + throws Exception { + + ExecuteAround.main(); + + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testMain_3() + throws Exception { + + ExecuteAround.main(); + + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testMain_4() + throws Exception { + + ExecuteAround.main(); + + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testProcessFile_1() + throws Exception { + ExecuteAround.BufferedReaderProcessor p = mock(ExecuteAround.BufferedReaderProcessor.class); + // add mock object expectations here + + + String result = ExecuteAround.processFile(p); + + assertNotNull(result); + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testProcessFile_2() + throws Exception { + ExecuteAround.BufferedReaderProcessor p = mock(ExecuteAround.BufferedReaderProcessor.class); + // add mock object expectations here + + + String result = ExecuteAround.processFile(p); + + assertNotNull(result); + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testProcessFileLimited_1() + throws Exception { + + String result = ExecuteAround.processFileLimited(); + + assertNotNull(result); + } + + @Test//(expected = java.io.FileNotFoundException.class) + public void testProcessFileLimited_2() + throws Exception { + + String result = ExecuteAround.processFileLimited(); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap3/LambdasTest.java b/src/test/java/lambdasinaction/chap3/LambdasTest.java new file mode 100644 index 00000000..314223fc --- /dev/null +++ b/src/test/java/lambdasinaction/chap3/LambdasTest.java @@ -0,0 +1,79 @@ +package lambdasinaction.chap3; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class LambdasTest { + @Test + public void testFilter_1() + throws Exception { + List inventory = mock(List.class); + Lambdas.ApplePredicate p = mock(Lambdas.ApplePredicate.class); + // add mock object expectations here + + + List result = Lambdas.filter(inventory, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap3.Lambdas.filter(Lambdas.java:29) + assertNotNull(result); + } + + @Test + public void testFilter_2() + throws Exception { + List inventory = mock(List.class); + Lambdas.ApplePredicate p = mock(Lambdas.ApplePredicate.class); + // add mock object expectations here + + + List result = Lambdas.filter(inventory, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap3.Lambdas.filter(Lambdas.java:29) + assertNotNull(result); + } + + @Test + public void testFilter_3() + throws Exception { + List inventory = mock(List.class); + Lambdas.ApplePredicate p = mock(Lambdas.ApplePredicate.class); + // add mock object expectations here + + + List result = Lambdas.filter(inventory, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap3.Lambdas.filter(Lambdas.java:29) + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + + Lambdas.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap3/SortingTest.java b/src/test/java/lambdasinaction/chap3/SortingTest.java new file mode 100644 index 00000000..e8008198 --- /dev/null +++ b/src/test/java/lambdasinaction/chap3/SortingTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap3; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class SortingTest { + @Test + public void testMain_1() + throws Exception { + + Sorting.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap4/DishTest.java b/src/test/java/lambdasinaction/chap4/DishTest.java new file mode 100644 index 00000000..01b52ba8 --- /dev/null +++ b/src/test/java/lambdasinaction/chap4/DishTest.java @@ -0,0 +1,101 @@ +package lambdasinaction.chap4; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DishTest { + @Test + public void testDish_1() + throws Exception { + String name = ""; + boolean vegetarian = true; + int calories = 1; + Dish.Type type = Dish.Type.FISH; + + Dish result = new Dish(name, vegetarian, calories, type); + + assertNotNull(result); + assertEquals("", result.toString()); + assertEquals("", result.getName()); + assertEquals(true, result.isVegetarian()); + assertEquals(1, result.getCalories()); + } + + @Test + public void testGetCalories_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + int result = fixture.getCalories(); + + assertEquals(1, result); + } + + @Test + public void testGetName_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + String result = fixture.getName(); + + assertEquals("", result); + } + + @Test + public void testGetType_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + Dish.Type result = fixture.getType(); + + assertNotNull(result); + assertEquals("FISH", result.name()); + assertEquals("FISH", result.toString()); + assertEquals(1, result.ordinal()); + } + + @Test + public void testIsVegetarian_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + boolean result = fixture.isVegetarian(); + + assertEquals(true, result); + } + + @Test + public void testIsVegetarian_2() + throws Exception { + Dish fixture = new Dish("", false, 1, Dish.Type.FISH); + + boolean result = fixture.isVegetarian(); + + assertEquals(false, result); + } + + @Test + public void testToString_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + String result = fixture.toString(); + + assertEquals("", result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap4/StreamBasicTest.java b/src/test/java/lambdasinaction/chap4/StreamBasicTest.java new file mode 100644 index 00000000..c162aee5 --- /dev/null +++ b/src/test/java/lambdasinaction/chap4/StreamBasicTest.java @@ -0,0 +1,91 @@ +package lambdasinaction.chap4; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class StreamBasicTest { + @Test + public void testGetLowCaloricDishesNamesInJava7_1() + throws Exception { + List dishes = mock(List.class); + // add mock object expectations here + + + List result = StreamBasic.getLowCaloricDishesNamesInJava7(dishes); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap4.StreamBasic.getLowCaloricDishesNamesInJava7(StreamBasic.java:26) + assertNotNull(result); + } + + @Test + public void testGetLowCaloricDishesNamesInJava7_2() + throws Exception { + List dishes = mock(List.class); + // add mock object expectations here + + + List result = StreamBasic.getLowCaloricDishesNamesInJava7(dishes); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap4.StreamBasic.getLowCaloricDishesNamesInJava7(StreamBasic.java:26) + assertNotNull(result); + } + + @Test + public void testGetLowCaloricDishesNamesInJava7_3() + throws Exception { + List dishes = mock(List.class); + // add mock object expectations here + + + List result = StreamBasic.getLowCaloricDishesNamesInJava7(dishes); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap4.StreamBasic.getLowCaloricDishesNamesInJava7(StreamBasic.java:26) + assertNotNull(result); + } + + @Test + public void testGetLowCaloricDishesNamesInJava8_1() + throws Exception { + List dishes = mock(List.class); + // add mock object expectations here + + + List result = StreamBasic.getLowCaloricDishesNamesInJava8(dishes); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap4.StreamBasic.getLowCaloricDishesNamesInJava8(StreamBasic.java:45) + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + + StreamBasic.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap4/StreamVsCollectionTest.java b/src/test/java/lambdasinaction/chap4/StreamVsCollectionTest.java new file mode 100644 index 00000000..b59ce934 --- /dev/null +++ b/src/test/java/lambdasinaction/chap4/StreamVsCollectionTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap4; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class StreamVsCollectionTest { + @Test + public void testMain_1() + throws Exception { + + StreamVsCollection.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/BuildingStreamsTest.java b/src/test/java/lambdasinaction/chap5/BuildingStreamsTest.java new file mode 100644 index 00000000..895521d1 --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/BuildingStreamsTest.java @@ -0,0 +1,34 @@ +package lambdasinaction.chap5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class BuildingStreamsTest { + @Test//(expected = java.nio.file.NoSuchFileException.class) + public void testMain_1() + throws Exception { + + BuildingStreams.main(); + + } + + @Test//(expected = java.nio.file.NoSuchFileException.class) + public void testMain_2() + throws Exception { + + BuildingStreams.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/FilteringTest.java b/src/test/java/lambdasinaction/chap5/FilteringTest.java new file mode 100644 index 00000000..818bd44e --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/FilteringTest.java @@ -0,0 +1,25 @@ +package lambdasinaction.chap5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class FilteringTest { + @Test + public void testMain_1() + throws Exception { + + Filtering.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/FindingTest.java b/src/test/java/lambdasinaction/chap5/FindingTest.java new file mode 100644 index 00000000..3cd23155 --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/FindingTest.java @@ -0,0 +1,35 @@ +package lambdasinaction.chap5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import lambdasinaction.chap5.Finding; + +public class FindingTest { + @Test + public void testMain_1() + throws Exception { + + Finding.main(); + + } + + @Test + public void testMain_2() + throws Exception { + + Finding.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/LazinessTest.java b/src/test/java/lambdasinaction/chap5/LazinessTest.java new file mode 100644 index 00000000..84424eb5 --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/LazinessTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class LazinessTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + Laziness.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/MappingTest.java b/src/test/java/lambdasinaction/chap5/MappingTest.java new file mode 100644 index 00000000..2b0678c2 --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/MappingTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MappingTest { + @Test + public void testMain_1() + throws Exception { + + Mapping.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/NumericStreamsTest.java b/src/test/java/lambdasinaction/chap5/NumericStreamsTest.java new file mode 100644 index 00000000..a9f9a2ed --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/NumericStreamsTest.java @@ -0,0 +1,56 @@ +package lambdasinaction.chap5; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class NumericStreamsTest { + @Test + public void testIsPerfectSquare_1() + throws Exception { + int n = 1; + + boolean result = NumericStreams.isPerfectSquare(n); + + assertEquals(true, result); + } + + @Test + public void testIsPerfectSquare_2() + throws Exception { + int n = 1; + + boolean result = NumericStreams.isPerfectSquare(n); + + assertEquals(true, result); + } + + @Test + public void testMain_1() + throws Exception { + + NumericStreams.main(); + + } + + @Test + public void testMain_2() + throws Exception { + + NumericStreams.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/PuttingIntoPracticeTest.java b/src/test/java/lambdasinaction/chap5/PuttingIntoPracticeTest.java new file mode 100644 index 00000000..d2533766 --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/PuttingIntoPracticeTest.java @@ -0,0 +1,25 @@ +package lambdasinaction.chap5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PuttingIntoPracticeTest { + @Test + public void testMain_1() + throws Exception { + + PuttingIntoPractice.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/ReducingTest.java b/src/test/java/lambdasinaction/chap5/ReducingTest.java new file mode 100644 index 00000000..574b064c --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/ReducingTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap5; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ReducingTest { + @Test + public void testMain_1() + throws Exception { + + Reducing.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/TraderTest.java b/src/test/java/lambdasinaction/chap5/TraderTest.java new file mode 100644 index 00000000..f0d403cb --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/TraderTest.java @@ -0,0 +1,74 @@ +package lambdasinaction.chap5; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class TraderTest { + @Test + public void testTrader_1() + throws Exception { + String n = ""; + String c = ""; + + Trader result = new Trader(n, c); + + assertNotNull(result); + assertEquals("Trader: in ", result.toString()); + assertEquals("", result.getName()); + assertEquals("", result.getCity()); + } + + @Test + public void testGetCity_1() + throws Exception { + Trader fixture = new Trader("", ""); + + String result = fixture.getCity(); + + assertEquals("", result); + } + + @Test + public void testGetName_1() + throws Exception { + Trader fixture = new Trader("", ""); + + String result = fixture.getName(); + + assertEquals("", result); + } + + @Test + public void testSetCity_1() + throws Exception { + Trader fixture = new Trader("", ""); + String newCity = ""; + + fixture.setCity(newCity); + + } + + @Test + public void testToString_1() + throws Exception { + Trader fixture = new Trader("", ""); + + String result = fixture.toString(); + + assertEquals("Trader: in ", result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap5/TransactionTest.java b/src/test/java/lambdasinaction/chap5/TransactionTest.java new file mode 100644 index 00000000..7b65c115 --- /dev/null +++ b/src/test/java/lambdasinaction/chap5/TransactionTest.java @@ -0,0 +1,78 @@ +package lambdasinaction.chap5; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class TransactionTest { + @Test + public void testTransaction_1() + throws Exception { + Trader trader = new Trader("", ""); + int year = 1; + int value = 1; + + Transaction result = new Transaction(trader, year, value); + + assertNotNull(result); + assertEquals("{Trader: in , year: 1, value:1}", result.toString()); + assertEquals(1, result.getValue()); + assertEquals(1, result.getYear()); + } + + @Test + public void testGetTrader_1() + throws Exception { + Transaction fixture = new Transaction(new Trader("", ""), 1, 1); + + Trader result = fixture.getTrader(); + + assertNotNull(result); + assertEquals("Trader: in ", result.toString()); + assertEquals("", result.getName()); + assertEquals("", result.getCity()); + } + + @Test + public void testGetValue_1() + throws Exception { + Transaction fixture = new Transaction(new Trader("", ""), 1, 1); + + int result = fixture.getValue(); + + assertEquals(1, result); + } + + @Test + public void testGetYear_1() + throws Exception { + Transaction fixture = new Transaction(new Trader("", ""), 1, 1); + + int result = fixture.getYear(); + + assertEquals(1, result); + } + + @Test + public void testToString_1() + throws Exception { + Transaction fixture = new Transaction(new Trader("", ""), 1, 1); + + String result = fixture.toString(); + + assertEquals("{Trader: in , year: 1, value:1}", result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/CollectorHarnessTest.java b/src/test/java/lambdasinaction/chap6/CollectorHarnessTest.java new file mode 100644 index 00000000..452695e8 --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/CollectorHarnessTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap6; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class CollectorHarnessTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + CollectorHarness.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/DishTest.java b/src/test/java/lambdasinaction/chap6/DishTest.java new file mode 100644 index 00000000..31a99ffa --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/DishTest.java @@ -0,0 +1,100 @@ +package lambdasinaction.chap6; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DishTest { + @Test + public void testDish_1() + throws Exception { + String name = ""; + boolean vegetarian = true; + int calories = 1; + Dish.Type type = Dish.Type.FISH; + + Dish result = new Dish(name, vegetarian, calories, type); + + assertNotNull(result); + assertEquals("", result.toString()); + assertEquals("", result.getName()); + assertEquals(true, result.isVegetarian()); + assertEquals(1, result.getCalories()); + } + + @Test + public void testGetCalories_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + int result = fixture.getCalories(); + + assertEquals(1, result); + } + + @Test + public void testGetName_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + String result = fixture.getName(); + + assertEquals("", result); + } + + @Test + public void testGetType_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + Dish.Type result = fixture.getType(); + + assertNotNull(result); + assertEquals("FISH", result.name()); + assertEquals("FISH", result.toString()); + assertEquals(1, result.ordinal()); + } + + @Test + public void testIsVegetarian_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + boolean result = fixture.isVegetarian(); + + assertEquals(true, result); + } + + @Test + public void testIsVegetarian_2() + throws Exception { + Dish fixture = new Dish("", false, 1, Dish.Type.FISH); + + boolean result = fixture.isVegetarian(); + + assertEquals(false, result); + } + + @Test + public void testToString_1() + throws Exception { + Dish fixture = new Dish("", true, 1, Dish.Type.FISH); + + String result = fixture.toString(); + + assertEquals("", result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/GroupingTest.java b/src/test/java/lambdasinaction/chap6/GroupingTest.java new file mode 100644 index 00000000..42376eaa --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/GroupingTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap6; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class GroupingTest { + @Test + public void testMain_1() + throws Exception { + + Grouping.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/GroupingTransactionsTest.java b/src/test/java/lambdasinaction/chap6/GroupingTransactionsTest.java new file mode 100644 index 00000000..4de9f0e6 --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/GroupingTransactionsTest.java @@ -0,0 +1,35 @@ +package lambdasinaction.chap6; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class GroupingTransactionsTest { + @Test + public void testGroupingTransactions_1() + throws Exception { + GroupingTransactions result = new GroupingTransactions(); + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + + GroupingTransactions.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/PartitionPrimeNumbersTest.java b/src/test/java/lambdasinaction/chap6/PartitionPrimeNumbersTest.java new file mode 100644 index 00000000..4a093aa6 --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/PartitionPrimeNumbersTest.java @@ -0,0 +1,178 @@ +package lambdasinaction.chap6; + +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.mockito.Mockito.mock; + +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PartitionPrimeNumbersTest { + @Test + public void testIsPrime_1() + throws Exception { + int candidate = 1; + + boolean result = PartitionPrimeNumbers.isPrime(candidate); + + assertEquals(true, result); + } + + @Test + public void testIsPrime_2() + throws Exception { + int candidate = 1; + + boolean result = PartitionPrimeNumbers.isPrime(candidate); + + assertEquals(true, result); + } + + @Test + public void testIsPrime_3() + throws Exception { + List primes = mock(List.class); + Integer candidate = new Integer(1); + // add mock object expectations here + + + boolean result = PartitionPrimeNumbers.isPrime(primes, candidate); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap6.PartitionPrimeNumbers.takeWhile(PartitionPrimeNumbers.java:41) + // at lambdasinaction.chap6.PartitionPrimeNumbers.isPrime(PartitionPrimeNumbers.java:36) + assertTrue(result); + } + + @Test + public void testIsPrime_4() + throws Exception { + List primes = mock(List.class); + Integer candidate = new Integer(1); + // add mock object expectations here + + + boolean result = PartitionPrimeNumbers.isPrime(primes, candidate); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap6.PartitionPrimeNumbers.takeWhile(PartitionPrimeNumbers.java:41) + // at lambdasinaction.chap6.PartitionPrimeNumbers.isPrime(PartitionPrimeNumbers.java:36) + assertTrue(result); + } + + @Test + public void testMain_1() + throws Exception { + + PartitionPrimeNumbers.main(); + + } + + @Test + public void testPartitionPrimes_1() + throws Exception { + int n = 1; + + Map> result = PartitionPrimeNumbers.partitionPrimes(n); + + assertNotNull(result); + assertEquals(2, result.size()); + assertTrue(result.containsKey(Boolean.FALSE)); + assertTrue(result.containsKey(Boolean.TRUE)); + } + + @Test + public void testPartitionPrimesWithCustomCollector_1() + throws Exception { + int n = 1; + + Map> result = PartitionPrimeNumbers.partitionPrimesWithCustomCollector(n); + + assertNotNull(result); + assertEquals(2, result.size()); + assertTrue(result.containsKey(Boolean.FALSE)); + assertTrue(result.containsKey(Boolean.TRUE)); + } + + @Test + public void testPartitionPrimesWithInlineCollector_1() + throws Exception { + PartitionPrimeNumbers fixture = new PartitionPrimeNumbers(); + int n = 1; + + Map> result = fixture.partitionPrimesWithInlineCollector(n); + + assertNotNull(result); + assertEquals(2, result.size()); + assertTrue(result.containsKey(Boolean.FALSE)); + assertTrue(result.containsKey(Boolean.TRUE)); + } + + @Test + public void testTakeWhile_1() + throws Exception { + List list = mock(List.class); + Predicate p = mock(Predicate.class); + // add mock object expectations here + + + List result = PartitionPrimeNumbers.takeWhile(list, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap6.PartitionPrimeNumbers.takeWhile(PartitionPrimeNumbers.java:41) + assertNotNull(result); + } + + @Test + public void testTakeWhile_2() + throws Exception { + List list = mock(List.class); + Predicate p = mock(Predicate.class); + // add mock object expectations here + + + List result = PartitionPrimeNumbers.takeWhile(list, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap6.PartitionPrimeNumbers.takeWhile(PartitionPrimeNumbers.java:41) + assertNotNull(result); + } + + @Test + public void testTakeWhile_3() + throws Exception { + List list = mock(List.class); + Predicate p = mock(Predicate.class); + // add mock object expectations here + + + List result = PartitionPrimeNumbers.takeWhile(list, p); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap6.PartitionPrimeNumbers.takeWhile(PartitionPrimeNumbers.java:41) + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/PartitioningTest.java b/src/test/java/lambdasinaction/chap6/PartitioningTest.java new file mode 100644 index 00000000..b1321ab4 --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/PartitioningTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap6; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PartitioningTest { + @Test + public void testMain_1() + throws Exception { + + Partitioning.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/ReducingTest.java b/src/test/java/lambdasinaction/chap6/ReducingTest.java new file mode 100644 index 00000000..904873d3 --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/ReducingTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap6; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ReducingTest { + @Test + public void testMain_1() + throws Exception { + + Reducing.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/SummarizingTest.java b/src/test/java/lambdasinaction/chap6/SummarizingTest.java new file mode 100644 index 00000000..9f19ece1 --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/SummarizingTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap6; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class SummarizingTest { + @Test + public void testMain_1() + throws Exception { + + Summarizing.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap6/ToListCollectorTest.java b/src/test/java/lambdasinaction/chap6/ToListCollectorTest.java new file mode 100644 index 00000000..85af7123 --- /dev/null +++ b/src/test/java/lambdasinaction/chap6/ToListCollectorTest.java @@ -0,0 +1,79 @@ +package lambdasinaction.chap6; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.function.Supplier; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ToListCollectorTest { + @Test + public void testAccumulator_1() + throws Exception { + ToListCollector fixture = new ToListCollector(); + + BiConsumer, Object> result = fixture.accumulator(); + + assertNotNull(result); + } + + @Test + public void testCharacteristics_1() + throws Exception { + ToListCollector fixture = new ToListCollector(); + + Set result = fixture.characteristics(); + + assertNotNull(result); + assertEquals(2, result.size()); + } + + @Test + public void testCombiner_1() + throws Exception { + ToListCollector fixture = new ToListCollector(); + + BinaryOperator> result = fixture.combiner(); + + assertNotNull(result); + } + + @Test + public void testFinisher_1() + throws Exception { + ToListCollector fixture = new ToListCollector(); + + Function, List> result = fixture.finisher(); + + assertNotNull(result); + } + + @Test + public void testSupplier_1() + throws Exception { + ToListCollector fixture = new ToListCollector(); + + Supplier> result = fixture.supplier(); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap7/ForkJoinSumCalculatorTest.java b/src/test/java/lambdasinaction/chap7/ForkJoinSumCalculatorTest.java new file mode 100644 index 00000000..9144262b --- /dev/null +++ b/src/test/java/lambdasinaction/chap7/ForkJoinSumCalculatorTest.java @@ -0,0 +1,86 @@ +package lambdasinaction.chap7; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ForkJoinSumCalculatorTest { + @Test + public void testForkJoinSumCalculator_1() + throws Exception { + long[] numbers = new long[] {}; + + ForkJoinSumCalculator result = new ForkJoinSumCalculator(numbers); + + assertNotNull(result); + assertEquals(null, result.getRawResult()); + assertEquals(new Long(0L), result.invoke()); + assertEquals(new Long(0L), result.get()); + assertEquals(new Long(0L), result.join()); + assertEquals(null, result.getException()); + assertEquals(false, result.isCancelled()); + assertEquals(true, result.isDone()); + assertEquals((short) 0, result.getForkJoinTaskTag()); + assertEquals(new Long(0L), result.getRawResult()); + assertEquals(false, result.isCompletedAbnormally()); + assertEquals(true, result.isCompletedNormally()); + assertEquals(false, result.tryUnfork()); + } + + @Test + public void testCompute_1() + throws Exception { + ForkJoinSumCalculator fixture = new ForkJoinSumCalculator(new long[] {}); + + Long result = fixture.compute(); + + assertNotNull(result); + assertEquals("0", result.toString()); + assertEquals((byte) 0, result.byteValue()); + assertEquals((short) 0, result.shortValue()); + assertEquals(0, result.intValue()); + assertEquals(0L, result.longValue()); + assertEquals(0.0f, result.floatValue(), 1.0f); + assertEquals(0.0, result.doubleValue(), 1.0); + } + + @Test + public void testCompute_2() + throws Exception { + ForkJoinSumCalculator fixture = new ForkJoinSumCalculator(new long[] {}); + + Long result = fixture.compute(); + + assertNotNull(result); + assertEquals("0", result.toString()); + assertEquals((byte) 0, result.byteValue()); + assertEquals((short) 0, result.shortValue()); + assertEquals(0, result.intValue()); + assertEquals(0L, result.longValue()); + assertEquals(0.0f, result.floatValue(), 1.0f); + assertEquals(0.0, result.doubleValue(), 1.0); + } + + @Test + public void testForkJoinSum_1() + throws Exception { + long n = 1L; + + long result = ForkJoinSumCalculator.forkJoinSum(n); + + assertEquals(1L, result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap7/ParallelStreamsHarnessTest.java b/src/test/java/lambdasinaction/chap7/ParallelStreamsHarnessTest.java new file mode 100644 index 00000000..e69de29b diff --git a/src/test/java/lambdasinaction/chap7/ParallelStreamsTest.java b/src/test/java/lambdasinaction/chap7/ParallelStreamsTest.java new file mode 100644 index 00000000..4cff4deb --- /dev/null +++ b/src/test/java/lambdasinaction/chap7/ParallelStreamsTest.java @@ -0,0 +1,100 @@ +package lambdasinaction.chap7; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ParallelStreamsTest { + @Test + public void testIterativeSum_1() + throws Exception { + long n = 1L; + + long result = ParallelStreams.iterativeSum(n); + + assertEquals(1L, result); + } + + @Test + public void testIterativeSum_2() + throws Exception { + long n = -1L; + + long result = ParallelStreams.iterativeSum(n); + + assertEquals(0L, result); + } + + @Test + public void testParallelRangedSum_1() + throws Exception { + long n = 1L; + + long result = ParallelStreams.parallelRangedSum(n); + + assertEquals(1L, result); + } + + @Test + public void testParallelSum_1() + throws Exception { + long n = 1L; + + long result = ParallelStreams.parallelSum(n); + + assertEquals(1L, result); + } + + @Test + public void testRangedSum_1() + throws Exception { + long n = 1L; + + long result = ParallelStreams.rangedSum(n); + + assertEquals(1L, result); + } + + @Test + public void testSequentialSum_1() + throws Exception { + long n = 1L; + + long result = ParallelStreams.sequentialSum(n); + + assertEquals(1L, result); + } + + @Test + public void testSideEffectParallelSum_1() + throws Exception { + long n = 1L; + + long result = ParallelStreams.sideEffectParallelSum(n); + + assertEquals(1L, result); + } + + @Test + public void testSideEffectSum_1() + throws Exception { + long n = 1L; + + long result = ParallelStreams.sideEffectSum(n); + + assertEquals(1L, result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap7/WordCountTest.java b/src/test/java/lambdasinaction/chap7/WordCountTest.java new file mode 100644 index 00000000..46c4387e --- /dev/null +++ b/src/test/java/lambdasinaction/chap7/WordCountTest.java @@ -0,0 +1,107 @@ +package lambdasinaction.chap7; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class WordCountTest { + @Test + public void testWordCount_1() + throws Exception { + WordCount result = new WordCount(); + assertNotNull(result); + } + + @Test + public void testCountWords_1() + throws Exception { + String s = ""; + + int result = WordCount.countWords(s); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.StringIndexOutOfBoundsException: String index out of range: 0 + // at java.lang.String.charAt(Unknown Source) + // at lambdasinaction.chap7.WordCount$WordCounterSpliterator.tryAdvance(WordCount.java:86) + // at java.util.Spliterator.forEachRemaining(Unknown Source) + // at java.util.stream.AbstractPipeline.copyInto(Unknown Source) + // at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) + // at java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source) + // at java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source) + // at java.util.stream.AbstractTask.compute(Unknown Source) + // at java.util.concurrent.CountedCompleter.exec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doExec(Unknown Source) + // at java.util.concurrent.ForkJoinTask.doInvoke(Unknown Source) + // at java.util.concurrent.ForkJoinTask.invoke(Unknown Source) + // at java.util.stream.ReduceOps$ReduceOp.evaluateParallel(Unknown Source) + // at java.util.stream.AbstractPipeline.evaluate(Unknown Source) + // at java.util.stream.ReferencePipeline.reduce(Unknown Source) + // at lambdasinaction.chap7.WordCount.countWords(WordCount.java:43) + // at lambdasinaction.chap7.WordCount.countWords(WordCount.java:39) + assertEquals(0, result); + } + + @Test + public void testCountWordsIteratively_1() + throws Exception { + String s = ""; + + int result = WordCount.countWordsIteratively(s); + + assertEquals(0, result); + } + + @Test + public void testCountWordsIteratively_2() + throws Exception { + String s = ""; + + int result = WordCount.countWordsIteratively(s); + + assertEquals(0, result); + } + + @Test + public void testCountWordsIteratively_3() + throws Exception { + String s = ""; + + int result = WordCount.countWordsIteratively(s); + + assertEquals(0, result); + } + + @Test + public void testCountWordsIteratively_4() + throws Exception { + String s = ""; + + int result = WordCount.countWordsIteratively(s); + + assertEquals(0, result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + WordCount.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/ChainOfResponsibilityMainTest.java b/src/test/java/lambdasinaction/chap8/ChainOfResponsibilityMainTest.java new file mode 100644 index 00000000..a82f7a56 --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/ChainOfResponsibilityMainTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap8; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ChainOfResponsibilityMainTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + ChainOfResponsibilityMain.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/DebuggingTest.java b/src/test/java/lambdasinaction/chap8/DebuggingTest.java new file mode 100644 index 00000000..3b56d649 --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/DebuggingTest.java @@ -0,0 +1,40 @@ +package lambdasinaction.chap8; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DebuggingTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + Debugging.main(args); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.chap8.Debugging.lambda$0(Debugging.java:9) + // at lambdasinaction.chap8.Debugging$$Lambda$306/539584182.apply(Unknown Source) + // at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) + // at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) + // at java.util.stream.AbstractPipeline.copyInto(Unknown Source) + // at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) + // at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) + // at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) + // at java.util.stream.AbstractPipeline.evaluate(Unknown Source) + // at java.util.stream.ReferencePipeline.forEach(Unknown Source) + // at lambdasinaction.chap8.Debugging.main(Debugging.java:9) + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/FactoryMainTest.java b/src/test/java/lambdasinaction/chap8/FactoryMainTest.java new file mode 100644 index 00000000..21087231 --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/FactoryMainTest.java @@ -0,0 +1,36 @@ +package lambdasinaction.chap8; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class FactoryMainTest { + @Test + public void testFactoryMain_1() + throws Exception { + FactoryMain result = new FactoryMain(); + assertNotNull(result); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + FactoryMain.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/ObserverMainTest.java b/src/test/java/lambdasinaction/chap8/ObserverMainTest.java new file mode 100644 index 00000000..644f3641 --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/ObserverMainTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap8; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ObserverMainTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + ObserverMain.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/OnlineBankingLambdaTest.java b/src/test/java/lambdasinaction/chap8/OnlineBankingLambdaTest.java new file mode 100644 index 00000000..698862f0 --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/OnlineBankingLambdaTest.java @@ -0,0 +1,43 @@ +package lambdasinaction.chap8; + +import static org.mockito.Mockito.mock; + +import java.util.function.Consumer; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class OnlineBankingLambdaTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + OnlineBankingLambda.main(args); + + } + + @Test + void testProcessCustomer_1()throws Exception { + OnlineBankingLambda fixture = new OnlineBankingLambda(); + int id = 1; + Consumer makeCustomerHappy = mock(Consumer.class); + // add mock object expectations here + + + fixture.processCustomer(id, makeCustomerHappy); + + } + + @BeforeEach + void setUp() + throws Exception { + } + + @AfterEach + void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/OnlineBankingTest.java b/src/test/java/lambdasinaction/chap8/OnlineBankingTest.java new file mode 100644 index 00000000..328628ff --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/OnlineBankingTest.java @@ -0,0 +1,16 @@ +package lambdasinaction.chap8; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +public class OnlineBankingTest { + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/PeekTest.java b/src/test/java/lambdasinaction/chap8/PeekTest.java new file mode 100644 index 00000000..6e29cd38 --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/PeekTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap8; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class PeekTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + Peek.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap8/StrategyMainTest.java b/src/test/java/lambdasinaction/chap8/StrategyMainTest.java new file mode 100644 index 00000000..c9788d0e --- /dev/null +++ b/src/test/java/lambdasinaction/chap8/StrategyMainTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap8; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class StrategyMainTest { + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + StrategyMain.main(args); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/AmbiguousTest.java b/src/test/java/lambdasinaction/chap9/AmbiguousTest.java new file mode 100644 index 00000000..35b4d952 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/AmbiguousTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class AmbiguousTest { + @Test + public void testMain_1() + throws Exception { + + Ambiguous.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/DiamondTest.java b/src/test/java/lambdasinaction/chap9/DiamondTest.java new file mode 100644 index 00000000..0abdadd5 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/DiamondTest.java @@ -0,0 +1,27 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DiamondTest { + @Test + public void testMain_1() + throws Exception { + + Diamond.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/DrawableTest.java b/src/test/java/lambdasinaction/chap9/DrawableTest.java new file mode 100644 index 00000000..bd32ef35 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/DrawableTest.java @@ -0,0 +1,17 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +public class DrawableTest { + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/EllipseTest.java b/src/test/java/lambdasinaction/chap9/EllipseTest.java new file mode 100644 index 00000000..9f98a1f4 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/EllipseTest.java @@ -0,0 +1,17 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +public class EllipseTest { + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/GameTest.java b/src/test/java/lambdasinaction/chap9/GameTest.java new file mode 100644 index 00000000..f4eade99 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/GameTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class GameTest { + @Test + public void testMain_1() + throws Exception { + + Game.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/IntroTest.java b/src/test/java/lambdasinaction/chap9/IntroTest.java new file mode 100644 index 00000000..8ec303ff --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/IntroTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class IntroTest { + @Test + public void testMain_1() + throws Exception { + + Intro.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/LetterTest.java b/src/test/java/lambdasinaction/chap9/LetterTest.java new file mode 100644 index 00000000..a4638edc --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/LetterTest.java @@ -0,0 +1,58 @@ +package lambdasinaction.chap9; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class LetterTest { + @Test + public void testAddFooter_1() + throws Exception { + String text = ""; + + String result = Letter.addFooter(text); + + assertEquals("Kind regards", result); + } + + @Test + public void testAddHeader_1() + throws Exception { + String text = ""; + + String result = Letter.addHeader(text); + + assertEquals("From Raoul, Mario and Alan:", result); + } + + @Test + public void testCheckSpelling_1() + throws Exception { + String text = ""; + + String result = Letter.checkSpelling(text); + + assertEquals("", result); + } + + @Test + public void testMain_1() + throws Exception { + + Letter.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/MostSpecificTest.java b/src/test/java/lambdasinaction/chap9/MostSpecificTest.java new file mode 100644 index 00000000..9a24d846 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/MostSpecificTest.java @@ -0,0 +1,26 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MostSpecificTest { + @Test + public void testMain_1() + throws Exception { + + MostSpecific.main(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/ResizableTest.java b/src/test/java/lambdasinaction/chap9/ResizableTest.java new file mode 100644 index 00000000..a5445421 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/ResizableTest.java @@ -0,0 +1,17 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +public class ResizableTest { + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/SquareTest.java b/src/test/java/lambdasinaction/chap9/SquareTest.java new file mode 100644 index 00000000..d3faaafb --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/SquareTest.java @@ -0,0 +1,17 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +public class SquareTest { + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/TriangleTest.java b/src/test/java/lambdasinaction/chap9/TriangleTest.java new file mode 100644 index 00000000..1c9cb4b8 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/TriangleTest.java @@ -0,0 +1,17 @@ +package lambdasinaction.chap9; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + +public class TriangleTest { + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/chap9/UtilsTest.java b/src/test/java/lambdasinaction/chap9/UtilsTest.java new file mode 100644 index 00000000..3b348702 --- /dev/null +++ b/src/test/java/lambdasinaction/chap9/UtilsTest.java @@ -0,0 +1,33 @@ +package lambdasinaction.chap9; + +import static org.mockito.Mockito.mock; + +import java.util.List; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class UtilsTest { + @Test + public void testPaint_1() + throws Exception { + List l = mock(List.class); + // add mock object expectations here + + + Utils.paint(l); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/GroupingTest.java b/src/test/java/lambdasinaction/dsl/GroupingTest.java new file mode 100644 index 00000000..08db7d2e --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/GroupingTest.java @@ -0,0 +1,46 @@ +package lambdasinaction.dsl; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collector; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class GroupingTest { + @Test + public void testMain_1() + throws Exception { + + Grouping.main(); + + } + + @Test + public void testTwoLevelGroupingBy_1() + throws Exception { + Function f1 = mock(Function.class); + Function f2 = mock(Function.class); + // add mock object expectations here + + + Collector>>> result = Grouping.twoLevelGroupingBy(f1, f2); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/LambdaOrderBuilderTest.java b/src/test/java/lambdasinaction/dsl/LambdaOrderBuilderTest.java new file mode 100644 index 00000000..2c9323e4 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/LambdaOrderBuilderTest.java @@ -0,0 +1,81 @@ +package lambdasinaction.dsl; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.function.Consumer; + +import lambdasinaction.dsl.model.Order; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class LambdaOrderBuilderTest { + @Test + public void testLambdaOrderBuilder_1() + throws Exception { + LambdaOrderBuilder result = new LambdaOrderBuilder(); + assertNotNull(result); + } + + @Test + public void testBuy_1() + throws Exception { + LambdaOrderBuilder fixture = new LambdaOrderBuilder(); + Consumer consumer = mock(Consumer.class); + // add mock object expectations here + + + fixture.buy(consumer); + + } + + @Test + public void testForCustomer_1() + throws Exception { + LambdaOrderBuilder fixture = new LambdaOrderBuilder(); + String customer = ""; + + fixture.forCustomer(customer); + + } + + @Test + public void testOrder_1() + throws Exception { + Consumer consumer = mock(Consumer.class); + // add mock object expectations here + + + Order result = LambdaOrderBuilder.order(consumer); + + assertNotNull(result); + assertEquals(0.0, result.getValue(), 1.0); + assertEquals(null, result.getCustomer()); + } + + @Test + public void testSell_1() + throws Exception { + LambdaOrderBuilder fixture = new LambdaOrderBuilder(); + Consumer consumer = mock(Consumer.class); + // add mock object expectations here + + + fixture.sell(consumer); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/MainTest.java b/src/test/java/lambdasinaction/dsl/MainTest.java new file mode 100644 index 00000000..789f4b46 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/MainTest.java @@ -0,0 +1,54 @@ +package lambdasinaction.dsl; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MainTest { + @Test + public void testLambda_1() + throws Exception { + Main fixture = new Main(); + + fixture.lambda(); + + } + + @Test + public void testMethodChaining_1() + throws Exception { + Main fixture = new Main(); + + fixture.methodChaining(); + + } + + @Test + public void testNestedFunction_1() + throws Exception { + Main fixture = new Main(); + + fixture.nestedFunction(); + + } + + @Test + public void testPlain_1() + throws Exception { + Main fixture = new Main(); + + fixture.plain(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/MethodChainingOrderBuilderTest.java b/src/test/java/lambdasinaction/dsl/MethodChainingOrderBuilderTest.java new file mode 100644 index 00000000..24d54439 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/MethodChainingOrderBuilderTest.java @@ -0,0 +1,66 @@ +package lambdasinaction.dsl; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import lambdasinaction.dsl.model.Order; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MethodChainingOrderBuilderTest { + @Test + public void testBuy_1() + throws Exception { + MethodChainingOrderBuilder fixture = MethodChainingOrderBuilder.forCustomer(""); + int quantity = 1; + + MethodChainingOrderBuilder.TradeBuilder result = fixture.buy(quantity); + + assertNotNull(result); + } + + @Test + public void testEnd_1() + throws Exception { + MethodChainingOrderBuilder fixture = MethodChainingOrderBuilder.forCustomer(""); + + Order result = fixture.end(); + + assertNotNull(result); + assertEquals(0.0, result.getValue(), 1.0); + assertEquals("", result.getCustomer()); + } + + @Test + public void testForCustomer_1() + throws Exception { + String customer = ""; + + MethodChainingOrderBuilder result = MethodChainingOrderBuilder.forCustomer(customer); + + assertNotNull(result); + } + + @Test + public void testSell_1() + throws Exception { + MethodChainingOrderBuilder fixture = MethodChainingOrderBuilder.forCustomer(""); + int quantity = 1; + + MethodChainingOrderBuilder.TradeBuilder result = fixture.sell(quantity); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/MixedBuilderTest.java b/src/test/java/lambdasinaction/dsl/MixedBuilderTest.java new file mode 100644 index 00000000..020aefab --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/MixedBuilderTest.java @@ -0,0 +1,62 @@ +package lambdasinaction.dsl; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.function.Consumer; + +import lambdasinaction.dsl.model.Order; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MixedBuilderTest { + @Test + public void testBuy_1() + throws Exception { + Consumer consumer = mock(Consumer.class); + // add mock object expectations here + + + MixedBuilder.TradeBuilder result = MixedBuilder.buy(consumer); + + assertNotNull(result); + } + + @Test + public void testForCustomer_1() + throws Exception { + String customer = ""; + + Order result = MixedBuilder.forCustomer(customer); + + assertNotNull(result); + assertEquals(0.0, result.getValue(), 1.0); + assertEquals("", result.getCustomer()); + } + + @Test + public void testSell_1() + throws Exception { + Consumer consumer = mock(Consumer.class); + // add mock object expectations here + + + MixedBuilder.TradeBuilder result = MixedBuilder.sell(consumer); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/MixedTest.java b/src/test/java/lambdasinaction/dsl/MixedTest.java new file mode 100644 index 00000000..b8e4ab54 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/MixedTest.java @@ -0,0 +1,28 @@ +package lambdasinaction.dsl; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MixedTest { + @Test + public void testMixed_1() + throws Exception { + Mixed fixture = new Mixed(); + + fixture.mixed(); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/NestedFunctionOrderBuilderTest.java b/src/test/java/lambdasinaction/dsl/NestedFunctionOrderBuilderTest.java new file mode 100644 index 00000000..85c8867d --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/NestedFunctionOrderBuilderTest.java @@ -0,0 +1,99 @@ +package lambdasinaction.dsl; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import lambdasinaction.dsl.model.Order; +import lambdasinaction.dsl.model.Stock; +import lambdasinaction.dsl.model.Trade; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class NestedFunctionOrderBuilderTest { + @Test + public void testAt_1() + throws Exception { + double price = 1.0; + + double result = NestedFunctionOrderBuilder.at(price); + + assertEquals(1.0, result, 0.1); + } + + @Test + public void testBuy_1() + throws Exception { + int quantity = 1; + Stock stock = new Stock(); + double price = 1.0; + + Trade result = NestedFunctionOrderBuilder.buy(quantity, stock, price); + + assertNotNull(result); + assertEquals(0.0, result.getValue(), 1.0); + assertEquals(1.0, result.getPrice(), 1.0); + assertEquals(0, result.getQuantity()); + } + + @Test + public void testOn_1() + throws Exception { + String market = ""; + + String result = NestedFunctionOrderBuilder.on(market); + + assertEquals("", result); + } + + @Test + public void testOrder_1() + throws Exception { + String customer = ""; + + Order result = NestedFunctionOrderBuilder.order(customer); + + assertNotNull(result); + assertEquals(0.0, result.getValue(), 1.0); + assertEquals("", result.getCustomer()); + } + + @Test + public void testSell_1() + throws Exception { + int quantity = 1; + Stock stock = new Stock(); + double price = 1.0; + + Trade result = NestedFunctionOrderBuilder.sell(quantity, stock, price); + + assertNotNull(result); + assertEquals(0.0, result.getValue(), 1.0); + assertEquals(1.0, result.getPrice(), 1.0); + assertEquals(0, result.getQuantity()); + } + + @Test + public void testStock_1() + throws Exception { + String symbol = ""; + String market = ""; + + Stock result = NestedFunctionOrderBuilder.stock(symbol, market); + + assertNotNull(result); + assertEquals("", result.getSymbol()); + assertEquals("", result.getMarket()); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/TaxCalculatorTest.java b/src/test/java/lambdasinaction/dsl/TaxCalculatorTest.java new file mode 100644 index 00000000..4a861181 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/TaxCalculatorTest.java @@ -0,0 +1,142 @@ +package lambdasinaction.dsl; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.mock; + +import java.util.function.Function; + +import lambdasinaction.dsl.model.Order; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class TaxCalculatorTest { + @Test + public void testTaxCalculator_1() + throws Exception { + TaxCalculator result = new TaxCalculator(); + assertNotNull(result); + } + + @Test + public void testCalculate_1() + throws Exception { + TaxCalculator fixture = new TaxCalculator(); + fixture.taxFuncion = mock(Function.class); + Order order = new Order(); + + double result = fixture.calculate(order); + + assertEquals(0.0, result, 0.1); + } + + @Test + public void testCalculate_2() + throws Exception { + Order order = new Order(); + boolean useRegional = false; + boolean useGeneral = true; + boolean useSurcharge = true; + + double result = TaxCalculator.calculate(order, useRegional, useGeneral, useSurcharge); + + assertEquals(0.0, result, 0.1); + } + + @Test + public void testCalculate_3() + throws Exception { + Order order = new Order(); + boolean useRegional = true; + boolean useGeneral = false; + boolean useSurcharge = false; + + double result = TaxCalculator.calculate(order, useRegional, useGeneral, useSurcharge); + + assertEquals(0.0, result, 0.1); + } + + @Test + public void testCalculateF_1() + throws Exception { + TaxCalculator fixture = new TaxCalculator(); + fixture.taxFuncion = mock(Function.class); + Order order = new Order(); + + double result = fixture.calculateF(order); + + // An unexpected exception was thrown in user code while executing this test: + // java.lang.NullPointerException + // at lambdasinaction.dsl.TaxCalculator.calculateF(TaxCalculator.java:65) + assertEquals(0.0, result, 0.1); + } + + @Test + public void testMain_1() + throws Exception { + String[] args = new String[] {}; + + TaxCalculator.main(args); + + } + + @Test + public void testWith_1() + throws Exception { + TaxCalculator fixture = new TaxCalculator(); + fixture.taxFuncion = mock(Function.class); + Function f = mock(Function.class); + // add mock object expectations here + + + TaxCalculator result = fixture.with(f); + + assertNotNull(result); + } + + @Test + public void testWithTaxGeneral_1() + throws Exception { + TaxCalculator fixture = new TaxCalculator(); + fixture.taxFuncion = mock(Function.class); + + TaxCalculator result = fixture.withTaxGeneral(); + + assertNotNull(result); + } + + @Test + public void testWithTaxRegional_1() + throws Exception { + TaxCalculator fixture = new TaxCalculator(); + fixture.taxFuncion = mock(Function.class); + + TaxCalculator result = fixture.withTaxRegional(); + + assertNotNull(result); + } + + @Test + public void testWithTaxSurcharge_1() + throws Exception { + TaxCalculator fixture = new TaxCalculator(); + fixture.taxFuncion = mock(Function.class); + + TaxCalculator result = fixture.withTaxSurcharge(); + + assertNotNull(result); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/model/OrderTest.java b/src/test/java/lambdasinaction/dsl/model/OrderTest.java new file mode 100644 index 00000000..ef3cd96e --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/model/OrderTest.java @@ -0,0 +1,75 @@ +package lambdasinaction.dsl.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class OrderTest { + @Test + public void testOrder_1() + throws Exception { + Order result = new Order(); + assertNotNull(result); + } + + @Test + public void testAddTrade_1() + throws Exception { + Order fixture = new Order(); + fixture.setCustomer(""); + fixture.addTrade(new Trade()); + Trade trade = new Trade(); + + fixture.addTrade(trade); + + } + + @Test + public void testGetCustomer_1() + throws Exception { + Order fixture = new Order(); + fixture.setCustomer(""); + fixture.addTrade(new Trade()); + + String result = fixture.getCustomer(); + + assertEquals("", result); + } + + @Test + public void testGetValue_1() + throws Exception { + Order fixture = new Order(); + fixture.setCustomer(""); + fixture.addTrade(new Trade()); + + double result = fixture.getValue(); + + assertEquals(0.0, result, 0.1); + } + + @Test + public void testSetCustomer_1() + throws Exception { + Order fixture = new Order(); + fixture.setCustomer(""); + fixture.addTrade(new Trade()); + String customer = ""; + + fixture.setCustomer(customer); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/model/StockTest.java b/src/test/java/lambdasinaction/dsl/model/StockTest.java new file mode 100644 index 00000000..d9d84d41 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/model/StockTest.java @@ -0,0 +1,67 @@ +package lambdasinaction.dsl.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class StockTest { + @Test + public void testGetMarket_1() + throws Exception { + Stock fixture = new Stock(); + fixture.setSymbol(""); + fixture.setMarket(""); + + String result = fixture.getMarket(); + + assertEquals("", result); + } + + @Test + public void testGetSymbol_1() + throws Exception { + Stock fixture = new Stock(); + fixture.setSymbol(""); + fixture.setMarket(""); + + String result = fixture.getSymbol(); + + assertEquals("", result); + } + + @Test + public void testSetMarket_1() + throws Exception { + Stock fixture = new Stock(); + fixture.setSymbol(""); + fixture.setMarket(""); + String market = ""; + + fixture.setMarket(market); + + } + + @Test + public void testSetSymbol_1() + throws Exception { + Stock fixture = new Stock(); + fixture.setSymbol(""); + fixture.setMarket(""); + String symbol = ""; + + fixture.setSymbol(symbol); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/model/TaxTest.java b/src/test/java/lambdasinaction/dsl/model/TaxTest.java new file mode 100644 index 00000000..787d1731 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/model/TaxTest.java @@ -0,0 +1,50 @@ +package lambdasinaction.dsl.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class TaxTest { + @Test + public void testGeneral_1() + throws Exception { + double value = 1.0; + + double result = Tax.general(value); + + assertEquals(1.3, result, 0.1); + } + + @Test + public void testRegional_1() + throws Exception { + double value = 1.0; + + double result = Tax.regional(value); + + assertEquals(1.1, result, 0.1); + } + + @Test + public void testSurcharge_1() + throws Exception { + double value = 1.0; + + double result = Tax.surcharge(value); + + assertEquals(1.05, result, 0.1); + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } + +} \ No newline at end of file diff --git a/src/test/java/lambdasinaction/dsl/model/TradeTest.java b/src/test/java/lambdasinaction/dsl/model/TradeTest.java new file mode 100644 index 00000000..56d1e0d0 --- /dev/null +++ b/src/test/java/lambdasinaction/dsl/model/TradeTest.java @@ -0,0 +1,151 @@ +package lambdasinaction.dsl.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class TradeTest { + @Test + public void testGetPrice_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + + double result = fixture.getPrice(); + + assertEquals(1.0, result, 0.1); + } + + @Test + public void testGetQuantity_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + + int result = fixture.getQuantity(); + + assertEquals(1, result); + } + + @Test + public void testGetStock_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + + Stock result = fixture.getStock(); + + assertNotNull(result); + assertEquals(null, result.getSymbol()); + assertEquals(null, result.getMarket()); + } + + @Test + public void testGetType_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + + Trade.Type result = fixture.getType(); + + assertNotNull(result); + assertEquals("BUY", result.name()); + assertEquals("BUY", result.toString()); + assertEquals(0, result.ordinal()); + } + + @Test + public void testGetValue_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + + double result = fixture.getValue(); + + assertEquals(1.0, result, 0.1); + } + + @Test + public void testSetPrice_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + double price = 1.0; + + fixture.setPrice(price); + + } + + @Test + public void testSetQuantity_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + int quantity = 1; + + fixture.setQuantity(quantity); + + } + + @Test + public void testSetStock_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + Stock stock = new Stock(); + + fixture.setStock(stock); + + } + + @Test + public void testSetType_1() + throws Exception { + Trade fixture = new Trade(); + fixture.setType(Trade.Type.BUY); + fixture.setPrice(1.0); + fixture.setStock(new Stock()); + fixture.setQuantity(1); + Trade.Type type = Trade.Type.BUY; + + fixture.setType(type); + + } + + @BeforeEach + public void setUp() + throws Exception { + } + + @AfterEach + public void tearDown() + throws Exception { + } +} \ No newline at end of file