diff --git a/.gitignore b/.gitignore
index 5be11c71ff..2edea19340 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
*/bin/*
+bin/
*.class
@@ -21,6 +22,9 @@
*.iws
out/
+# VSCode
+.vscode/
+
# Mac
.DS_Store
diff --git a/README.md b/README.md
index 1030cbb09c..4cad075cc3 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,16 @@
-The "REST with Spring" Classes
+The Courses
==============================
-Here's the Master Class of REST With Spring (along with the newly announced Boot 2 material):
-**[>> THE REST WITH SPRING - MASTER CLASS](http://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
-And here's the Master Class of Learn Spring Security:
-**[>> LEARN SPRING SECURITY - MASTER CLASS](http://www.baeldung.com/learn-spring-security-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=lss#master-class)**
+Here's the new "Learn Spring" course:
+**[>> LEARN SPRING - THE MASTER CLASS](https://www.baeldung.com/learn-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=ls#master-class)**
+
+Here's the Master Class of "REST With Spring" (along with the new announced Boot 2 material):
+**[>> THE REST WITH SPRING - MASTER CLASS](https://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
+
+And here's the Master Class of "Learn Spring Security":
+**[>> LEARN SPRING SECURITY - MASTER CLASS](https://www.baeldung.com/learn-spring-security-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=lss#master-class)**
@@ -15,7 +19,7 @@ Java and Spring Tutorials
This project is **a collection of small and focused tutorials** - each covering a single and well defined area of development in the Java ecosystem.
A strong focus of these is, of course, the Spring Framework - Spring, Spring Boot and Spring Security.
-In additional to Spring, the following technologies are in focus: `core Java`, `Jackson`, `HttpClient`, `Guava`.
+In additional to Spring, the modules here are covering a number of aspects in Java.
Building the project
@@ -32,8 +36,15 @@ Running a Spring Boot module
====================
To run a Spring Boot module run the command: `mvn spring-boot:run` in the module directory
-#Running Tests
+Working with the IDE
+====================
+This repo contains a large number of modules.
+When you're working with an individual module, there's no need to import all of them (or build all of them) - you can simply import that particular module in either Eclipse or IntelliJ.
+
+
+Running Tests
+=============
The command `mvn clean install` will run the unit tests in a module.
To run the integration tests, use the command `mvn clean install -Pintegration-lite-first`
diff --git a/algorithms-miscellaneous-3/README.md b/algorithms-miscellaneous-3/README.md
index 71541cd2b3..6a38df484a 100644
--- a/algorithms-miscellaneous-3/README.md
+++ b/algorithms-miscellaneous-3/README.md
@@ -1,4 +1,4 @@
-## Relevant articles:
+## Relevant Articles:
- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique)
- [Implementing Simple State Machines with Java Enums](https://www.baeldung.com/java-enum-simple-state-machine)
@@ -6,4 +6,4 @@
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
-- [A Guide to the Folding Technique](https://www.baeldung.com/folding-hashing-technique)
+- [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique)
diff --git a/algorithms-miscellaneous-3/src/main/java/com/baeldung/algorithms/stringsortingbynumber/NaturalOrderComparators.java b/algorithms-miscellaneous-3/src/main/java/com/baeldung/algorithms/stringsortingbynumber/NaturalOrderComparators.java
new file mode 100644
index 0000000000..376b196aa1
--- /dev/null
+++ b/algorithms-miscellaneous-3/src/main/java/com/baeldung/algorithms/stringsortingbynumber/NaturalOrderComparators.java
@@ -0,0 +1,30 @@
+package com.baeldung.algorithms.stringsortingbynumber;
+
+import java.util.Comparator;
+
+public final class NaturalOrderComparators {
+
+ private static final String DIGIT_AND_DECIMAL_REGEX = "[^\\d.]";
+
+ private NaturalOrderComparators() {
+ throw new AssertionError("Let's keep this static");
+ }
+
+ public static Comparator createNaturalOrderRegexComparator() {
+ return Comparator.comparingDouble(NaturalOrderComparators::parseStringToNumber);
+ }
+
+ private static double parseStringToNumber(String input){
+
+ final String digitsOnly = input.replaceAll(DIGIT_AND_DECIMAL_REGEX, "");
+
+ if("".equals(digitsOnly)) return 0;
+
+ try{
+ return Double.parseDouble(digitsOnly);
+ }catch (NumberFormatException nfe){
+ return 0;
+ }
+ }
+
+}
diff --git a/algorithms-miscellaneous-3/src/test/java/com/baeldung/algorithms/stringsortingbynumber/NaturalOrderComparatorsUnitTest.java b/algorithms-miscellaneous-3/src/test/java/com/baeldung/algorithms/stringsortingbynumber/NaturalOrderComparatorsUnitTest.java
new file mode 100644
index 0000000000..549151bc93
--- /dev/null
+++ b/algorithms-miscellaneous-3/src/test/java/com/baeldung/algorithms/stringsortingbynumber/NaturalOrderComparatorsUnitTest.java
@@ -0,0 +1,79 @@
+package com.baeldung.algorithms.stringsortingbynumber;
+
+import com.baeldung.algorithms.stringsortingbynumber.NaturalOrderComparators;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class NaturalOrderComparatorsUnitTest {
+
+ @Test
+ public void givenSimpleStringsContainingIntsAndDoubles_whenSortedByRegex_checkSortingCorrect() {
+
+ List testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.4", "d2.3d");
+
+ testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
+
+ List expected = Arrays.asList("a1", "d2.2", "d2.3d", "d2.4", "b3", "c4");
+
+ assertEquals(expected, testStrings);
+
+
+ }
+
+ @Test
+ public void givenSimpleStringsContainingIntsAndDoublesWithAnInvalidNumber_whenSortedByRegex_checkSortingCorrect() {
+
+ List testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.4", "d2.3.3d");
+
+ testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
+
+ List expected = Arrays.asList("d2.3.3d", "a1", "d2.2", "d2.4", "b3", "c4");
+
+ assertEquals(expected, testStrings);
+
+
+ }
+
+ @Test
+ public void givenAllForseenProblems_whenSortedByRegex_checkSortingCorrect() {
+
+ List testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.f4", "d2.3.3d");
+
+ testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
+
+ List expected = Arrays.asList("d2.3.3d", "a1", "d2.2", "d2.f4", "b3", "c4");
+
+ assertEquals(expected, testStrings);
+
+
+ }
+
+ @Test
+ public void givenComplexStringsContainingSeparatedNumbers_whenSortedByRegex_checkNumbersCondensedAndSorted() {
+
+ List testStrings = Arrays.asList("a1b2c5", "b3ght3.2", "something65.thensomething5"); //125, 33.2, 65.5
+
+ List expected = Arrays.asList("b3ght3.2", "something65.thensomething5", "a1b2c5" );
+
+ testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
+
+ assertEquals(expected, testStrings);
+
+ }
+
+ @Test
+ public void givenStringsNotContainingNumbers_whenSortedByRegex_checkOrderNotChanged() {
+
+ List testStrings = Arrays.asList("a", "c", "d", "e");
+ List expected = new ArrayList<>(testStrings);
+
+ testStrings.sort(NaturalOrderComparators.createNaturalOrderRegexComparator());
+
+ assertEquals(expected, testStrings);
+ }
+}
\ No newline at end of file
diff --git a/algorithms-sorting/src/main/java/com/baeldung/algorithms/shellsort/ShellSort.java b/algorithms-sorting/src/main/java/com/baeldung/algorithms/shellsort/ShellSort.java
new file mode 100644
index 0000000000..c130e2d866
--- /dev/null
+++ b/algorithms-sorting/src/main/java/com/baeldung/algorithms/shellsort/ShellSort.java
@@ -0,0 +1,20 @@
+package com.baeldung.algorithms.shellsort;
+
+public class ShellSort {
+
+ public static void sort(int arrayToSort[]) {
+ int n = arrayToSort.length;
+
+ for (int gap = n / 2; gap > 0; gap /= 2) {
+ for (int i = gap; i < n; i++) {
+ int key = arrayToSort[i];
+ int j = i;
+ while (j >= gap && arrayToSort[j - gap] > key) {
+ arrayToSort[j] = arrayToSort[j - gap];
+ j -= gap;
+ }
+ arrayToSort[j] = key;
+ }
+ }
+ }
+}
diff --git a/algorithms-sorting/src/test/java/com/baeldung/algorithms/shellsort/ShellSortUnitTest.java b/algorithms-sorting/src/test/java/com/baeldung/algorithms/shellsort/ShellSortUnitTest.java
new file mode 100644
index 0000000000..91a27c41d0
--- /dev/null
+++ b/algorithms-sorting/src/test/java/com/baeldung/algorithms/shellsort/ShellSortUnitTest.java
@@ -0,0 +1,17 @@
+package com.baeldung.algorithms.shellsort;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
+
+public class ShellSortUnitTest {
+
+ @Test
+ public void givenUnsortedArray_whenShellSort_thenSortedAsc() {
+ int[] input = {41, 15, 82, 5, 65, 19, 32, 43, 8};
+ ShellSort.sort(input);
+ int[] expected = {5, 8, 15, 19, 32, 41, 43, 65, 82};
+ assertArrayEquals("the two arrays are not equal", expected, input);
+ }
+}
diff --git a/apache-olingo/olingo2/pom.xml b/apache-olingo/olingo2/pom.xml
index e3647b9c57..24e7b4e0b2 100644
--- a/apache-olingo/olingo2/pom.xml
+++ b/apache-olingo/olingo2/pom.xml
@@ -82,7 +82,6 @@
- 1.8
2.0.11
diff --git a/aws/pom.xml b/aws/pom.xml
index 560f9145f9..75d5aac1eb 100644
--- a/aws/pom.xml
+++ b/aws/pom.xml
@@ -112,7 +112,6 @@
- 2.5
1.3.0
1.1.0
2.8.0
diff --git a/axon/pom.xml b/axon/pom.xml
index 2b9ac1fcdd..3d30cceb83 100644
--- a/axon/pom.xml
+++ b/axon/pom.xml
@@ -18,12 +18,6 @@
org.axonframework
axon-spring-boot-starter
${axon.version}
-
-
- org.axonframework
- axon-server-connector
-
-
@@ -58,7 +52,7 @@
- 4.0.3
+ 4.1.2
\ No newline at end of file
diff --git a/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java b/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java
index b37b2fdd66..4ef02e6b54 100644
--- a/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java
+++ b/axon/src/main/java/com/baeldung/axon/commandmodel/OrderAggregate.java
@@ -13,6 +13,7 @@ import com.baeldung.axon.coreapi.commands.ShipOrderCommand;
import com.baeldung.axon.coreapi.events.OrderConfirmedEvent;
import com.baeldung.axon.coreapi.events.OrderPlacedEvent;
import com.baeldung.axon.coreapi.events.OrderShippedEvent;
+import com.baeldung.axon.coreapi.exceptions.UnconfirmedOrderException;
@Aggregate
public class OrderAggregate {
@@ -34,7 +35,7 @@ public class OrderAggregate {
@CommandHandler
public void handle(ShipOrderCommand command) {
if (!orderConfirmed) {
- throw new IllegalStateException("Cannot ship an order which has not been confirmed yet.");
+ throw new UnconfirmedOrderException();
}
apply(new OrderShippedEvent(orderId));
@@ -43,12 +44,12 @@ public class OrderAggregate {
@EventSourcingHandler
public void on(OrderPlacedEvent event) {
this.orderId = event.getOrderId();
- orderConfirmed = false;
+ this.orderConfirmed = false;
}
@EventSourcingHandler
public void on(OrderConfirmedEvent event) {
- orderConfirmed = true;
+ this.orderConfirmed = true;
}
protected OrderAggregate() {
diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/UnconfirmedOrderException.java b/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/UnconfirmedOrderException.java
new file mode 100644
index 0000000000..1873bc6893
--- /dev/null
+++ b/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/UnconfirmedOrderException.java
@@ -0,0 +1,8 @@
+package com.baeldung.axon.coreapi.exceptions;
+
+public class UnconfirmedOrderException extends IllegalStateException {
+
+ public UnconfirmedOrderException() {
+ super("Cannot ship an order which has not been confirmed yet.");
+ }
+}
diff --git a/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java
index d4cf3d999b..a37f0111ed 100644
--- a/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java
+++ b/axon/src/main/java/com/baeldung/axon/querymodel/OrderedProductsEventHandler.java
@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.axonframework.config.ProcessingGroup;
import org.axonframework.eventhandling.EventHandler;
import org.axonframework.queryhandling.QueryHandler;
import org.springframework.stereotype.Service;
@@ -16,6 +17,7 @@ import com.baeldung.axon.coreapi.queries.FindAllOrderedProductsQuery;
import com.baeldung.axon.coreapi.queries.OrderedProduct;
@Service
+@ProcessingGroup("ordered-products")
public class OrderedProductsEventHandler {
private final Map orderedProducts = new HashMap<>();
diff --git a/axon/src/main/resources/application.properties b/axon/src/main/resources/application.properties
new file mode 100644
index 0000000000..7c51eb8e1e
--- /dev/null
+++ b/axon/src/main/resources/application.properties
@@ -0,0 +1 @@
+spring.application.name=Order Management Service
\ No newline at end of file
diff --git a/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java b/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java
index 9beedbaa19..aaefe49fb1 100644
--- a/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java
+++ b/axon/src/test/java/com/baeldung/axon/commandmodel/OrderAggregateUnitTest.java
@@ -2,6 +2,7 @@ package com.baeldung.axon.commandmodel;
import java.util.UUID;
+import com.baeldung.axon.coreapi.exceptions.UnconfirmedOrderException;
import org.axonframework.test.aggregate.AggregateTestFixture;
import org.axonframework.test.aggregate.FixtureConfiguration;
import org.junit.*;
@@ -41,12 +42,12 @@ public class OrderAggregateUnitTest {
}
@Test
- public void givenOrderPlacedEvent_whenShipOrderCommand_thenShouldThrowIllegalStateException() {
+ public void givenOrderPlacedEvent_whenShipOrderCommand_thenShouldThrowUnconfirmedOrderException() {
String orderId = UUID.randomUUID().toString();
String product = "Deluxe Chair";
fixture.given(new OrderPlacedEvent(orderId, product))
.when(new ShipOrderCommand(orderId))
- .expectException(IllegalStateException.class);
+ .expectException(UnconfirmedOrderException.class);
}
@Test
diff --git a/core-groovy-2/pom.xml b/core-groovy-2/pom.xml
index 53b3e6a7ec..ba3fd0802b 100644
--- a/core-groovy-2/pom.xml
+++ b/core-groovy-2/pom.xml
@@ -175,8 +175,6 @@
1.0.0
2.4.0
1.1-groovy-2.4
- 3.9
- 1.8
3.8.1
1.2.3
2.5.7
diff --git a/core-groovy-2/src/main/groovy/com/baeldung/concatenate/Wonder.groovy b/core-groovy-2/src/main/groovy/com/baeldung/concatenate/Wonder.groovy
new file mode 100644
index 0000000000..1d7527726e
--- /dev/null
+++ b/core-groovy-2/src/main/groovy/com/baeldung/concatenate/Wonder.groovy
@@ -0,0 +1,52 @@
+package com.baeldung.concatenate
+
+class Wonder {
+
+ String numOfWonder = 'seven'
+
+ String operator_plus() {
+ return 'The ' + numOfWonder + ' wonders of the world'
+ }
+
+ String operator_left() {
+ return 'The ' << numOfWonder << ' wonders of ' << 'the world'
+ }
+
+ String interpolation_one() {
+ return "The $numOfWonder wonders of the world"
+
+ }
+
+ String interpolation_two() {
+ return "The ${numOfWonder} wonders of the world"
+ }
+
+ String multilineString() {
+ return """
+ There are $numOfWonder wonders of the world.
+ Can you name them all?
+ 1. The Great Pyramid of Giza
+ 2. Hanging Gardens of Babylon
+ 3. Colossus of Rhode
+ 4. Lighthouse of Alexendra
+ 5. Temple of Artemis
+ 6. Status of Zeus at Olympia
+ 7. Mausoleum at Halicarnassus
+ """
+ }
+
+ String method_concat() {
+ return 'The '.concat(numOfWonder).concat(' wonders of the world')
+
+ }
+
+ String method_builder() {
+ return new StringBuilder()
+ .append('The ').append(numOfWonder).append(' wonders of the world')
+ }
+
+ String method_buffer() {
+ return new StringBuffer()
+ .append('The ').append(numOfWonder).append(' wonders of the world')
+ }
+}
\ No newline at end of file
diff --git a/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/Employee.groovy b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/Employee.groovy
new file mode 100644
index 0000000000..f49d0f906b
--- /dev/null
+++ b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/Employee.groovy
@@ -0,0 +1,45 @@
+package com.baeldung.metaprogramming
+
+import groovy.transform.AutoClone
+import groovy.transform.Canonical
+import groovy.transform.EqualsAndHashCode
+import groovy.transform.ToString
+import groovy.transform.TupleConstructor
+import groovy.util.logging.*
+
+@Canonical
+@TupleConstructor
+@EqualsAndHashCode
+@ToString(includePackage=false, excludes=['id'])
+@Log
+@AutoClone
+class Employee {
+
+ long id
+ String firstName
+ String lastName
+ int age
+
+ //method to catch missing property's getter
+ def propertyMissing(String propertyName) {
+ log.info "$propertyName is not available"
+ "property '$propertyName' is not available"
+ }
+
+ //method to catch missing property's setter
+ def propertyMissing(String propertyName, propertyValue) {
+ println "property '$propertyName' is not available"
+ log.info "$propertyName is not available"
+ "property '$propertyName' is not available"
+ }
+
+ def methodMissing(String methodName, def methodArgs) {
+ log.info "$methodName is not defined"
+ "method '$methodName' is not defined"
+ }
+
+ def logEmp() {
+ log.info "Employee: $lastName, $firstName is of $age years age"
+ }
+
+}
\ No newline at end of file
diff --git a/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/BasicExtensions.groovy b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/BasicExtensions.groovy
new file mode 100644
index 0000000000..65591cae8d
--- /dev/null
+++ b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/BasicExtensions.groovy
@@ -0,0 +1,30 @@
+package com.baeldung.metaprogramming.extension
+
+import com.baeldung.metaprogramming.Employee
+
+class BasicExtensions {
+
+ static int getYearOfBirth(Employee self) {
+ return (new Date().getYear() + 1900) - self.age;
+ }
+
+ static String capitalize(String self) {
+ return self.substring(0, 1).toUpperCase() + self.substring(1)
+ }
+
+ static void printCounter(Integer self) {
+ while (self>0) {
+ println self
+ self--
+ }
+ }
+
+ static Long square(Long self) {
+ return self*self
+ }
+
+ static BigDecimal cube(BigDecimal self) {
+ return self*self*self
+ }
+
+}
\ No newline at end of file
diff --git a/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/StaticEmployeeExtension.groovy b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/StaticEmployeeExtension.groovy
new file mode 100644
index 0000000000..ab2aac38ea
--- /dev/null
+++ b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/extension/StaticEmployeeExtension.groovy
@@ -0,0 +1,10 @@
+package com.baeldung.metaprogramming.extension
+
+import com.baeldung.metaprogramming.Employee
+
+class StaticEmployeeExtension {
+
+ static Employee getDefaultObj(Employee self) {
+ return new Employee(firstName: "firstName", lastName: "lastName", age: 20)
+ }
+}
\ No newline at end of file
diff --git a/core-groovy-2/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/core-groovy-2/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
new file mode 100644
index 0000000000..967108b846
--- /dev/null
+++ b/core-groovy-2/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule
@@ -0,0 +1,4 @@
+moduleName=core-groovy-2
+moduleVersion=1.0-SNAPSHOT
+extensionClasses=com.baeldung.metaprogramming.extension.BasicExtensions
+staticExtensionClasses=com.baeldung.metaprogramming.extension.StaticEmployeeExtension
diff --git a/core-groovy-2/src/test/groovy/com/baeldung/concatenate/WonderUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/concatenate/WonderUnitTest.groovy
new file mode 100644
index 0000000000..5fc74abd69
--- /dev/null
+++ b/core-groovy-2/src/test/groovy/com/baeldung/concatenate/WonderUnitTest.groovy
@@ -0,0 +1,69 @@
+package com.baeldung.concatenate
+
+import org.junit.Before
+import org.junit.Test
+
+import static org.junit.Assert.*
+
+class WonderUnitTest {
+
+ static final String EXPECTED_SINGLE_LINE = "The seven wonders of the world"
+
+ Wonder wonder
+
+ @Before
+ void before() {
+ wonder = new Wonder()
+ }
+
+ @Test
+ void whenUsingOperatorPlus_thenConcatCorrectly() {
+ assertEquals(EXPECTED_SINGLE_LINE, wonder.operator_plus())
+ }
+
+ @Test
+ void whenUsingOperatorLeft_thenConcatCorrectly() {
+ assertEquals(EXPECTED_SINGLE_LINE, wonder.operator_left())
+ }
+
+ @Test
+ void whenUsingInterpolationOne_thenConcatCorrectly() {
+ assertEquals(EXPECTED_SINGLE_LINE, wonder.interpolation_one())
+ }
+
+ @Test
+ void whenUsingInterpolationTwo_thenConcatCorrectly() {
+ assertEquals(EXPECTED_SINGLE_LINE, wonder.interpolation_two())
+ }
+
+ @Test
+ void whenUsingMultiline_thenConcatCorrectly() {
+ def expectedMultiline = """
+ There are seven wonders of the world.
+ Can you name them all?
+ 1. The Great Pyramid of Giza
+ 2. Hanging Gardens of Babylon
+ 3. Colossus of Rhode
+ 4. Lighthouse of Alexendra
+ 5. Temple of Artemis
+ 6. Status of Zeus at Olympia
+ 7. Mausoleum at Halicarnassus
+ """
+ assertEquals(expectedMultiline, wonder.multilineString())
+ }
+
+ @Test
+ void whenUsingMethodConcat_thenConcatCorrectly() {
+ assertEquals(EXPECTED_SINGLE_LINE, wonder.method_concat())
+ }
+
+ @Test
+ void whenUsingMethodBuilder_thenConcatCorrectly() {
+ assertEquals(EXPECTED_SINGLE_LINE, wonder.method_builder())
+ }
+
+ @Test
+ void whenUsingMethodBuffer_thenConcatCorrectly() {
+ assertEquals(EXPECTED_SINGLE_LINE, wonder.method_buffer())
+ }
+}
diff --git a/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy
new file mode 100644
index 0000000000..8066b10f9b
--- /dev/null
+++ b/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy
@@ -0,0 +1,118 @@
+package com.baeldung.metaprogramming
+
+import groovy.time.TimeCategory
+
+class MetaprogrammingUnitTest extends GroovyTestCase {
+
+ Employee emp = new Employee(firstName: "Norman", lastName: "Lewis")
+
+ void testPropertyMissing() {
+ assert emp.address == "property 'address' is not available"
+ }
+
+ void testMethodMissing() {
+ Employee emp = new Employee()
+ try {
+ emp.getFullName()
+ } catch(MissingMethodException e) {
+ println "method is not defined"
+ }
+ assert emp.getFullName() == "method 'getFullName' is not defined"
+ }
+
+ void testMetaClassProperty() {
+ Employee.metaClass.address = ""
+ emp = new Employee(firstName: "Norman", lastName: "Lewis", address: "US")
+ assert emp.address == "US"
+ }
+
+ void testMetaClassMethod() {
+ emp.metaClass.getFullName = {
+ "$lastName, $firstName"
+ }
+ assert emp.getFullName() == "Lewis, Norman"
+ }
+
+ void testMetaClassConstructor() {
+ try {
+ Employee emp = new Employee("Norman")
+ } catch(GroovyRuntimeException e) {
+ assert e.message == "Could not find matching constructor for: com.baeldung.metaprogramming.Employee(String)"
+ }
+
+ Employee.metaClass.constructor = { String firstName ->
+ new Employee(firstName: firstName)
+ }
+
+ Employee norman = new Employee("Norman")
+ assert norman.firstName == "Norman"
+ assert norman.lastName == null
+ }
+
+ void testJavaMetaClass() {
+ String.metaClass.capitalize = { String str ->
+ str.substring(0, 1).toUpperCase() + str.substring(1);
+ }
+ assert "norman".capitalize() == "Norman"
+ }
+
+ void testEmployeeExtension() {
+ Employee emp = new Employee(age: 28)
+ assert emp.getYearOfBirth() == 1991
+ }
+
+ void testJavaClassesExtensions() {
+ 5.printCounter()
+
+ assert 40l.square() == 1600l
+
+ assert (2.98).cube() == 26.463592
+ }
+
+ void testStaticEmployeeExtension() {
+ assert Employee.getDefaultObj().firstName == "firstName"
+ assert Employee.getDefaultObj().lastName == "lastName"
+ assert Employee.getDefaultObj().age == 20
+ }
+
+ void testToStringAnnotation() {
+ Employee employee = new Employee()
+ employee.id = 1
+ employee.firstName = "norman"
+ employee.lastName = "lewis"
+ employee.age = 28
+
+ assert employee.toString() == "Employee(norman, lewis, 28)"
+ }
+
+ void testTupleConstructorAnnotation() {
+ Employee norman = new Employee(1, "norman", "lewis", 28)
+ assert norman.toString() == "Employee(norman, lewis, 28)"
+
+ Employee snape = new Employee(2, "snape")
+ assert snape.toString() == "Employee(snape, null, 0)"
+
+ }
+
+ void testEqualsAndHashCodeAnnotation() {
+ Employee norman = new Employee(1, "norman", "lewis", 28)
+ Employee normanCopy = new Employee(1, "norman", "lewis", 28)
+ assert norman.equals(normanCopy)
+ assert norman.hashCode() == normanCopy.hashCode()
+ }
+
+ void testAutoCloneAnnotation() {
+ try {
+ Employee norman = new Employee(1, "norman", "lewis", 28)
+ def normanCopy = norman.clone()
+ assert norman == normanCopy
+ } catch(CloneNotSupportedException e) {
+ e.printStackTrace()
+ }
+ }
+
+ void testLoggingAnnotation() {
+ Employee employee = new Employee(1, "Norman", "Lewis", 28)
+ employee.logEmp()
+ }
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-11/src/main/java/com/baeldung/predicate/not/README.md b/core-java-modules/core-java-11/src/main/java/com/baeldung/predicate/not/README.md
new file mode 100644
index 0000000000..6f8f95970e
--- /dev/null
+++ b/core-java-modules/core-java-11/src/main/java/com/baeldung/predicate/not/README.md
@@ -0,0 +1,3 @@
+## Relevant articles:
+
+- [Negate a Predicate Method Reference with Java 11](https://www.baeldung.com/java-negate-predicate-method-reference)
diff --git a/core-java-modules/core-java-12/README.md b/core-java-modules/core-java-12/README.md
new file mode 100644
index 0000000000..6c603e4dea
--- /dev/null
+++ b/core-java-modules/core-java-12/README.md
@@ -0,0 +1,4 @@
+## Relevant Articles:
+
+
+- [String API Updates in Java 12](https://www.baeldung.com/java12-string-api)
diff --git a/core-java-modules/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md
index 245fa93ba7..d11510b2aa 100644
--- a/core-java-modules/core-java-8-2/README.md
+++ b/core-java-modules/core-java-8-2/README.md
@@ -7,3 +7,4 @@
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
- [Run JAR Application With Command Line Arguments](https://www.baeldung.com/java-run-jar-with-arguments)
- [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit)
+- [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface)
diff --git a/core-java-modules/core-java-8/pom.xml b/core-java-modules/core-java-8/pom.xml
index c09c970e07..28182e515b 100644
--- a/core-java-modules/core-java-8/pom.xml
+++ b/core-java-modules/core-java-8/pom.xml
@@ -175,7 +175,6 @@
- 3.5
3.6.1
4.1
4.01
diff --git a/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/Tuple.java b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/Tuple.java
new file mode 100644
index 0000000000..7a9f62341e
--- /dev/null
+++ b/core-java-modules/core-java-8/src/main/java/com/baeldung/java_8_features/groupingby/Tuple.java
@@ -0,0 +1,34 @@
+package com.baeldung.java_8_features.groupingby;
+
+public class Tuple {
+
+ private BlogPostType type;
+ private String author;
+
+ public Tuple(BlogPostType type, String author) {
+ super();
+ this.type = type;
+ this.author = author;
+ }
+
+ public BlogPostType getType() {
+ return type;
+ }
+
+ public void setType(BlogPostType type) {
+ this.type = type;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ @Override
+ public String toString() {
+ return "Tuple [type=" + type + ", author=" + author + ", getType()=" + getType() + ", getAuthor()=" + getAuthor() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]";
+ }
+}
diff --git a/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java
index bd7943c77b..bf594610bb 100644
--- a/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java
+++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java
@@ -259,4 +259,15 @@ public class OptionalUnitTest {
LOG.debug("Getting default value...");
return "Default Value";
}
+
+// Uncomment code when code base is compatiable with Java 11
+// @Test
+// public void givenAnEmptyOptional_thenIsEmptyBehavesAsExpected() {
+// Optional opt = Optional.of("Baeldung");
+// assertFalse(opt.isEmpty());
+//
+// opt = Optional.ofNullable(null);
+// assertTrue(opt.isEmpty());
+// }
+
}
\ No newline at end of file
diff --git a/core-java-modules/core-java-arrays-2/.gitignore b/core-java-modules/core-java-arrays-2/.gitignore
new file mode 100644
index 0000000000..374c8bf907
--- /dev/null
+++ b/core-java-modules/core-java-arrays-2/.gitignore
@@ -0,0 +1,25 @@
+*.class
+
+0.*
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+.resourceCache
+
+# Packaged files #
+*.jar
+*.war
+*.ear
+
+# Files generated by integration tests
+backup-pom.xml
+/bin/
+/temp
+
+#IntelliJ specific
+.idea/
+*.iml
\ No newline at end of file
diff --git a/core-java-arrays/README.MD b/core-java-modules/core-java-arrays-2/README.MD
similarity index 100%
rename from core-java-arrays/README.MD
rename to core-java-modules/core-java-arrays-2/README.MD
diff --git a/core-java-modules/core-java-arrays-2/pom.xml b/core-java-modules/core-java-arrays-2/pom.xml
new file mode 100644
index 0000000000..bfe8a349e1
--- /dev/null
+++ b/core-java-modules/core-java-arrays-2/pom.xml
@@ -0,0 +1,50 @@
+
+ 4.0.0
+ com.baeldung
+ core-java-arrays-2
+ 0.1.0-SNAPSHOT
+ core-java-arrays-2
+ jar
+
+
+ com.baeldung
+ parent-java
+ 0.0.1-SNAPSHOT
+ ../../parent-java
+
+
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+
+ org.assertj
+ assertj-core
+ ${assertj-core.version}
+ test
+
+
+
+
+ core-java-arrays-2
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+
+ 3.9
+
+ 3.10.0
+
+
+
diff --git a/core-java-arrays/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java b/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java
similarity index 100%
rename from core-java-arrays/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java
rename to core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java
diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/looping/LoopDiagonally.java b/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/looping/LoopDiagonally.java
new file mode 100644
index 0000000000..71e2840f45
--- /dev/null
+++ b/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/looping/LoopDiagonally.java
@@ -0,0 +1,45 @@
+package com.baeldung.array.looping;
+
+public class LoopDiagonally {
+
+
+ public String loopDiagonally(String[][] twoDArray) {
+
+ int length = twoDArray.length;
+ int diagonalLines = (length + length) - 1;
+ int itemsInDiagonal = 0;
+ int midPoint = (diagonalLines / 2) + 1;
+ StringBuilder output = new StringBuilder();
+
+ for (int i = 1; i <= diagonalLines; i++) {
+
+ StringBuilder items = new StringBuilder();
+ int rowIndex;
+ int columnIndex;
+
+ if (i <= midPoint) {
+ itemsInDiagonal++;
+ for (int j = 0; j < itemsInDiagonal; j++) {
+ rowIndex = (i - j) - 1;
+ columnIndex = j;
+ items.append(twoDArray[rowIndex][columnIndex]);
+ }
+ } else {
+ itemsInDiagonal--;
+ for (int j = 0; j < itemsInDiagonal; j++) {
+ rowIndex = (length - 1) - j;
+ columnIndex = (i - length) + j;
+ items.append(twoDArray[rowIndex][columnIndex]);
+ }
+ }
+
+ if (i != diagonalLines) {
+ output.append(items).append(" ");
+ } else {
+ output.append(items);
+ }
+ }
+
+ return output.toString();
+ }
+}
diff --git a/core-java-arrays/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java
similarity index 100%
rename from core-java-arrays/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java
rename to core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java
diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java
new file mode 100644
index 0000000000..5f670f4a59
--- /dev/null
+++ b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java
@@ -0,0 +1,20 @@
+package com.baeldung.array.looping;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class LoopDiagonallyUnitTest {
+
+ @Test
+ public void twoArrayIsLoopedDiagonallyAsExpected() {
+
+ LoopDiagonally loopDiagonally = new LoopDiagonally();
+ String[][] twoDArray = {{"a", "b", "c"},
+ {"d", "e", "f"},
+ {"g", "h", "i"}};
+
+ String output = loopDiagonally.loopDiagonally(twoDArray);
+ assertEquals("a db gec hf i", output);
+ }
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md
index b5f71cc253..45feff3edc 100644
--- a/core-java-modules/core-java-arrays/README.md
+++ b/core-java-modules/core-java-arrays/README.md
@@ -7,7 +7,7 @@
- [Check if a Java Array Contains a Value](http://www.baeldung.com/java-array-contains-value)
- [Initializing Arrays in Java](http://www.baeldung.com/java-initialize-array)
- [Guide to the java.util.Arrays Class](http://www.baeldung.com/java-util-arrays)
-- [Jagged Arrays In Java](http://www.baeldung.com/java-jagged-arrays)
+- [Multi-Dimensional Arrays In Java](http://www.baeldung.com/java-jagged-arrays)
- [Find Sum and Average in a Java Array](http://www.baeldung.com/java-array-sum-average)
- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide)
- [How to Invert an Array in Java](http://www.baeldung.com/java-invert-array)
@@ -16,3 +16,4 @@
- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays)
- [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array)
- [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array)
+- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SortedArrayChecker.java b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SortedArrayChecker.java
index ec612fd53b..78a9a8f4d1 100644
--- a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SortedArrayChecker.java
+++ b/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SortedArrayChecker.java
@@ -2,7 +2,10 @@ package com.baeldung.array;
import com.baeldung.arraycopy.model.Employee;
+import java.util.Comparator;
+
public class SortedArrayChecker {
+
boolean isSorted(int[] array, int length) {
if (array == null || length < 2)
return true;
@@ -22,7 +25,7 @@ public class SortedArrayChecker {
return true;
}
- boolean isSorted(String[] array, int length) {
+ boolean isSorted(Comparable[] array, int length) {
if (array == null || length < 2)
return true;
@@ -32,40 +35,31 @@ public class SortedArrayChecker {
return isSorted(array, length - 1);
}
-boolean isSorted(String[] array) {
- for (int i = 0; i < array.length - 1; ++i) {
- if (array[i].compareTo(array[i + 1]) > 0)
- return false;
- }
-
- return true;
-}
-
- boolean isSortedByName(Employee[] array) {
+ boolean isSorted(Comparable[] array) {
for (int i = 0; i < array.length - 1; ++i) {
- if (array[i].getName().compareTo(array[i + 1].getName()) > 0)
+ if (array[i].compareTo(array[i + 1]) > 0)
return false;
}
return true;
}
-boolean isSortedByAge(Employee[] array) {
- for (int i = 0; i < array.length - 1; ++i) {
- if (array[i].getAge() > (array[i + 1].getAge()))
- return false;
+ boolean isSorted(Object[] array, Comparator comparator) {
+ for (int i = 0; i < array.length - 1; ++i) {
+ if (comparator.compare(array[i], (array[i + 1])) > 0)
+ return false;
+ }
+
+ return true;
}
- return true;
-}
-
- boolean isSortedByAge(Employee[] array, int length) {
+ boolean isSorted(Object[] array, Comparator comparator, int length) {
if (array == null || length < 2)
return true;
- if (array[length - 2].getAge() > array[length - 1].getAge())
+ if (comparator.compare(array[length - 2], array[length - 1]) > 0)
return false;
- return isSortedByAge(array, length - 1);
+ return isSorted(array, comparator, length - 1);
}
}
diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java
index 29866a3c22..7971e0eab7 100644
--- a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java
+++ b/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java
@@ -4,32 +4,33 @@ import com.baeldung.arraycopy.model.Employee;
import org.junit.Before;
import org.junit.Test;
+import java.util.Comparator;
+
import static org.assertj.core.api.Assertions.assertThat;
-class SortedArrayCheckerUnitTest {
-
+public class SortedArrayCheckerUnitTest {
private static final int[] INTEGER_SORTED = {1, 3, 5, 7, 9};
private static final int[] INTEGER_NOT_SORTED = {1, 3, 11, 7};
private static final String[] STRING_SORTED = {"abc", "cde", "fgh"};
private static final String[] STRING_NOT_SORTED = {"abc", "fgh", "cde", "ijk"};
- private final Employee[] EMPLOYEES_SORTED_BY_NAME = {
+ private static final Employee[] EMPLOYEES_SORTED_BY_NAME = {
new Employee(1, "Carlos", 26),
new Employee(2, "Daniel", 31),
new Employee(3, "Marta", 27)};
- private final Employee[] EMPLOYEES_NOT_SORTED_BY_NAME = {
+ private static final Employee[] EMPLOYEES_NOT_SORTED_BY_NAME = {
new Employee(1, "Daniel", 31),
new Employee(2, "Carlos", 26),
new Employee(3, "Marta", 27)};
- private final Employee[] EMPLOYEES_SORTED_BY_AGE = {
+ private static final Employee[] EMPLOYEES_SORTED_BY_AGE = {
new Employee(1, "Carlos", 26),
new Employee(2, "Marta", 27),
new Employee(3, "Daniel", 31)};
- private final Employee[] EMPLOYEES_NOT_SORTED_BY_AGE = {
+ private static final Employee[] EMPLOYEES_NOT_SORTED_BY_AGE = {
new Employee(1, "Marta", 27),
new Employee(2, "Carlos", 26),
new Employee(3, "Daniel", 31)};
@@ -61,13 +62,18 @@ class SortedArrayCheckerUnitTest {
@Test
public void givenEmployeeArray_thenReturnIfItIsSortedOrNot() {
- assertThat(sortedArrayChecker.isSortedByName(EMPLOYEES_SORTED_BY_NAME)).isEqualTo(true);
- assertThat(sortedArrayChecker.isSortedByName(EMPLOYEES_NOT_SORTED_BY_NAME)).isEqualTo(false);
+ assertThat(sortedArrayChecker.isSorted(EMPLOYEES_SORTED_BY_NAME, Comparator.comparing(Employee::getName))).isEqualTo(true);
+ assertThat(sortedArrayChecker.isSorted(EMPLOYEES_NOT_SORTED_BY_NAME, Comparator.comparing(Employee::getName))).isEqualTo(false);
- assertThat(sortedArrayChecker.isSortedByAge(EMPLOYEES_SORTED_BY_AGE)).isEqualTo(true);
- assertThat(sortedArrayChecker.isSortedByAge(EMPLOYEES_NOT_SORTED_BY_AGE)).isEqualTo(false);
+ assertThat(sortedArrayChecker.isSorted(EMPLOYEES_SORTED_BY_AGE, Comparator.comparingInt(Employee::getAge))).isEqualTo(true);
+ assertThat(sortedArrayChecker.isSorted(EMPLOYEES_NOT_SORTED_BY_AGE, Comparator.comparingInt(Employee::getAge))).isEqualTo(false);
- assertThat(sortedArrayChecker.isSortedByAge(EMPLOYEES_SORTED_BY_AGE, EMPLOYEES_SORTED_BY_AGE.length)).isEqualTo(true);
- assertThat(sortedArrayChecker.isSortedByAge(EMPLOYEES_NOT_SORTED_BY_AGE, EMPLOYEES_NOT_SORTED_BY_AGE.length)).isEqualTo(false);
+ assertThat(sortedArrayChecker
+ .isSorted(EMPLOYEES_SORTED_BY_AGE, Comparator.comparingInt(Employee::getAge), EMPLOYEES_SORTED_BY_AGE.length))
+ .isEqualTo(true);
+ assertThat(sortedArrayChecker
+ .isSorted(EMPLOYEES_NOT_SORTED_BY_AGE, Comparator.comparingInt(Employee::getAge), EMPLOYEES_NOT_SORTED_BY_AGE.length))
+ .isEqualTo(false);
}
+
}
\ No newline at end of file
diff --git a/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java b/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java
index ecf68e0b2c..5f7fe356c5 100644
--- a/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java
+++ b/core-java-modules/core-java-collections-array-list/src/test/java/org/baeldung/java/collections/CoreJavaCollectionsUnitTest.java
@@ -42,7 +42,7 @@ public class CoreJavaCollectionsUnitTest {
@Test(expected = UnsupportedOperationException.class)
public final void givenUsingGuavaBuilder_whenUnmodifiableListIsCreatedFromOriginal_thenNoLongerModifiable() {
final List list = new ArrayList(Arrays.asList("one", "two", "three"));
- final ImmutableList