From 3ce04cafd5b8e4e82ce38a51bfbe9fd0f5f5c6aa Mon Sep 17 00:00:00 2001 From: panos-kakos <102670093+panos-kakos@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:47:55 +0100 Subject: [PATCH 1/4] [Java 11502] (#12625) * [JAVA-11502] Added vavr-modules (parent) * [JAVA-11502] Added vavr(submodule) to vavr-modules(parent) * [JAVA-11502] Added vavr-2(submodule) to vavr-modules(parent) * [JAVA-11502] Added java-vavr-stream(submodule) to vavr-modules(parent) * [JAVA-11502] deleted modules that were moved + cleanup Co-authored-by: panagiotiskakos Co-authored-by: Dhawal Kapil --- pom.xml | 10 +- vavr-modules/README.md | 3 + .../java-vavr-stream}/README.md | 0 .../java-vavr-stream}/pom.xml | 2 +- .../samples/java/vavr/VavrSampler.java | 0 .../src/main/resources/logback.xml | 0 vavr-modules/pom.xml | 33 +++ {vavr-2 => vavr-modules/vavr-2}/README.md | 0 {vavr-2 => vavr-modules/vavr-2}/pom.xml | 7 +- .../com/baeldung/vavr/either/EitherDemo.java | 0 .../baeldung/vavr/either/EitherUnitTest.java | 0 .../CollectionsInteroperabilityUnitTest.java | 0 {vavr => vavr-modules/vavr}/README.md | 0 {vavr => vavr-modules/vavr}/pom.xml | 2 +- .../main/java/com/baeldung/Application.java | 0 .../repositories/VavrUserRepository.java | 0 .../samples/java/vavr/VavrSampler.java | 0 .../main/java/com/baeldung/vavr/Person.java | 0 .../com/baeldung/vavr/PersonValidator.java | 0 .../src/main/java/com/baeldung/vavr/User.java | 0 .../vavr/exception/handling/JavaTryCatch.java | 0 .../vavr/exception/handling/VavrTry.java | 0 .../handling/client/ClientException.java | 0 .../exception/handling/client/HttpClient.java | 0 .../exception/handling/client/Response.java | 0 .../application/Application.java | 0 .../baeldung/vavrvalidation/model/User.java | 0 .../validator/UserValidator.java | 0 .../vavr}/src/main/resources/logback.xml | 0 .../vavr/PatternMatchingUnitTest.java | 0 .../PropertyBasedLongRunningUnitTest.java | 0 .../java/com/baeldung/vavr/VavrUnitTest.java | 0 .../collections/CollectionAPIUnitTest.java | 0 .../CollectionFactoryMethodsUnitTest.java | 214 +++++++++--------- .../VavrExceptionHandlingUnitTest.java | 174 +++++++------- .../exception/handling/VavrTryUnitTest.java | 0 .../baeldung/vavr/future/FutureUnitTest.java | 0 .../VavrRepositoryIntegrationTest.java | 0 .../validator/UserValidatorUnitTest.java | 0 .../validator/ValidationUnitTest.java | 0 40 files changed, 239 insertions(+), 206 deletions(-) create mode 100644 vavr-modules/README.md rename {java-vavr-stream => vavr-modules/java-vavr-stream}/README.md (100%) rename {java-vavr-stream => vavr-modules/java-vavr-stream}/pom.xml (94%) rename {java-vavr-stream => vavr-modules/java-vavr-stream}/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java (100%) rename {java-vavr-stream => vavr-modules/java-vavr-stream}/src/main/resources/logback.xml (100%) create mode 100644 vavr-modules/pom.xml rename {vavr-2 => vavr-modules/vavr-2}/README.md (100%) rename {vavr-2 => vavr-modules/vavr-2}/pom.xml (74%) rename {vavr-2 => vavr-modules/vavr-2}/src/main/java/com/baeldung/vavr/either/EitherDemo.java (100%) rename {vavr-2 => vavr-modules/vavr-2}/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java (100%) rename {vavr-2 => vavr-modules/vavr-2}/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/README.md (100%) rename {vavr => vavr-modules/vavr}/pom.xml (96%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/Application.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/repositories/VavrUserRepository.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/Person.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/PersonValidator.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/User.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavrvalidation/application/Application.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavrvalidation/model/User.java (100%) rename {vavr => vavr-modules/vavr}/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java (100%) rename {vavr => vavr-modules/vavr}/src/main/resources/logback.xml (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/VavrUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java (96%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java (96%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java (100%) rename {vavr => vavr-modules/vavr}/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java (100%) diff --git a/pom.xml b/pom.xml index b8a73ad0a0..4bd983e30b 100644 --- a/pom.xml +++ b/pom.xml @@ -410,7 +410,6 @@ java-jdi java-rmi java-spi - java-vavr-stream java-websocket javax-sound javaxval @@ -488,6 +487,7 @@ reactive-systems security-modules slack + vavr-modules web-modules @@ -692,8 +692,7 @@ spring-ejb-modules/ejb-beans vaadin - vavr - vavr-2 + vavr-modules @@ -809,7 +808,6 @@ java-jdi java-rmi java-spi - java-vavr-stream java-websocket javax-sound javaxval @@ -889,6 +887,7 @@ reactive-systems security-modules slack + vavr-modules web-modules @@ -1079,8 +1078,7 @@ spring-ejb-modules/ejb-beans vaadin - vavr - vavr-2 + vavr-modules diff --git a/vavr-modules/README.md b/vavr-modules/README.md new file mode 100644 index 0000000000..fa2a448f3a --- /dev/null +++ b/vavr-modules/README.md @@ -0,0 +1,3 @@ +## VAVR + +This module contains modules about vavr. \ No newline at end of file diff --git a/java-vavr-stream/README.md b/vavr-modules/java-vavr-stream/README.md similarity index 100% rename from java-vavr-stream/README.md rename to vavr-modules/java-vavr-stream/README.md diff --git a/java-vavr-stream/pom.xml b/vavr-modules/java-vavr-stream/pom.xml similarity index 94% rename from java-vavr-stream/pom.xml rename to vavr-modules/java-vavr-stream/pom.xml index 8358c29003..cda9d1f734 100644 --- a/java-vavr-stream/pom.xml +++ b/vavr-modules/java-vavr-stream/pom.xml @@ -11,7 +11,7 @@ com.baeldung - parent-modules + vavr-modules 1.0.0-SNAPSHOT diff --git a/java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java b/vavr-modules/java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java similarity index 100% rename from java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java rename to vavr-modules/java-vavr-stream/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java diff --git a/java-vavr-stream/src/main/resources/logback.xml b/vavr-modules/java-vavr-stream/src/main/resources/logback.xml similarity index 100% rename from java-vavr-stream/src/main/resources/logback.xml rename to vavr-modules/java-vavr-stream/src/main/resources/logback.xml diff --git a/vavr-modules/pom.xml b/vavr-modules/pom.xml new file mode 100644 index 0000000000..d570df6d34 --- /dev/null +++ b/vavr-modules/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + vavr-modules + vavr-modules + pom + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + vavr + vavr-2 + java-vavr-stream + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + \ No newline at end of file diff --git a/vavr-2/README.md b/vavr-modules/vavr-2/README.md similarity index 100% rename from vavr-2/README.md rename to vavr-modules/vavr-2/README.md diff --git a/vavr-2/pom.xml b/vavr-modules/vavr-2/pom.xml similarity index 74% rename from vavr-2/pom.xml rename to vavr-modules/vavr-2/pom.xml index f3640d7c6e..681886ac11 100644 --- a/vavr-2/pom.xml +++ b/vavr-modules/vavr-2/pom.xml @@ -1,18 +1,17 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 vavr-2 vavr-2 jar - parent-modules com.baeldung + vavr-modules 1.0.0-SNAPSHOT - io.vavr diff --git a/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java b/vavr-modules/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java similarity index 100% rename from vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java rename to vavr-modules/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java diff --git a/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java b/vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java similarity index 100% rename from vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java rename to vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java diff --git a/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java b/vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java similarity index 100% rename from vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java rename to vavr-modules/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java diff --git a/vavr/README.md b/vavr-modules/vavr/README.md similarity index 100% rename from vavr/README.md rename to vavr-modules/vavr/README.md diff --git a/vavr/pom.xml b/vavr-modules/vavr/pom.xml similarity index 96% rename from vavr/pom.xml rename to vavr-modules/vavr/pom.xml index 1604ecc06e..5f6bf4db98 100644 --- a/vavr/pom.xml +++ b/vavr-modules/vavr/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/vavr/src/main/java/com/baeldung/Application.java b/vavr-modules/vavr/src/main/java/com/baeldung/Application.java similarity index 100% rename from vavr/src/main/java/com/baeldung/Application.java rename to vavr-modules/vavr/src/main/java/com/baeldung/Application.java diff --git a/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java b/vavr-modules/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java similarity index 100% rename from vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java rename to vavr-modules/vavr/src/main/java/com/baeldung/repositories/VavrUserRepository.java diff --git a/vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java b/vavr-modules/vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java similarity index 100% rename from vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java rename to vavr-modules/vavr/src/main/java/com/baeldung/samples/java/vavr/VavrSampler.java diff --git a/vavr/src/main/java/com/baeldung/vavr/Person.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/Person.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/Person.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/Person.java diff --git a/vavr/src/main/java/com/baeldung/vavr/PersonValidator.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/PersonValidator.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/PersonValidator.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/PersonValidator.java diff --git a/vavr/src/main/java/com/baeldung/vavr/User.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/User.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/User.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/User.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/JavaTryCatch.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/VavrTry.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/ClientException.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/HttpClient.java diff --git a/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavr/exception/handling/client/Response.java diff --git a/vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/application/Application.java diff --git a/vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/model/User.java diff --git a/vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java b/vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java rename to vavr-modules/vavr/src/main/java/com/baeldung/vavrvalidation/validator/UserValidator.java diff --git a/vavr/src/main/resources/logback.xml b/vavr-modules/vavr/src/main/resources/logback.xml similarity index 100% rename from vavr/src/main/resources/logback.xml rename to vavr-modules/vavr/src/main/resources/logback.xml diff --git a/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/PatternMatchingUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/PropertyBasedLongRunningUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/VavrUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionAPIUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java similarity index 96% rename from vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java index 60359d6803..1bae70a3d4 100644 --- a/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java +++ b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/collections/CollectionFactoryMethodsUnitTest.java @@ -1,107 +1,107 @@ -package com.baeldung.vavr.collections; - -import static io.vavr.API.Array; -import static io.vavr.API.Failure; -import static io.vavr.API.List; -import static io.vavr.API.None; -import static io.vavr.API.Some; -import static io.vavr.API.Stream; -import static io.vavr.API.Success; -import static io.vavr.API.Tuple; -import static io.vavr.API.Vector; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import io.vavr.Tuple3; -import io.vavr.collection.Array; -import io.vavr.collection.List; -import io.vavr.collection.Stream; -import io.vavr.collection.Vector; -import io.vavr.control.Option; -import io.vavr.control.Try; - -public class CollectionFactoryMethodsUnitTest { - - @Test - public void givenANoneOptionElement_whenCreated_thenCorrect() { - Option none = None(); - assertFalse(none == null); - assertEquals(none, Option.none()); - } - - @Test - public void givenASomeOptionElement_whenCreated_thenCorrect() { - Option some = Some(1); - assertFalse(some == null); - assertTrue(some.contains(1)); - } - - @Test - public void givenATupleElement_whenCreated_thenCorrect() { - Tuple3 tuple = Tuple('a', "chain", 2); - assertTrue(tuple!=null); - assertEquals(tuple._1(), new Character('a')); - assertEquals(tuple._2(), "chain"); - assertEquals(tuple._3().intValue(), 2); - } - - @Test - public void givenASuccessObject_whenEvaluated_thenSuccess() { - Try integer = Success(55); - assertEquals(integer.get().intValue(), 55); - } - @Test - public void givenAFailureObject_whenEvaluated_thenExceptionThrown() { - Try failure = Failure(new Exception("Exception X encapsulated here")); - - try { - Integer i = failure.get();// evaluate a failure raise the exception - System.out.println(i);// not executed - } catch (Exception e) { - assertEquals(e.getMessage(), "Exception X encapsulated here"); - } - } - - @Test - public void givenAList_whenCreated_thenCorrect() { - List list = List(1, 2, 3, 4, 5); - - assertEquals(list.size(), 5); - assertEquals(list.get(0).intValue(), 1); - } - - @Test - public void givenAnEmptyList_whenCreated_thenCorrect() { - List empty = List(); - - assertEquals(empty.size(), 0); - assertEquals(empty, List.empty()); - } - - @Test - public void givenAnArray_whenCreated_thenCorrect() { - Array array = Array(1, 2, 3, 4, 5); - - assertEquals(array.size(), 5); - assertEquals(array.get(0).intValue(), 1); - } - - @Test - public void givenAStream_whenCreated_thenCorrect() { - Stream stream = Stream(1, 2, 3, 4, 5); - - assertEquals(stream.size(), 5); - assertEquals(stream.get(0).intValue(), 1); - } - - @Test - public void givenAVector_whenCreated_thenCorrect() { - Vector vector = Vector(1, 2, 3, 4, 5); - - assertEquals(vector.size(), 5); - assertEquals(vector.get(0).intValue(), 1); - } -} +package com.baeldung.vavr.collections; + +import static io.vavr.API.Array; +import static io.vavr.API.Failure; +import static io.vavr.API.List; +import static io.vavr.API.None; +import static io.vavr.API.Some; +import static io.vavr.API.Stream; +import static io.vavr.API.Success; +import static io.vavr.API.Tuple; +import static io.vavr.API.Vector; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import io.vavr.Tuple3; +import io.vavr.collection.Array; +import io.vavr.collection.List; +import io.vavr.collection.Stream; +import io.vavr.collection.Vector; +import io.vavr.control.Option; +import io.vavr.control.Try; + +public class CollectionFactoryMethodsUnitTest { + + @Test + public void givenANoneOptionElement_whenCreated_thenCorrect() { + Option none = None(); + assertFalse(none == null); + assertEquals(none, Option.none()); + } + + @Test + public void givenASomeOptionElement_whenCreated_thenCorrect() { + Option some = Some(1); + assertFalse(some == null); + assertTrue(some.contains(1)); + } + + @Test + public void givenATupleElement_whenCreated_thenCorrect() { + Tuple3 tuple = Tuple('a', "chain", 2); + assertTrue(tuple!=null); + assertEquals(tuple._1(), new Character('a')); + assertEquals(tuple._2(), "chain"); + assertEquals(tuple._3().intValue(), 2); + } + + @Test + public void givenASuccessObject_whenEvaluated_thenSuccess() { + Try integer = Success(55); + assertEquals(integer.get().intValue(), 55); + } + @Test + public void givenAFailureObject_whenEvaluated_thenExceptionThrown() { + Try failure = Failure(new Exception("Exception X encapsulated here")); + + try { + Integer i = failure.get();// evaluate a failure raise the exception + System.out.println(i);// not executed + } catch (Exception e) { + assertEquals(e.getMessage(), "Exception X encapsulated here"); + } + } + + @Test + public void givenAList_whenCreated_thenCorrect() { + List list = List(1, 2, 3, 4, 5); + + assertEquals(list.size(), 5); + assertEquals(list.get(0).intValue(), 1); + } + + @Test + public void givenAnEmptyList_whenCreated_thenCorrect() { + List empty = List(); + + assertEquals(empty.size(), 0); + assertEquals(empty, List.empty()); + } + + @Test + public void givenAnArray_whenCreated_thenCorrect() { + Array array = Array(1, 2, 3, 4, 5); + + assertEquals(array.size(), 5); + assertEquals(array.get(0).intValue(), 1); + } + + @Test + public void givenAStream_whenCreated_thenCorrect() { + Stream stream = Stream(1, 2, 3, 4, 5); + + assertEquals(stream.size(), 5); + assertEquals(stream.get(0).intValue(), 1); + } + + @Test + public void givenAVector_whenCreated_thenCorrect() { + Vector vector = Vector(1, 2, 3, 4, 5); + + assertEquals(vector.size(), 5); + assertEquals(vector.get(0).intValue(), 1); + } +} diff --git a/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java similarity index 96% rename from vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java index 140593218f..5be2526c0b 100644 --- a/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java +++ b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrExceptionHandlingUnitTest.java @@ -1,87 +1,87 @@ -package com.baeldung.vavr.exception.handling; - -import io.vavr.API; -import io.vavr.CheckedFunction1; -import io.vavr.Value; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -public class VavrExceptionHandlingUnitTest { - - private static final Logger LOG = LoggerFactory.getLogger(VavrExceptionHandlingUnitTest.class); - - private List integers; - private List validIntegersOnly; - - @Before - public void init() { - integers = Arrays.asList(3, 9, 7, 0, 10, 20); - validIntegersOnly = Arrays.asList(3, 9, 7, 5, 10, 20); - } - - @Test - public void exceptionCausingMethod_UsingCheckedFunction_ThenSuccess() { - CheckedFunction1 fn = i -> readFromFile(i); - - validIntegersOnly.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); - } - - @Test(expected = IOException.class) - public void exceptionCausingMethod_UsingCheckedFunction_ThenFailure() { - CheckedFunction1 fn = i -> readFromFile(i); - - integers.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); - } - - @Test - public void exceptionCausingMethod_UsingAPI_ThenSuccess() { - validIntegersOnly.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); - } - - @Test(expected = IOException.class) - public void exceptionCausingMethod_UsingAPI_ThenFailure() { - integers.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); - } - - @Test - public void exceptionCausingMethod_UsingLift_ThenSuccess() { - validIntegersOnly.stream().map(CheckedFunction1.lift(i -> readFromFile(i))) - .map(i -> i.getOrElse(-1)) - .forEach(i -> { - Assert.assertNotSame(-1, i); - LOG.debug("{}", i); - }); - } - - @Test - public void exceptionCausingMethod_UsingLift_ThenFailure() { - integers.stream() - .map(CheckedFunction1.lift(i -> readFromFile(i))) - .map(i -> i.getOrElse(-1)) - .forEach(i -> LOG.debug("{}", i)); - - } - - @Test - public void exceptionCausingMethod_UsingTry_ThenSuccess() { - integers.stream() - .map(CheckedFunction1.liftTry(VavrExceptionHandlingUnitTest::readFromFile)) - .flatMap(Value::toJavaStream) - .forEach(i -> LOG.debug("{}", i)); - } - - private static Integer readFromFile(Integer i) throws IOException { - if (i == 0) { - throw new IOException(); // mock IOException - } - return i * i; - } - -} +package com.baeldung.vavr.exception.handling; + +import io.vavr.API; +import io.vavr.CheckedFunction1; +import io.vavr.Value; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +public class VavrExceptionHandlingUnitTest { + + private static final Logger LOG = LoggerFactory.getLogger(VavrExceptionHandlingUnitTest.class); + + private List integers; + private List validIntegersOnly; + + @Before + public void init() { + integers = Arrays.asList(3, 9, 7, 0, 10, 20); + validIntegersOnly = Arrays.asList(3, 9, 7, 5, 10, 20); + } + + @Test + public void exceptionCausingMethod_UsingCheckedFunction_ThenSuccess() { + CheckedFunction1 fn = i -> readFromFile(i); + + validIntegersOnly.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); + } + + @Test(expected = IOException.class) + public void exceptionCausingMethod_UsingCheckedFunction_ThenFailure() { + CheckedFunction1 fn = i -> readFromFile(i); + + integers.stream().map(fn.unchecked()).forEach(i -> LOG.debug("{}", i)); + } + + @Test + public void exceptionCausingMethod_UsingAPI_ThenSuccess() { + validIntegersOnly.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); + } + + @Test(expected = IOException.class) + public void exceptionCausingMethod_UsingAPI_ThenFailure() { + integers.stream().map(API.unchecked(i -> readFromFile(i))).forEach(i -> LOG.debug("{}", i)); + } + + @Test + public void exceptionCausingMethod_UsingLift_ThenSuccess() { + validIntegersOnly.stream().map(CheckedFunction1.lift(i -> readFromFile(i))) + .map(i -> i.getOrElse(-1)) + .forEach(i -> { + Assert.assertNotSame(-1, i); + LOG.debug("{}", i); + }); + } + + @Test + public void exceptionCausingMethod_UsingLift_ThenFailure() { + integers.stream() + .map(CheckedFunction1.lift(i -> readFromFile(i))) + .map(i -> i.getOrElse(-1)) + .forEach(i -> LOG.debug("{}", i)); + + } + + @Test + public void exceptionCausingMethod_UsingTry_ThenSuccess() { + integers.stream() + .map(CheckedFunction1.liftTry(VavrExceptionHandlingUnitTest::readFromFile)) + .flatMap(Value::toJavaStream) + .forEach(i -> LOG.debug("{}", i)); + } + + private static Integer readFromFile(Integer i) throws IOException { + if (i == 0) { + throw new IOException(); // mock IOException + } + return i * i; + } + +} diff --git a/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/exception/handling/VavrTryUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/future/FutureUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavr/repositories/VavrRepositoryIntegrationTest.java diff --git a/vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/UserValidatorUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java b/vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java rename to vavr-modules/vavr/src/test/java/com/baeldung/vavrvalidation/validator/ValidationUnitTest.java From f391cba986c83d0ffcfcc0d2ea26a69923ead79b Mon Sep 17 00:00:00 2001 From: panos-kakos <102670093+panos-kakos@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:48:34 +0100 Subject: [PATCH 2/4] [Java 11503] (#12626) * [JAVA-11503] Created new vertx-modules * [JAVA-11503] Moved vertx(sub-module) to vertx-modules(parent) * [JAVA-11503] Moved spring-vertx(sub-module) to vertx-modules(parent) * [JAVA-11503] Moved vertx-and-java(sub-module) to vertx-modules(parent) * [JAVA-11503] deleted modules that were moved Co-authored-by: panagiotiskakos --- pom.xml | 8 ++--- vertx-modules/README.md | 3 ++ vertx-modules/pom.xml | 33 +++++++++++++++++++ .../spring-vertx}/README.md | 0 .../spring-vertx}/pom.xml | 2 +- .../vertxspring/VertxSpringApplication.java | 0 .../vertxspring/config/PortConfiguration.java | 0 .../baeldung/vertxspring/entity/Article.java | 0 .../repository/ArticleRepository.java | 0 .../vertxspring/service/ArticleService.java | 0 .../vertxspring/util/DbBootstrap.java | 0 .../verticles/ArticleRecipientVerticle.java | 0 .../vertxspring/verticles/ServerVerticle.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/conf/conf.json | 0 .../src/main/resources/logback.xml | 0 .../java/com/baeldung/SpringContextTest.java | 0 ...VertxSpringApplicationIntegrationTest.java | 0 .../vertx-and-rxjava}/.gitignore | 0 .../vertx-and-rxjava}/README.md | 0 .../vertx-and-rxjava}/pom.xml | 2 +- .../vertx-and-rxjava}/pom.xml.orig | 0 .../baeldung/weather/CityAndDayLength.java | 0 .../baeldung/weather/MetaWeatherClient.java | 0 .../VertxWithRxJavaIntegrationTest.java | 0 .../src/test/resources/cities.txt | 0 .../src/test/resources/logback-test.xml | 0 {vertx => vertx-modules/vertx}/README.md | 0 {vertx => vertx-modules/vertx}/pom.xml | 2 +- .../main/java/com/baeldung/HelloVerticle.java | 0 .../com/baeldung/SimpleServerVerticle.java | 0 .../main/java/com/baeldung/model/Article.java | 0 .../baeldung/rest/RestServiceVerticle.java | 0 .../vertx}/src/main/resources/conf/conf.json | 0 .../vertx}/src/main/resources/logback.xml | 0 .../baeldung/RestServiceVerticleUnitTest.java | 0 .../SimpleServerVerticleUnitTest.java | 0 37 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 vertx-modules/README.md create mode 100644 vertx-modules/pom.xml rename {spring-vertx => vertx-modules/spring-vertx}/README.md (100%) rename {spring-vertx => vertx-modules/spring-vertx}/pom.xml (97%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/entity/Article.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/service/ArticleService.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/resources/application.properties (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/resources/conf/conf.json (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/main/resources/logback.xml (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-vertx => vertx-modules/spring-vertx}/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/.gitignore (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/README.md (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/pom.xml (97%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/pom.xml.orig (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/src/test/java/com/baeldung/weather/CityAndDayLength.java (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/src/test/java/com/baeldung/weather/MetaWeatherClient.java (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/src/test/resources/cities.txt (100%) rename {vertx-and-rxjava => vertx-modules/vertx-and-rxjava}/src/test/resources/logback-test.xml (100%) rename {vertx => vertx-modules/vertx}/README.md (100%) rename {vertx => vertx-modules/vertx}/pom.xml (98%) rename {vertx => vertx-modules/vertx}/src/main/java/com/baeldung/HelloVerticle.java (100%) rename {vertx => vertx-modules/vertx}/src/main/java/com/baeldung/SimpleServerVerticle.java (100%) rename {vertx => vertx-modules/vertx}/src/main/java/com/baeldung/model/Article.java (100%) rename {vertx => vertx-modules/vertx}/src/main/java/com/baeldung/rest/RestServiceVerticle.java (100%) rename {vertx => vertx-modules/vertx}/src/main/resources/conf/conf.json (100%) rename {vertx => vertx-modules/vertx}/src/main/resources/logback.xml (100%) rename {vertx => vertx-modules/vertx}/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java (100%) rename {vertx => vertx-modules/vertx}/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java (100%) diff --git a/pom.xml b/pom.xml index 4bd983e30b..8f4ac4d8de 100644 --- a/pom.xml +++ b/pom.xml @@ -610,7 +610,6 @@ spring-threads spring-vault - spring-vertx spring-web-modules spring-webflux-amqp @@ -627,8 +626,7 @@ undertow - vertx - vertx-and-rxjava + vertx-modules video-tutorials webrtc @@ -1003,7 +1001,6 @@ spring-threads spring-vault - spring-vertx spring-web-modules spring-webflux-amqp @@ -1020,8 +1017,7 @@ undertow - vertx - vertx-and-rxjava + vertx-modules video-tutorials webrtc diff --git a/vertx-modules/README.md b/vertx-modules/README.md new file mode 100644 index 0000000000..983577b923 --- /dev/null +++ b/vertx-modules/README.md @@ -0,0 +1,3 @@ +## VERTX + +This module contains modules about VERTX. \ No newline at end of file diff --git a/vertx-modules/pom.xml b/vertx-modules/pom.xml new file mode 100644 index 0000000000..8c9c36e73e --- /dev/null +++ b/vertx-modules/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + vertx-modules + vertx-modules + pom + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + + + vertx + spring-vertx + vertx-and-rxjava + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + \ No newline at end of file diff --git a/spring-vertx/README.md b/vertx-modules/spring-vertx/README.md similarity index 100% rename from spring-vertx/README.md rename to vertx-modules/spring-vertx/README.md diff --git a/spring-vertx/pom.xml b/vertx-modules/spring-vertx/pom.xml similarity index 97% rename from spring-vertx/pom.xml rename to vertx-modules/spring-vertx/pom.xml index e24bb3f1ee..447d31ee55 100644 --- a/spring-vertx/pom.xml +++ b/vertx-modules/spring-vertx/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/VertxSpringApplication.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/config/PortConfiguration.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/entity/Article.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/repository/ArticleRepository.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/service/ArticleService.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/util/DbBootstrap.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ArticleRecipientVerticle.java diff --git a/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java b/vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java similarity index 100% rename from spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java rename to vertx-modules/spring-vertx/src/main/java/com/baeldung/vertxspring/verticles/ServerVerticle.java diff --git a/spring-vertx/src/main/resources/application.properties b/vertx-modules/spring-vertx/src/main/resources/application.properties similarity index 100% rename from spring-vertx/src/main/resources/application.properties rename to vertx-modules/spring-vertx/src/main/resources/application.properties diff --git a/spring-vertx/src/main/resources/conf/conf.json b/vertx-modules/spring-vertx/src/main/resources/conf/conf.json similarity index 100% rename from spring-vertx/src/main/resources/conf/conf.json rename to vertx-modules/spring-vertx/src/main/resources/conf/conf.json diff --git a/spring-vertx/src/main/resources/logback.xml b/vertx-modules/spring-vertx/src/main/resources/logback.xml similarity index 100% rename from spring-vertx/src/main/resources/logback.xml rename to vertx-modules/spring-vertx/src/main/resources/logback.xml diff --git a/spring-vertx/src/test/java/com/baeldung/SpringContextTest.java b/vertx-modules/spring-vertx/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-vertx/src/test/java/com/baeldung/SpringContextTest.java rename to vertx-modules/spring-vertx/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java b/vertx-modules/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java similarity index 100% rename from spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java rename to vertx-modules/spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java diff --git a/vertx-and-rxjava/.gitignore b/vertx-modules/vertx-and-rxjava/.gitignore similarity index 100% rename from vertx-and-rxjava/.gitignore rename to vertx-modules/vertx-and-rxjava/.gitignore diff --git a/vertx-and-rxjava/README.md b/vertx-modules/vertx-and-rxjava/README.md similarity index 100% rename from vertx-and-rxjava/README.md rename to vertx-modules/vertx-and-rxjava/README.md diff --git a/vertx-and-rxjava/pom.xml b/vertx-modules/vertx-and-rxjava/pom.xml similarity index 97% rename from vertx-and-rxjava/pom.xml rename to vertx-modules/vertx-and-rxjava/pom.xml index 1793cff1e7..95bf95020a 100644 --- a/vertx-and-rxjava/pom.xml +++ b/vertx-modules/vertx-and-rxjava/pom.xml @@ -8,7 +8,7 @@ com.baeldung - parent-modules + vertx-modules 1.0.0-SNAPSHOT diff --git a/vertx-and-rxjava/pom.xml.orig b/vertx-modules/vertx-and-rxjava/pom.xml.orig similarity index 100% rename from vertx-and-rxjava/pom.xml.orig rename to vertx-modules/vertx-and-rxjava/pom.xml.orig diff --git a/vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java b/vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java similarity index 100% rename from vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java rename to vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/CityAndDayLength.java diff --git a/vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java b/vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java similarity index 100% rename from vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java rename to vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/MetaWeatherClient.java diff --git a/vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java b/vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java similarity index 100% rename from vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java rename to vertx-modules/vertx-and-rxjava/src/test/java/com/baeldung/weather/VertxWithRxJavaIntegrationTest.java diff --git a/vertx-and-rxjava/src/test/resources/cities.txt b/vertx-modules/vertx-and-rxjava/src/test/resources/cities.txt similarity index 100% rename from vertx-and-rxjava/src/test/resources/cities.txt rename to vertx-modules/vertx-and-rxjava/src/test/resources/cities.txt diff --git a/vertx-and-rxjava/src/test/resources/logback-test.xml b/vertx-modules/vertx-and-rxjava/src/test/resources/logback-test.xml similarity index 100% rename from vertx-and-rxjava/src/test/resources/logback-test.xml rename to vertx-modules/vertx-and-rxjava/src/test/resources/logback-test.xml diff --git a/vertx/README.md b/vertx-modules/vertx/README.md similarity index 100% rename from vertx/README.md rename to vertx-modules/vertx/README.md diff --git a/vertx/pom.xml b/vertx-modules/vertx/pom.xml similarity index 98% rename from vertx/pom.xml rename to vertx-modules/vertx/pom.xml index 7608b3e355..f8d72f8ae8 100644 --- a/vertx/pom.xml +++ b/vertx-modules/vertx/pom.xml @@ -10,7 +10,7 @@ com.baeldung - parent-modules + vertx-modules 1.0.0-SNAPSHOT diff --git a/vertx/src/main/java/com/baeldung/HelloVerticle.java b/vertx-modules/vertx/src/main/java/com/baeldung/HelloVerticle.java similarity index 100% rename from vertx/src/main/java/com/baeldung/HelloVerticle.java rename to vertx-modules/vertx/src/main/java/com/baeldung/HelloVerticle.java diff --git a/vertx/src/main/java/com/baeldung/SimpleServerVerticle.java b/vertx-modules/vertx/src/main/java/com/baeldung/SimpleServerVerticle.java similarity index 100% rename from vertx/src/main/java/com/baeldung/SimpleServerVerticle.java rename to vertx-modules/vertx/src/main/java/com/baeldung/SimpleServerVerticle.java diff --git a/vertx/src/main/java/com/baeldung/model/Article.java b/vertx-modules/vertx/src/main/java/com/baeldung/model/Article.java similarity index 100% rename from vertx/src/main/java/com/baeldung/model/Article.java rename to vertx-modules/vertx/src/main/java/com/baeldung/model/Article.java diff --git a/vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java b/vertx-modules/vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java similarity index 100% rename from vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java rename to vertx-modules/vertx/src/main/java/com/baeldung/rest/RestServiceVerticle.java diff --git a/vertx/src/main/resources/conf/conf.json b/vertx-modules/vertx/src/main/resources/conf/conf.json similarity index 100% rename from vertx/src/main/resources/conf/conf.json rename to vertx-modules/vertx/src/main/resources/conf/conf.json diff --git a/vertx/src/main/resources/logback.xml b/vertx-modules/vertx/src/main/resources/logback.xml similarity index 100% rename from vertx/src/main/resources/logback.xml rename to vertx-modules/vertx/src/main/resources/logback.xml diff --git a/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java b/vertx-modules/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java similarity index 100% rename from vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java rename to vertx-modules/vertx/src/test/java/com/baeldung/RestServiceVerticleUnitTest.java diff --git a/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java b/vertx-modules/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java similarity index 100% rename from vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java rename to vertx-modules/vertx/src/test/java/com/baeldung/SimpleServerVerticleUnitTest.java From e151d4d1d00f171b36eff644516d733c52cad5ed Mon Sep 17 00:00:00 2001 From: panos-kakos <102670093+panos-kakos@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:54:56 +0100 Subject: [PATCH 3/4] [JAVA-13220] Added comment about failing test (#12644) Co-authored-by: panagiotiskakos --- .../baeldung/boot/embeddedRedis/TestRedisConfiguration.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java index b4748bcd38..c265d99c9b 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java @@ -14,6 +14,9 @@ public class TestRedisConfiguration { public TestRedisConfiguration(final RedisProperties redisProperties) { this.redisServer = new RedisServer(redisProperties.getRedisPort()); + //Uncomment below if running on windows and can't start redis server +// this.redisServer = RedisServer.builder().setting("maxheap 200m").port(6379).setting("bind localhost").build(); +// redisServer.start(); } @PostConstruct From 7f6b12abcb5f907c8b4e49179e461f2b1fcc6028 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Thu, 25 Aug 2022 17:00:13 +0100 Subject: [PATCH 4/4] [JAVA-13976] Fix integration tests after Spring Boot upgrade to 2.7.2 (#12647) --- .../src/main/resources/application.yml | 7 ++++-- apache-olingo/src/main/resources/data.sql | 18 +++++++-------- libraries-data-db/pom.xml | 3 +-- libraries-data-db/src/main/resources/db.sql | 12 +++++----- persistence-modules/r2dbc/pom.xml | 5 ----- ...lication-lazy-load-no-trans-off.properties | 1 + ...plication-lazy-load-no-trans-on.properties | 1 + .../application-persistent-on.properties | 1 + .../src/main/resources/application.properties | 2 ++ .../src/main/resources/application.yaml | 3 +++ .../src/main/resources/data-h2.sql | 10 ++++----- .../src/main/resources/data-trans.sql | 22 +++++++++---------- .../spring-boot-persistence-mongodb/pom.xml | 5 ----- .../com/baeldung/boot/config/H2JpaConfig.java | 1 + .../src/main/resources/application.properties | 4 +++- .../SpringBootProfileIntegrationTest.java | 2 +- .../config/H2TestProfileJPAConfig.java | 1 + ...BootSqlGroupAnnotationIntegrationTest.java | 6 +++-- .../src/test/resources/application.properties | 1 + .../src/test/resources/import_employees.sql | 8 ++++--- .../resources/import_senior_employees.sql | 4 ++-- .../src/main/resources/schema.sql | 2 +- .../repositories/CompanyRepository.java | 2 +- .../src/main/resources/application.properties | 2 ++ .../src/main/resources/application.properties | 1 + .../boot/daos/user/UserRepository.java | 10 ++++----- .../com/baeldung/config/StudentJpaConfig.java | 1 + .../resources/persistence-student.properties | 4 +++- .../baeldung/config/PersistenceConfig.java | 4 ++-- .../src/main/resources/fetching.cfg.xml | 4 ++-- .../src/main/resources/fetchingLazy.cfg.xml | 1 + .../src/main/resources/insert_users.sql | 12 +++++----- .../HibernateFetchingIntegrationTest.java | 2 +- .../src/test/resources/fetching.cfg.xml | 3 ++- .../src/test/resources/fetchingLazy.cfg.xml | 1 + .../src/main/resources/import_entities.sql | 6 ++--- .../repository/CommentRepository.java | 2 +- .../src/main/resources/application.properties | 4 +++- .../src/main/resources/db/import_joins.sql | 18 +++++++-------- .../src/test/resources/entitygraph-data.sql | 12 +++++----- .../test/resources/test-aggregation-data.sql | 14 ++++++------ .../src/test/resources/test-movie-cleanup.sql | 2 +- .../src/test/resources/test-movie-data.sql | 14 ++++++------ .../src/main/resources/schema-all.sql | 2 +- .../baeldung/openapi/OpenApiApplication.java | 15 +++++++++++++ .../main/java/com/baeldung/sprq/SpqrApp.java | 3 +++ .../openapi/OpenApiPetsIntegrationTest.java | 2 +- .../spring-boot-properties/pom.xml | 2 +- .../spring-boot-runtime/pom.xml | 6 +---- 49 files changed, 150 insertions(+), 118 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-crud-2/src/main/resources/application.properties create mode 100644 spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/OpenApiApplication.java diff --git a/apache-olingo/src/main/resources/application.yml b/apache-olingo/src/main/resources/application.yml index 3e09ea8dd5..e97fec0031 100644 --- a/apache-olingo/src/main/resources/application.yml +++ b/apache-olingo/src/main/resources/application.yml @@ -1,16 +1,19 @@ server: port: 8080 - + spring: jersey: application-path: /odata - + jpa: defer-datasource-initialization: true show-sql: true open-in-view: false hibernate: ddl-auto: update + properties: + hibernate: + globally_quoted_identifiers: true sql: init: diff --git a/apache-olingo/src/main/resources/data.sql b/apache-olingo/src/main/resources/data.sql index 327f2688c5..e872cec10f 100644 --- a/apache-olingo/src/main/resources/data.sql +++ b/apache-olingo/src/main/resources/data.sql @@ -1,12 +1,10 @@ -insert into car_maker(id,name) values (1,'Special Motors'); -insert into car_maker(id,name) values (2,'BWM'); -insert into car_maker(id,name) values (3,'Dolores'); +insert into "car_maker"("id", "name") values (1,'Special Motors'); +insert into "car_maker"("id", "name") values (2,'BWM'); +insert into "car_maker"("id", "name") values (3,'Dolores'); -insert into car_model(id,maker_fk,name,sku,year) values(1,1,'Muze','SM001',2018); -insert into car_model(id,maker_fk,name,sku,year) values(2,1,'Empada','SM002',2008); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(1,1,'Muze','SM001',2018); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(2,1,'Empada','SM002',2008); -insert into car_model(id,maker_fk,name,sku,year) values(4,2,'BWM-100','BWM100',2008); -insert into car_model(id,maker_fk,name,sku,year) values(5,2,'BWM-200','BWM200',2009); -insert into car_model(id,maker_fk,name,sku,year) values(6,2,'BWM-300','BWM300',2008); - -alter sequence hibernate_sequence restart with 100; \ No newline at end of file +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(4,2,'BWM-100','BWM100',2008); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(5,2,'BWM-200','BWM200',2009); +insert into "car_model"("id", "maker_fk", "name", "sku", "year") values(6,2,'BWM-300','BWM300',2008); diff --git a/libraries-data-db/pom.xml b/libraries-data-db/pom.xml index c0f2848705..8e5140458e 100644 --- a/libraries-data-db/pom.xml +++ b/libraries-data-db/pom.xml @@ -159,7 +159,6 @@ classname="com.gs.fw.common.mithra.generator.MithraGenerator" /> @@ -268,7 +267,7 @@ 11.11.2 - 16.5.1 + 18.1.0 3.0.0 1.8 5.0 diff --git a/libraries-data-db/src/main/resources/db.sql b/libraries-data-db/src/main/resources/db.sql index e6a9ed3fc2..7bcf6f816e 100644 --- a/libraries-data-db/src/main/resources/db.sql +++ b/libraries-data-db/src/main/resources/db.sql @@ -8,7 +8,7 @@ create table dept( loc varchar(13), constraint pk_dept primary key (deptno) ); - + create table emp( empno numeric, ename varchar(10), @@ -26,25 +26,25 @@ insert into dept values(10, 'ACCOUNTING', 'NEW YORK'); insert into dept values(20, 'RESEARCH', 'DALLAS'); insert into dept values(30, 'SALES', 'CHICAGO'); insert into dept values(40, 'OPERATIONS', 'BOSTON'); - + insert into emp values( 7839, 'KING', 'PRESIDENT', null, - to_date('17-11-1981','dd-mm-yyyy'), + parsedatetime('17-11-1981','dd-MM-yyyy'), 7698, null, 10 ); insert into emp values( 7698, 'BLAKE', 'MANAGER', 7839, - to_date('1-5-1981','dd-mm-yyyy'), + parsedatetime('01-05-1981','dd-MM-yyyy'), 7782, null, 20 ); insert into emp values( 7782, 'CLARK', 'MANAGER', 7839, - to_date('9-6-1981','dd-mm-yyyy'), + parsedatetime('09-06-1981','dd-MM-yyyy'), 7566, null, 30 ); insert into emp values( 7566, 'JONES', 'MANAGER', 7839, - to_date('2-4-1981','dd-mm-yyyy'), + parsedatetime('02-04-1981','dd-MM-yyyy'), 7839, null, 40 ); diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index 1ce5eb3e96..f32b37974b 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -39,7 +39,6 @@ io.r2dbc r2dbc-h2 - ${r2dbc-h2.version} org.springframework.boot @@ -61,8 +60,4 @@ - - 0.8.1.RELEASE - - \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties index a1243dc1df..b030527cca 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties @@ -11,4 +11,5 @@ logging.level.org.hibernate.SQL=INFO logging.level.org.hibernate.type=INFO spring.jpa.properties.hibernate.validator.apply_to_ddl=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=true spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties index 2ea89b2ee6..972a7bb0f3 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties @@ -11,4 +11,5 @@ logging.level.org.hibernate.SQL=INFO logging.level.org.hibernate.type=INFO spring.jpa.properties.hibernate.validator.apply_to_ddl=false spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true +spring.jpa.properties.hibernate.globally_quoted_identifiers=true spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties index be939ffa69..e745c7455e 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-persistent-on.properties @@ -8,3 +8,4 @@ spring.h2.console.enabled=true spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.h2.console.path=/h2-console +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties index 2499d7cd06..4dd2caf075 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.properties @@ -7,6 +7,8 @@ spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.show-sql=false spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.validator.apply_to_ddl=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=true + #spring.jpa.properties.hibernate.check_nullability=true spring.h2.console.enabled=true spring.h2.console.path=/h2-console diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml index aeb33f797a..1b8cfbb558 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application.yaml @@ -12,3 +12,6 @@ spring: driverClassName: org.h2.Driver jpa: spring.jpa.database-platform: org.hibernate.dialect.H2Dialect + properties: + hibernate: + globally_quoted_identifiers: true diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql index 3d04b578d2..2566a8d125 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-h2.sql @@ -1,5 +1,5 @@ -INSERT INTO countries (id, name) VALUES (1, 'USA'); -INSERT INTO countries (id, name) VALUES (2, 'France'); -INSERT INTO countries (id, name) VALUES (3, 'Brazil'); -INSERT INTO countries (id, name) VALUES (4, 'Italy'); -INSERT INTO countries (id, name) VALUES (5, 'Canada'); \ No newline at end of file +INSERT INTO "countries" VALUES (1, 'USA'); +INSERT INTO "countries" VALUES (2, 'France'); +INSERT INTO "countries" VALUES (3, 'Brazil'); +INSERT INTO "countries" VALUES (4, 'Italy'); +INSERT INTO "countries" VALUES (5, 'Canada'); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql index e4fda99437..2b4aa92542 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data-trans.sql @@ -1,12 +1,12 @@ -insert into USER values (101, 'user1', 'comment1'); -insert into USER values (102, 'user2', 'comment2'); -insert into USER values (103, 'user3', 'comment3'); -insert into USER values (104, 'user4', 'comment4'); -insert into USER values (105, 'user5', 'comment5'); +insert into "user" values (101, 'user1', 'comment1'); +insert into "user" values (102, 'user2', 'comment2'); +insert into "user" values (103, 'user3', 'comment3'); +insert into "user" values (104, 'user4', 'comment4'); +insert into "user" values (105, 'user5', 'comment5'); -insert into DOCUMENT values (1, 'doc1', 101); -insert into DOCUMENT values (2, 'doc2', 101); -insert into DOCUMENT values (3, 'doc3', 101); -insert into DOCUMENT values (4, 'doc4', 101); -insert into DOCUMENT values (5, 'doc5', 102); -insert into DOCUMENT values (6, 'doc6', 102); \ No newline at end of file +insert into "document" values (1, 'doc1', 101); +insert into "document" values (2, 'doc2', 101); +insert into "document" values (3, 'doc3', 101); +insert into "document" values (4, 'doc4', 101); +insert into "document" values (5, 'doc5', 102); +insert into "document" values (6, 'doc6', 102); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-mongodb/pom.xml b/persistence-modules/spring-boot-persistence-mongodb/pom.xml index 8b36474777..724fa38f7e 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/pom.xml +++ b/persistence-modules/spring-boot-persistence-mongodb/pom.xml @@ -32,13 +32,8 @@ de.flapdoodle.embed de.flapdoodle.embed.mongo - ${embed.mongo.version} test - - 3.2.6 - - \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java index 6325d2cd2e..d3a09c08ff 100644 --- a/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java +++ b/persistence-modules/spring-boot-persistence/src/main/java/com/baeldung/boot/config/H2JpaConfig.java @@ -66,6 +66,7 @@ public class H2JpaConfig { hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql")); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", env.getProperty("hibernate.globally_quoted_identifiers")); return hibernateProperties; } diff --git a/persistence-modules/spring-boot-persistence/src/main/resources/application.properties b/persistence-modules/spring-boot-persistence/src/main/resources/application.properties index 7b5a467a2b..52bfc00712 100644 --- a/persistence-modules/spring-boot-persistence/src/main/resources/application.properties +++ b/persistence-modules/spring-boot-persistence/src/main/resources/application.properties @@ -8,4 +8,6 @@ spring.jpa.hibernate.ddl-auto = create spring.h2.console.enabled=true # Uppercase Table Names -spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl \ No newline at end of file +spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + +hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java index d7bb44e133..226a5a550a 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/SpringBootProfileIntegrationTest.java @@ -22,7 +22,7 @@ public class SpringBootProfileIntegrationTest { private GenericEntityRepository genericEntityRepository; @Test - public void givenGenericEntityRepository_whenSaveAndRetreiveEntity_thenOK() { + public void givenGenericEntityRepository_whenSaveAndRetrieveEntity_thenOK() { GenericEntity genericEntity = genericEntityRepository.save(new GenericEntity("test")); GenericEntity foundEntity = genericEntityRepository.findById(genericEntity.getId()).orElse(null); assertNotNull(foundEntity); diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java index f73000a10e..515350fe0a 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/config/H2TestProfileJPAConfig.java @@ -62,6 +62,7 @@ public class H2TestProfileJPAConfig { hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql")); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", env.getProperty("hibernate.globally_quoted_identifiers")); return hibernateProperties; } diff --git a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java index 0153d463a2..e584645742 100644 --- a/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java +++ b/persistence-modules/spring-boot-persistence/src/test/java/com/baeldung/springbootinitialload/tests/SpringBootSqlGroupAnnotationIntegrationTest.java @@ -17,8 +17,10 @@ import com.baeldung.boot.repository.EmployeeRepository; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -@SqlGroup({ @Sql(scripts = "/employees_schema.sql", config = @SqlConfig(transactionMode = TransactionMode.ISOLATED)), - @Sql("/import_employees.sql")}) +@SqlGroup({ + @Sql(scripts = "/employees_schema.sql", config = @SqlConfig(transactionMode = TransactionMode.ISOLATED)), + @Sql("/import_employees.sql")} +) public class SpringBootSqlGroupAnnotationIntegrationTest { @Autowired diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties index b268f46094..9f6f3f60d2 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/application.properties +++ b/persistence-modules/spring-boot-persistence/src/test/resources/application.properties @@ -19,6 +19,7 @@ hibernate.hbm2ddl.auto=create-drop hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=true hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory +hibernate.globally_quoted_identifiers=true spring.jpa.properties.hibernate.hbm2ddl.import_files=import_books.sql spring.sql.init.data-locations=import_*_users.sql \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql b/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql index 40442d2804..f234d02fd9 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql +++ b/persistence-modules/spring-boot-persistence/src/test/resources/import_employees.sql @@ -1,3 +1,5 @@ -insert into EMPLOYEES values(1, 'Harsha', 'Developer'); -insert into EMPLOYEES values(2, 'John', 'Tester'); -insert into EMPLOYEES values(3, 'Ram', 'Manager'); \ No newline at end of file +delete from "employees"; + +insert into "employees" values(1, 'Harsha', 'Developer'); +insert into "employees" values(2, 'John', 'Tester'); +insert into "employees" values(3, 'Ram', 'Manager'); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql b/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql index 3d0819175b..e4af4651a7 100644 --- a/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql +++ b/persistence-modules/spring-boot-persistence/src/test/resources/import_senior_employees.sql @@ -1,2 +1,2 @@ -insert into EMPLOYEES values(4, 'Eric', 'Senior Developer'); -insert into EMPLOYEES values(5, 'Vidhyaah', 'Senior Manager'); \ No newline at end of file +insert into "employees" values(4, 'Eric', 'Senior Developer'); +insert into "employees" values(5, 'Vidhyaah', 'Senior Manager'); \ No newline at end of file diff --git a/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql b/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql index 5618822bf9..2c431d2340 100644 --- a/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql +++ b/persistence-modules/spring-data-jdbc/src/main/resources/schema.sql @@ -1,5 +1,5 @@ create table person ( - id integer identity primary key, + id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY, first_name varchar(30), last_name varchar(30) ); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java b/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java index f456b15652..cfef3a6a5e 100644 --- a/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java +++ b/persistence-modules/spring-data-jpa-annotations/src/main/java/com/baeldung/embeddable/repositories/CompanyRepository.java @@ -13,6 +13,6 @@ public interface CompanyRepository extends JpaRepository { @Query("SELECT C FROM Company C WHERE C.contactPerson.firstName = ?1") List findByContactPersonFirstNameWithJPQL(String firstName); - @Query(value = "SELECT * FROM company WHERE contact_first_name = ?1", nativeQuery = true) + @Query(value = "SELECT * FROM \"company\" WHERE \"contact_first_name\" = ?1", nativeQuery = true) List findByContactPersonFirstNameWithNativeQuery(String firstName); } diff --git a/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties index f127dd5e50..6f871a25b7 100644 --- a/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-annotations/src/main/resources/application.properties @@ -4,3 +4,5 @@ spring.jpa.properties.hibernate.jdbc.batch_size=4 spring.jpa.properties.hibernate.order_inserts=true spring.jpa.properties.hibernate.order_updates=true spring.jpa.properties.hibernate.generate_statistics=true + +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-crud-2/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-crud-2/src/main/resources/application.properties new file mode 100644 index 0000000000..ead0df89a3 --- /dev/null +++ b/persistence-modules/spring-data-jpa-crud-2/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java index cfa99414c6..a2c816b1c4 100644 --- a/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java +++ b/persistence-modules/spring-data-jpa-enterprise/src/main/java/com/baeldung/boot/daos/user/UserRepository.java @@ -21,7 +21,7 @@ public interface UserRepository extends JpaRepository , UserRepos @Query("SELECT u FROM User u WHERE u.status = 1") Collection findAllActiveUsers(); - + @Query("select u from User u where u.email like '%@gmail.com'") List findUsersWithGmailAddress(); @@ -75,14 +75,14 @@ public interface UserRepository extends JpaRepository , UserRepos @Query(value = "INSERT INTO Users (name, age, email, status, active) VALUES (:name, :age, :email, :status, :active)", nativeQuery = true) @Modifying void insertUser(@Param("name") String name, @Param("age") Integer age, @Param("email") String email, @Param("status") Integer status, @Param("active") boolean active); - + @Modifying @Query(value = "UPDATE Users u SET status = ? WHERE u.name = ?", nativeQuery = true) int updateUserSetStatusForNameNativePostgres(Integer status, String name); - + @Query(value = "SELECT u FROM User u WHERE u.name IN :names") List findUserByNameList(@Param("names") Collection names); - + void deleteAllByCreationDateAfter(LocalDate date); @Modifying(clearAutomatically = true, flushAutomatically = true) @@ -97,6 +97,6 @@ public interface UserRepository extends JpaRepository , UserRepos int deleteDeactivatedUsersWithNoModifyingAnnotation(); @Modifying(clearAutomatically = true, flushAutomatically = true) - @Query(value = "alter table USERS add column deleted int(1) not null default 0", nativeQuery = true) + @Query(value = "alter table USERS add column deleted int not null default 0", nativeQuery = true) void addDeletedColumn(); } diff --git a/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java b/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java index 08f37ea806..bcb3b2fc8c 100644 --- a/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java +++ b/persistence-modules/spring-data-jpa-filtering/src/main/java/com/baeldung/config/StudentJpaConfig.java @@ -62,6 +62,7 @@ public class StudentJpaConfig { hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql")); hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", env.getProperty("hibernate.cache.use_second_level_cache")); hibernateProperties.setProperty("hibernate.cache.use_query_cache", env.getProperty("hibernate.cache.use_query_cache")); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", env.getProperty("hibernate.globally_quoted_identifiers")); return hibernateProperties; } diff --git a/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties b/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties index 3b6b580630..a2a83f5dee 100644 --- a/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties +++ b/persistence-modules/spring-data-jpa-filtering/src/test/resources/persistence-student.properties @@ -6,4 +6,6 @@ hibernate.show_sql=true hibernate.hbm2ddl.auto=create hibernate.cache.use_second_level_cache=false -hibernate.cache.use_query_cache=false \ No newline at end of file +hibernate.cache.use_query_cache=false + +hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java index a0d70ed006..64fe4d7724 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/config/PersistenceConfig.java @@ -64,7 +64,7 @@ public class PersistenceConfig { public AuditorAware auditorProvider() { return new AuditorAwareImpl(); } - + @Bean public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); @@ -175,7 +175,7 @@ public class PersistenceConfig { hibernateProperties.setProperty("hibernate.show_sql", "true"); // hibernateProperties.setProperty("hibernate.format_sql", "true"); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); // Envers properties hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix")); diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml index 1b9a4a191c..dcc3e76cf5 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetching.cfg.xml @@ -12,8 +12,8 @@ org.hibernate.dialect.MySQLDialect true validate - - + true + diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml index c5f608e1a7..8fe08b10c3 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/fetchingLazy.cfg.xml @@ -11,6 +11,7 @@ iamtheking org.hibernate.dialect.MySQLDialect true + true diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql index 330b2e36b0..e0aca9ac41 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql @@ -1,8 +1,8 @@ -insert into Users(id, name, creation_date, last_login_date, active, age, email, status) -values(1, 'John', TO_DATE('01/01/2018', 'DD/MM/YYYY'), TO_DATE('01/01/2020', 'DD/MM/YYYY'), 1, 23, 'john@email.com', 1); +insert into Users(name, creation_date, last_login_date, active, age, email, status) +values('John', PARSEDATETIME('01/01/2018', 'dd/MM/yyyy'), PARSEDATETIME('01/01/2020', 'dd/MM/yyyy'), 1, 23, 'john@email.com', 1); -insert into Users(id, name, creation_date, last_login_date, active, age, email, status) -values(2, 'Bob', TO_DATE('02/02/2019', 'DD/MM/YYYY'), TO_DATE('02/02/2020', 'DD/MM/YYYY'), 1, 56, 'bob@email.com', 1); +insert into Users(name, creation_date, last_login_date, active, age, email, status) +values('Bob', PARSEDATETIME('02/02/2019', 'dd/MM/yyyy'), PARSEDATETIME('02/02/2020', 'dd/MM/yyyy'), 1, 56, 'bob@email.com', 1); -insert into Users(id, name, creation_date, last_login_date, active, age, email, status) -values(3, 'Cindy', TO_DATE('02/02/2019', 'DD/MM/YYYY'), TO_DATE('02/02/2020', 'DD/MM/YYYY'), 1, 18, 'cindy@email.com', 0); \ No newline at end of file +insert into Users(name, creation_date, last_login_date, active, age, email, status) +values('Cindy', PARSEDATETIME('02/02/2019', 'dd/MM/yyyy'), PARSEDATETIME('02/02/2020', 'dd/MM/yyyy'), 1, 18, 'cindy@email.com', 0); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java index 65bf36f8bf..e90207a170 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/hibernate/fetching/HibernateFetchingIntegrationTest.java @@ -15,7 +15,7 @@ public class HibernateFetchingIntegrationTest { // this loads sample data in the database @Before - public void addFecthingTestData() { + public void addFetchingTestData() { FetchingAppView fav = new FetchingAppView(); fav.createTestData(); } diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml index 4d3ff2ae63..c14a3ecd7a 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetching.cfg.xml @@ -12,7 +12,8 @@ org.hibernate.dialect.H2Dialect update false - + true + diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml index 8a2bf593cb..ad6ee0ed46 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml +++ b/persistence-modules/spring-data-jpa-query-2/src/test/resources/fetchingLazy.cfg.xml @@ -12,6 +12,7 @@ org.hibernate.dialect.H2Dialect update false + true diff --git a/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql b/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql index 4fe18bf4aa..ce71bc744c 100644 --- a/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql +++ b/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql @@ -1,3 +1,3 @@ -insert into Article(id, publication_date, publication_time, creation_date_time) values(1, TO_DATE('01/01/2018', 'DD/MM/YYYY'), TO_DATE('15:00', 'HH24:MI'), TO_DATE('31/12/2017 07:30', 'DD/MM/YYYY HH24:MI')); -insert into Article(id, publication_date, publication_time, creation_date_time) values(2, TO_DATE('01/01/2018', 'DD/MM/YYYY'), TO_DATE('15:30', 'HH24:MI'), TO_DATE('15/12/2017 08:00', 'DD/MM/YYYY HH24:MI')); -insert into Article(id, publication_date, publication_time, creation_date_time) values(3, TO_DATE('15/12/2017', 'DD/MM/YYYY'), TO_DATE('16:00', 'HH24:MI'), TO_DATE('01/12/2017 13:45', 'DD/MM/YYYY HH24:MI')); \ No newline at end of file +insert into Article(id, publication_date, publication_time, creation_date_time) values(1, PARSEDATETIME('01/01/2018', 'dd/MM/yyyy'), PARSEDATETIME('15:00', 'HH:mm'), PARSEDATETIME('31/12/2017 07:30', 'dd/MM/yyyy HH:mm')); +insert into Article(id, publication_date, publication_time, creation_date_time) values(2, PARSEDATETIME('01/01/2018', 'dd/MM/yyyy'), PARSEDATETIME('15:30', 'HH:mm'), PARSEDATETIME('15/12/2017 08:00', 'dd/MM/yyyy HH:mm')); +insert into Article(id, publication_date, publication_time, creation_date_time) values(3, PARSEDATETIME('15/12/2017', 'dd/MM/yyyy'), PARSEDATETIME('16:00', 'HH:mm'), PARSEDATETIME('01/12/2017 13:45', 'dd/MM/yyyy HH:mm')); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java b/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java index 89e9345e94..5309581638 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java +++ b/persistence-modules/spring-data-jpa-query/src/main/java/com/baeldung/aggregation/repository/CommentRepository.java @@ -21,7 +21,7 @@ public interface CommentRepository extends JpaRepository { @Query("SELECT c.year AS yearComment, COUNT(c.year) AS totalComment FROM Comment AS c GROUP BY c.year ORDER BY c.year DESC") List countTotalCommentsByYearInterface(); - @Query(value = "SELECT c.year AS yearComment, COUNT(c.*) AS totalComment FROM comment AS c GROUP BY c.year ORDER BY c.year DESC", nativeQuery = true) + @Query(value = "SELECT c.\"year\" AS yearComment, COUNT(c.*) AS totalComment FROM \"comment\" AS c GROUP BY c.\"year\" ORDER BY c.\"year\" DESC", nativeQuery = true) List countTotalCommentsByYearNative(); } diff --git a/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties index eb0e519ef0..7850367c64 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-query/src/main/resources/application.properties @@ -1,2 +1,4 @@ spring.jpa.show-sql=false -spring.jpa.defer-datasource-initialization=true \ No newline at end of file +spring.jpa.defer-datasource-initialization=true + +spring.jpa.properties.hibernate.globally_quoted_identifiers=true diff --git a/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql b/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql index e4772d6ff2..7598064278 100644 --- a/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql +++ b/persistence-modules/spring-data-jpa-query/src/main/resources/db/import_joins.sql @@ -1,13 +1,13 @@ -INSERT INTO department (id, name) VALUES (1, 'Infra'); -INSERT INTO department (id, name) VALUES (2, 'Accounting'); -INSERT INTO department (id, name) VALUES (3, 'Management'); +INSERT INTO "department" ("id", "name") VALUES (1, 'Infra'); +INSERT INTO "department" ("id", "name") VALUES (2, 'Accounting'); +INSERT INTO "department" ("id", "name") VALUES (3, 'Management'); -INSERT INTO joins_employee (id, name, age, department_id) VALUES (1, 'Baeldung', '35', 1); -INSERT INTO joins_employee (id, name, age, department_id) VALUES (2, 'John', '35', 2); -INSERT INTO joins_employee (id, name, age, department_id) VALUES (3, 'Jane', '35', 2); +INSERT INTO "joins_employee" ("id", "name", "age", "department_id") VALUES (1, 'Baeldung', '35', 1); +INSERT INTO "joins_employee" ("id", "name", "age", "department_id") VALUES (2, 'John', '35', 2); +INSERT INTO "joins_employee" ("id", "name", "age", "department_id") VALUES (3, 'Jane', '35', 2); -INSERT INTO phone (id, number, employee_id) VALUES (1, '111', 1); -INSERT INTO phone (id, number, employee_id) VALUES (2, '222', 1); -INSERT INTO phone (id, number, employee_id) VALUES (3, '333', 1); +INSERT INTO "phone" ("id", "number", "employee_id") VALUES (1, '111', 1); +INSERT INTO "phone" ("id", "number", "employee_id") VALUES (2, '222', 1); +INSERT INTO "phone" ("id", "number", "employee_id") VALUES (3, '333', 1); COMMIT; diff --git a/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql b/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql index 685ec2c605..73994d88cc 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql +++ b/persistence-modules/spring-data-jpa-query/src/test/resources/entitygraph-data.sql @@ -1,7 +1,7 @@ -INSERT INTO Item(id,name) VALUES (1,'Table'); -INSERT INTO Item(id,name) VALUES (2,'Bottle'); +INSERT INTO "item" ("id", "name") VALUES (1,'Table'); +INSERT INTO "item" ("id", "name") VALUES (2,'Bottle'); -INSERT INTO Characteristic(id,item_id, type) VALUES (1,1,'Rigid'); -INSERT INTO Characteristic(id,item_id,type) VALUES (2,1,'Big'); -INSERT INTO Characteristic(id,item_id,type) VALUES (3,2,'Fragile'); -INSERT INTO Characteristic(id,item_id,type) VALUES (4,2,'Small'); \ No newline at end of file +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (1,1,'Rigid'); +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (2,1,'Big'); +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (3,2,'Fragile'); +INSERT INTO "characteristic" ("id", "item_id", "type") VALUES (4,2,'Small'); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql b/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql index 12409a124e..ece64240ae 100644 --- a/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql +++ b/persistence-modules/spring-data-jpa-query/src/test/resources/test-aggregation-data.sql @@ -1,7 +1,7 @@ -INSERT INTO post (id, title, content) VALUES (1, 'Comment 1', 'Content 1'); -INSERT INTO post (id, title, content) VALUES (2, 'Comment 2', 'Content 2'); -INSERT INTO post (id, title, content) VALUES (3, 'Comment 3', 'Content 3'); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (1, 2019, false, 'Comment 1', 1); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (2, 2018, true, 'Comment 2', 1); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (3, 2018, true, 'Comment 3', 2); -INSERT INTO comment (id, year, approved, content, post_id) VALUES (4, 2017, false, 'Comment 4', 3); \ No newline at end of file +INSERT INTO "post" ("id", "title", "content") VALUES (1, 'Comment 1', 'Content 1'); +INSERT INTO "post" ("id", "title", "content") VALUES (2, 'Comment 2', 'Content 2'); +INSERT INTO "post" ("id", "title", "content") VALUES (3, 'Comment 3', 'Content 3'); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (1, 2019, false, 'Comment 1', 1); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (2, 2018, true, 'Comment 2', 1); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (3, 2018, true, 'Comment 3', 2); +INSERT INTO "comment" ("id", "year", "approved", "content", "post_id") VALUES (4, 2017, false, 'Comment 4', 3); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql index 90aa15307c..0ba0ba0694 100644 --- a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql +++ b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-cleanup.sql @@ -1 +1 @@ -DELETE FROM Movie; \ No newline at end of file +DELETE FROM "movie"; \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql index 37f8e4fe64..0eb9638f43 100644 --- a/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql +++ b/persistence-modules/spring-data-jpa-repo-2/src/test/resources/test-movie-data.sql @@ -1,7 +1,7 @@ -INSERT INTO movie(id, title, director, rating, duration) VALUES(1, 'Godzilla: King of the Monsters', ' Michael Dougherty', 'PG-13', 132); -INSERT INTO movie(id, title, director, rating, duration) VALUES(2, 'Avengers: Endgame', 'Anthony Russo', 'PG-13', 181); -INSERT INTO movie(id, title, director, rating, duration) VALUES(3, 'Captain Marvel', 'Anna Boden', 'PG-13', 123); -INSERT INTO movie(id, title, director, rating, duration) VALUES(4, 'Dumbo', 'Tim Burton', 'PG', 112); -INSERT INTO movie(id, title, director, rating, duration) VALUES(5, 'Booksmart', 'Olivia Wilde', 'R', 102); -INSERT INTO movie(id, title, director, rating, duration) VALUES(6, 'Aladdin', 'Guy Ritchie', 'PG', 128); -INSERT INTO movie(id, title, director, rating, duration) VALUES(7, 'The Sun Is Also a Star', 'Ry Russo-Young', 'PG-13', 100); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(1, 'Godzilla: King of the Monsters', ' Michael Dougherty', 'PG-13', 132); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(2, 'Avengers: Endgame', 'Anthony Russo', 'PG-13', 181); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(3, 'Captain Marvel', 'Anna Boden', 'PG-13', 123); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(4, 'Dumbo', 'Tim Burton', 'PG', 112); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(5, 'Booksmart', 'Olivia Wilde', 'R', 102); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(6, 'Aladdin', 'Guy Ritchie', 'PG', 128); +INSERT INTO "movie" ("id", "title", "director", "rating", "duration") VALUES(7, 'The Sun Is Also a Star', 'Ry Russo-Young', 'PG-13', 100); diff --git a/spring-batch-2/src/main/resources/schema-all.sql b/spring-batch-2/src/main/resources/schema-all.sql index 9f698f7d81..c17b9f9749 100644 --- a/spring-batch-2/src/main/resources/schema-all.sql +++ b/spring-batch-2/src/main/resources/schema-all.sql @@ -1,7 +1,7 @@ DROP TABLE coffee IF EXISTS; CREATE TABLE coffee ( - coffee_id BIGINT IDENTITY NOT NULL PRIMARY KEY, + coffee_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, brand VARCHAR(20), origin VARCHAR(20), characteristics VARCHAR(30) diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/OpenApiApplication.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/OpenApiApplication.java new file mode 100644 index 0000000000..3fd8dbd6c5 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/openapi/OpenApiApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.openapi; + +import org.jobrunr.autoconfigure.JobRunrAutoConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@EnableAutoConfiguration(exclude = { JobRunrAutoConfiguration.class}) +public class OpenApiApplication { + + public static void main(String[] args) { + SpringApplication.run(OpenApiApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/sprq/SpqrApp.java b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/sprq/SpqrApp.java index 4a205dcc1f..ec471aa8eb 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/sprq/SpqrApp.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/main/java/com/baeldung/sprq/SpqrApp.java @@ -1,9 +1,12 @@ package com.baeldung.sprq; +import org.jobrunr.autoconfigure.JobRunrAutoConfiguration; import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication +@EnableAutoConfiguration(exclude = { JobRunrAutoConfiguration.class}) public class SpqrApp { public static void main(String[] args) { diff --git a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java index b56c19d94c..e56ff445d7 100644 --- a/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java +++ b/spring-boot-modules/spring-boot-libraries-2/src/test/java/com/baeldung/openapi/OpenApiPetsIntegrationTest.java @@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = OpenApiApplication.class) @AutoConfigureMockMvc public class OpenApiPetsIntegrationTest { diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 41baf3bb82..378864a1df 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -122,7 +122,7 @@ - 2021.0.0 + 2021.0.3 1.10 @ diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index 04c8ddc525..7b2ed6976b 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -71,7 +71,6 @@ javax.persistence javax.persistence-api - ${jpa.version} com.google.guava @@ -87,15 +86,12 @@ org.apache.httpcomponents httpclient - ${httpclient.version} - 2.2 3.1.7 - 3.1.0 - 4.5.8 + 3.1.3 \ No newline at end of file