From f7a767a82683bc4ea76dbc2065b5c0da9be27c59 Mon Sep 17 00:00:00 2001 From: Davide De Date: Fri, 11 Aug 2023 17:03:19 +0200 Subject: [PATCH 1/3] Jakarta EE 9+ and JDK 17+ Baseline - Due compatibility issues with the new Spring Framework version 6.x we want to change along. This includes upgrades of JDK, dependencies and the transition from "import javax.*" to "import jakarta.*" Reference: https://spring.io/blog/2021/09/02/a-java-17-and-jakarta-ee-9-baseline-for-spring-framework-6 https://github.com/spring-projects/spring-framework/wiki/What%27s-New-in-Spring-Framework-6.x - Jakarta dependencies Moved dependencies from javax-* to jakarta-* packages. Transitive dependencies using still javax has been upgraded as well. This includes the following libraries: - jakarta.validation-api - jakarta.persistence - jakarta.servlets - hibernate-validator - spring (uses jakarta from up version 3.x) - JDK17 Upgrading the current version of the JDK in order to move along the spring baseline. This upgrades the JDK from version 8 to version 17. Dependencies for having a clean build have also been upgraded: - jacoco - maven-war-plugin - lombok - TestModelClassWithLotsOfIrrelevantAnnotations Removing annotation @SafeHtml due to hibernate-validator API changes - Annotation not present in class path anymore. --- .idea/compiler.xml | 6 +-- pom.xml | 53 +++++++++++++------ .../github/valdr/demo/model/IgnoredClass.java | 2 +- .../com/github/valdr/demo/model/Person.java | 6 +-- valdr-bean-validation/pom.xml | 18 ++++--- .../com/github/valdr/BuiltInConstraint.java | 18 +++---- .../com/github/valdr/ConstraintParser.java | 2 +- .../github/valdr/ValidationRulesServlet.java | 12 ++--- .../valdr/decorator/PatternDecorator.java | 2 +- .../github/valdr/ConstraintParserTest.java | 8 +-- .../valdr/ValidationRulesServletTest.java | 4 +- .../valdr/decorator/PatternDecoratorTest.java | 2 +- .../TestModelWithASingleAnnotatedMember.java | 2 +- ...leAnnotatedMemberWithCustomMessageKey.java | 2 +- .../d/SuperClassWithValidatedMember.java | 2 +- ...lClassWithLotsOfIrrelevantAnnotations.java | 2 - .../model/f/TestModelWithEmailAnnotation.java | 2 +- .../valdr/model/h/TestModelWithPatterns.java | 2 +- ...tModelWithoutAnyConstraintAnnotations.java | 16 +++--- .../model/validation/CustomValidation.java | 2 +- 20 files changed, 92 insertions(+), 71 deletions(-) diff --git a/.idea/compiler.xml b/.idea/compiler.xml index e12baa7..b0ee7a4 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -29,9 +29,9 @@ - - - + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index ee4020b..9f7d906 100644 --- a/pom.xml +++ b/pom.xml @@ -79,35 +79,38 @@ UTF-8 UTF-8 - 1.8 - 1.8 + 17 - 3.7.0 + 3.11.0 + 3.3.1 1.6 3.0.0 3.1.0 2.5.3 3.0.1 1.6.7 + 0.8.10 - 2.0.1.Final + 3.0.2 3.7 1.4 2.7 29.0-jre 1.3 1.0.2 - 6.1.5.Final + 8.0.1.Final 2.10.0 4.13.1 - 1.16.20 + 1.18.28 2.18.3 0.9.9 - 4.0.0 + 6.0.0 1.7.9 - 5.0.5.RELEASE + 6.0.11 + 3.1.0 + 4.0.0 @@ -128,8 +131,8 @@ ${reflections.version} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${bean-validation.version} @@ -171,8 +174,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api ${servlet-api.version} provided @@ -209,9 +212,15 @@ test - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - ${hibernate.version} + jakarta.persistence + jakarta.persistence-api + ${jakarta.persistence-api.version} + test + + + jakarta.xml.bind + jakarta.xml.bind-api + ${jakarta.xml.bind-api.version} test @@ -255,15 +264,25 @@ nexus-staging-maven-plugin ${nexus-staging-maven-plugin.version} + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + maven-compiler-plugin - ${source.version} - ${target.version} + ${maven.compiler.release} + ${maven.compiler.release} diff --git a/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/IgnoredClass.java b/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/IgnoredClass.java index f0c12b9..4155bcd 100644 --- a/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/IgnoredClass.java +++ b/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/IgnoredClass.java @@ -1,6 +1,6 @@ package com.github.valdr.demo.model; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; public class IgnoredClass { @NotNull diff --git a/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/Person.java b/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/Person.java index 28dc8b1..cad3817 100644 --- a/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/Person.java +++ b/valdr-bean-validation-demo/src/main/java/com/github/valdr/demo/model/Person.java @@ -3,9 +3,9 @@ import org.hibernate.validator.constraints.CreditCardNumber; import org.hibernate.validator.constraints.URL; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; public class Person { @NotNull(message = "\\foo") diff --git a/valdr-bean-validation/pom.xml b/valdr-bean-validation/pom.xml index bcddf68..992f3ee 100644 --- a/valdr-bean-validation/pom.xml +++ b/valdr-bean-validation/pom.xml @@ -20,8 +20,8 @@ reflections - javax.validation - validation-api + jakarta.validation + jakarta.validation-api com.fasterxml.jackson.core @@ -50,8 +50,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api provided @@ -92,8 +92,13 @@ test - org.hibernate.javax.persistence - hibernate-jpa-2.1-api + jakarta.persistence + jakarta.persistence-api + test + + + jakarta.xml.bind + jakarta.xml.bind-api test @@ -113,7 +118,6 @@ org.jacoco jacoco-maven-plugin - 0.8.1 com/github/valdr/thirdparty/**/*.class diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/BuiltInConstraint.java b/valdr-bean-validation/src/main/java/com/github/valdr/BuiltInConstraint.java index 2aff3b7..b975cc9 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/BuiltInConstraint.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/BuiltInConstraint.java @@ -8,15 +8,15 @@ import java.util.Arrays; import java.util.stream.Collectors; -import javax.validation.constraints.Digits; -import javax.validation.constraints.Email; -import javax.validation.constraints.Future; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Past; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; +import jakarta.validation.constraints.Digits; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Future; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Past; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; import lombok.Getter; import lombok.SneakyThrows; diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java b/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java index f5548b9..2a99f80 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintParser.java @@ -19,7 +19,7 @@ /** *

Parses classes in defined packages for supported Bean Validation (JSR * 303) - * annotations ({@code javax.validation.*}) and configured custom annotations. + * annotations ({@code jakarta.validation.*}) and configured custom annotations. *

The parsing result is a JSON string that complies with the document specified by valdr. * diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/ValidationRulesServlet.java b/valdr-bean-validation/src/main/java/com/github/valdr/ValidationRulesServlet.java index ffa000b..2504938 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/ValidationRulesServlet.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/ValidationRulesServlet.java @@ -7,11 +7,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -24,7 +24,7 @@ * custom Bean Validation annotations. The Servlet then builds and returns a JSON document with all validation rules * (i.e. Bean Validation constraints). The JSON document adheres to structure specified by valdr.

* - * Servlet can be configured using following {@link javax.servlet.ServletConfig} init parameters (* = mandatory): + * Servlet can be configured using following {@link jakarta.servlet.ServletConfig} init parameters (* = mandatory): *
    *
  • configFile: path to JSON configuration file, if omitted valdr-bean-validation.json is expected at root of class * path
  • diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java b/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java index 2084cae..6837942 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java @@ -7,7 +7,7 @@ import com.github.valdr.ConstraintAttributes; /** - * Decorates the map of attributes of the {@link javax.validation.constraints.Pattern} constraint. + * Decorates the map of attributes of the {@link jakarta.validation.constraints.Pattern} constraint. */ public class PatternDecorator extends AbstractConstraintAttributesDecorator { diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java index 6b92466..e787d6f 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java @@ -71,7 +71,7 @@ public void shouldReturnDefaultMessage() { " \"" + TestModelWithASingleAnnotatedMember.class.getSimpleName() + "\" : {" + LS + " \"notNullString\" : {" + LS + " \"required\" : {" + LS + - " \"message\" : \"{javax.validation.constraints.NotNull.message}\"" + LS + + " \"message\" : \"{jakarta.validation.constraints.NotNull.message}\"" + LS + " }" + LS + " }" + LS + " }" + LS + @@ -164,7 +164,7 @@ public void shouldSupportEmailAnnotation() { // then assertThat(json, containsString(TestModelWithEmailAnnotation.class.getSimpleName())); assertThat(json, containsString("email")); - assertThat(json, containsString("{javax.validation.constraints.Email.message}")); + assertThat(json, containsString("{jakarta.validation.constraints.Email.message}")); } /** @@ -198,9 +198,9 @@ public void shouldConsiderSuperClassMembers() throws IOException { JsonNode jsonNode = new ObjectMapper().readTree(json); // then assertThat(jsonNode.get(SuperClassWithValidatedMember.class.getSimpleName()).get("notNullString").get("required") - .get("message").asText(), is("{javax.validation.constraints.NotNull.message}")); + .get("message").asText(), is("{jakarta.validation.constraints.NotNull.message}")); assertThat(jsonNode.get(SubClassWithNoValidatedMembers.class.getSimpleName()).get("notNullString").get - ("required").get("message").asText(), is("{javax.validation.constraints.NotNull.message}")); + ("required").get("message").asText(), is("{jakarta.validation.constraints.NotNull.message}")); } /** diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java index 66be7d0..7f7bf9f 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java @@ -10,8 +10,8 @@ import java.io.FileWriter; import java.io.IOException; -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletException; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.core.Is.is; diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java index 6639e03..e73f6f9 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java @@ -25,7 +25,7 @@ public class PatternDecoratorTest { @Test public void shouldStoreThePatternForValueAttribute() { /* - * javax.validation.constraints.Pattern uses the attribute 'regex' to define the pattern. However, for valdr the + * jakarta.validation.constraints.Pattern uses the attribute 'regex' to define the pattern. However, for valdr the * pattern must be passed in the 'value' attribute. */ // given diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/a/TestModelWithASingleAnnotatedMember.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/a/TestModelWithASingleAnnotatedMember.java index 81489b3..392373d 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/a/TestModelWithASingleAnnotatedMember.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/a/TestModelWithASingleAnnotatedMember.java @@ -2,7 +2,7 @@ import lombok.Getter; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Getter public class TestModelWithASingleAnnotatedMember { diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/c/TestModelWithASingleAnnotatedMemberWithCustomMessageKey.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/c/TestModelWithASingleAnnotatedMemberWithCustomMessageKey.java index cbbe60e..a3dce5c 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/c/TestModelWithASingleAnnotatedMemberWithCustomMessageKey.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/c/TestModelWithASingleAnnotatedMemberWithCustomMessageKey.java @@ -2,7 +2,7 @@ import lombok.Getter; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Getter public class TestModelWithASingleAnnotatedMemberWithCustomMessageKey { diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/d/SuperClassWithValidatedMember.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/d/SuperClassWithValidatedMember.java index 4b07b77..ca55471 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/d/SuperClassWithValidatedMember.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/d/SuperClassWithValidatedMember.java @@ -2,7 +2,7 @@ import lombok.Getter; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; @Getter public class SuperClassWithValidatedMember { diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/e/TestModelClassWithLotsOfIrrelevantAnnotations.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/e/TestModelClassWithLotsOfIrrelevantAnnotations.java index 8f90362..d5ab290 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/e/TestModelClassWithLotsOfIrrelevantAnnotations.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/e/TestModelClassWithLotsOfIrrelevantAnnotations.java @@ -2,11 +2,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; -import org.hibernate.validator.constraints.SafeHtml; public class TestModelClassWithLotsOfIrrelevantAnnotations { @Deprecated - @SafeHtml @Getter @JsonIgnore private String foo; diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/f/TestModelWithEmailAnnotation.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/f/TestModelWithEmailAnnotation.java index d8b363f..abb0c88 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/f/TestModelWithEmailAnnotation.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/f/TestModelWithEmailAnnotation.java @@ -1,6 +1,6 @@ package com.github.valdr.model.f; -import javax.validation.constraints.Email; +import jakarta.validation.constraints.Email; public class TestModelWithEmailAnnotation { @Email diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/h/TestModelWithPatterns.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/h/TestModelWithPatterns.java index a230222..49cf76c 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/h/TestModelWithPatterns.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/h/TestModelWithPatterns.java @@ -1,6 +1,6 @@ package com.github.valdr.model.h; -import javax.validation.constraints.Pattern; +import jakarta.validation.constraints.Pattern; public class TestModelWithPatterns { @Pattern(regexp = "abc") diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/i/TestModelWithoutAnyConstraintAnnotations.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/i/TestModelWithoutAnyConstraintAnnotations.java index 24412a8..2f3359a 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/i/TestModelWithoutAnyConstraintAnnotations.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/i/TestModelWithoutAnyConstraintAnnotations.java @@ -4,14 +4,14 @@ import lombok.Getter; import lombok.NonNull; -import javax.persistence.Column; -import javax.persistence.MappedSuperclass; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Version; -import javax.xml.bind.annotation.XmlRootElement; +import jakarta.persistence.Column; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.persistence.Version; +import jakarta.xml.bind.annotation.XmlRootElement; import java.util.Date; /** diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/model/validation/CustomValidation.java b/valdr-bean-validation/src/test/java/com/github/valdr/model/validation/CustomValidation.java index c7e5f6b..39d06d8 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/model/validation/CustomValidation.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/model/validation/CustomValidation.java @@ -1,7 +1,7 @@ package com.github.valdr.model.validation; -import javax.validation.Constraint; +import jakarta.validation.Constraint; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; From 61d08271043dc05023bdf949bb66e59186ebed51 Mon Sep 17 00:00:00 2001 From: Davide De Date: Fri, 15 Sep 2023 09:12:12 +0200 Subject: [PATCH 2/3] Dependency update --- .idea/encodings.xml | 8 +- .idea/misc.xml | 2 +- pom.xml | 41 ++++----- .../valdr-bean-validation-demo.iml | 38 +++++---- valdr-bean-validation-parent.iml | 2 +- valdr-bean-validation/pom.xml | 6 +- .../com/github/valdr/AnnotatedClassTest.java | 2 +- .../github/valdr/ClasspathScannerTest.java | 8 +- .../github/valdr/ConstraintParserTest.java | 10 +-- .../java/com/github/valdr/OptionsTest.java | 7 +- .../github/valdr/ValdrBeanValidationTest.java | 6 +- .../valdr/ValidationRulesServletTest.java | 12 +-- .../valdr/decorator/PatternDecoratorTest.java | 4 +- .../serializer/MinimalMapSerializerTest.java | 8 +- .../valdr-bean-validation.iml | 85 ++++++++++++------- 15 files changed, 134 insertions(+), 105 deletions(-) diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 12108cd..0939357 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,9 +1,15 @@ - + + + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index a01d4cc..400d063 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -15,7 +15,7 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9f7d906..6e657f2 100644 --- a/pom.xml +++ b/pom.xml @@ -83,31 +83,31 @@ 3.11.0 - 3.3.1 - 1.6 - 3.0.0 - 3.1.0 - 2.5.3 - 3.0.1 - 1.6.7 + 3.4.0 + 3.1.0 + 3.5.0 + 3.3.1 + 3.0.1 + 3.2.1 + 1.6.13 0.8.10 3.0.2 - 3.7 - 1.4 - 2.7 - 29.0-jre - 1.3 - 1.0.2 + 3.13.0 + 1.5.0 + 2.13.0 + 32.1.2-jre + 2.2 + 6.1.7.Final 8.0.1.Final - 2.10.0 - 4.13.1 + 2.14.3 + 5.10.0 1.18.28 - 2.18.3 + 5.5.0 0.9.9 6.0.0 - 1.7.9 + 2.0.9 6.0.11 3.1.0 4.0.0 @@ -182,8 +182,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-api ${junit.version} test @@ -201,7 +201,7 @@ org.hamcrest - hamcrest-library + hamcrest ${hamcrest.version} test @@ -279,6 +279,7 @@ ${maven-war-plugin.version} + org.apache.maven.plugins maven-compiler-plugin ${maven.compiler.release} diff --git a/valdr-bean-validation-demo/valdr-bean-validation-demo.iml b/valdr-bean-validation-demo/valdr-bean-validation-demo.iml index e16ca87..df0413e 100644 --- a/valdr-bean-validation-demo/valdr-bean-validation-demo.iml +++ b/valdr-bean-validation-demo/valdr-bean-validation-demo.iml @@ -12,7 +12,7 @@ - + @@ -23,25 +23,27 @@ - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/valdr-bean-validation-parent.iml b/valdr-bean-validation-parent.iml index 9e16274..57db11d 100644 --- a/valdr-bean-validation-parent.iml +++ b/valdr-bean-validation-parent.iml @@ -1,6 +1,6 @@ - + diff --git a/valdr-bean-validation/pom.xml b/valdr-bean-validation/pom.xml index 992f3ee..dac352f 100644 --- a/valdr-bean-validation/pom.xml +++ b/valdr-bean-validation/pom.xml @@ -62,8 +62,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter-api test @@ -83,7 +83,7 @@ org.hamcrest - hamcrest-library + hamcrest test diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/AnnotatedClassTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/AnnotatedClassTest.java index 990c2ff..708d3e8 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/AnnotatedClassTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/AnnotatedClassTest.java @@ -2,7 +2,7 @@ import com.github.valdr.model.a.TestModelWithASingleAnnotatedMember; import com.google.common.collect.Lists; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/ClasspathScannerTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/ClasspathScannerTest.java index 2377f72..4407514 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/ClasspathScannerTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/ClasspathScannerTest.java @@ -5,14 +5,14 @@ import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.hamcrest.Matcher; -import org.junit.Test; +import org.hamcrest.collection.IsEmptyCollection; +import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.List; import java.util.Set; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.empty; import static org.hamcrest.core.Is.is; /** @@ -30,7 +30,7 @@ public void shouldFindNothingForEmptyPackageNames() { // when Set> classesToParse = classpathScanner.findClassesToParse(); // then - assertThat(classesToParse, is(empty())); + assertThat(classesToParse, IsEmptyCollection.empty()); } /** @@ -43,7 +43,7 @@ public void shouldFindNothingForEmptyPackageNameString() { // when Set> classesToParse = classpathScanner.findClassesToParse(); // then - assertThat(classesToParse, is(empty())); + assertThat(classesToParse, IsEmptyCollection.empty()); } /** diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java index e787d6f..96a9754 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/ConstraintParserTest.java @@ -14,16 +14,16 @@ import com.github.valdr.model.h.TestModelWithPatterns; import com.github.valdr.model.validation.CustomValidation; import com.google.common.collect.Lists; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; import java.util.List; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.StringContains.containsString; +import static org.hamcrest.core.StringStartsWith.startsWith; public class ConstraintParserTest { private static final String LS = System.getProperty("line.separator"); diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/OptionsTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/OptionsTest.java index 5bd13c8..114c587 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/OptionsTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/OptionsTest.java @@ -1,10 +1,11 @@ package com.github.valdr; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests Options. diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/ValdrBeanValidationTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/ValdrBeanValidationTest.java index bd0f7d9..5c8e1b6 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/ValdrBeanValidationTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/ValdrBeanValidationTest.java @@ -4,7 +4,6 @@ import com.github.valdr.util.SysOutSlurper; import org.apache.commons.io.FileUtils; -import org.junit.Test; import java.io.File; import java.io.FileWriter; @@ -12,11 +11,12 @@ import java.nio.charset.Charset; import lombok.SneakyThrows; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests ValdrBeanValidation. diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java index 7f7bf9f..b3d1b47 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/ValidationRulesServletTest.java @@ -1,7 +1,7 @@ package com.github.valdr; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.util.ReflectionTestUtils; @@ -13,10 +13,10 @@ import jakarta.servlet.ServletConfig; import jakarta.servlet.ServletException; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.mock; @@ -30,8 +30,8 @@ public class ValidationRulesServletTest { private MockHttpServletResponse response; private MockHttpServletRequest request; - @Before - public void setUp() throws Exception { + @BeforeEach + public void setUp() { servletConfig = mock(ServletConfig.class); response = new MockHttpServletResponse(); request = new MockHttpServletRequest(); diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java index e73f6f9..4fadb04 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/decorator/PatternDecoratorTest.java @@ -1,14 +1,14 @@ package com.github.valdr.decorator; import com.github.valdr.ConstraintAttributes; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.HashMap; import java.util.Map; import java.util.Set; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; diff --git a/valdr-bean-validation/src/test/java/com/github/valdr/serializer/MinimalMapSerializerTest.java b/valdr-bean-validation/src/test/java/com/github/valdr/serializer/MinimalMapSerializerTest.java index 724d5ee..c0a0de4 100644 --- a/valdr-bean-validation/src/test/java/com/github/valdr/serializer/MinimalMapSerializerTest.java +++ b/valdr-bean-validation/src/test/java/com/github/valdr/serializer/MinimalMapSerializerTest.java @@ -5,16 +5,16 @@ import com.fasterxml.jackson.databind.module.SimpleModule; import com.github.valdr.MinimalMap; import lombok.Value; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; /** * Tests {@link MinimalMapSerializer}. @@ -26,7 +26,7 @@ public class MinimalMapSerializerTest { /** * Initializes the map. */ - @Before + @BeforeEach public void setup() { attributeMap = new TestMinimalMap(); } diff --git a/valdr-bean-validation/valdr-bean-validation.iml b/valdr-bean-validation/valdr-bean-validation.iml index e07368d..059c9f4 100644 --- a/valdr-bean-validation/valdr-bean-validation.iml +++ b/valdr-bean-validation/valdr-bean-validation.iml @@ -1,6 +1,17 @@ - + + + + + + + + + + + + @@ -12,40 +23,48 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c682a3a68fb6517bce2de24d52bfead49413263e Mon Sep 17 00:00:00 2001 From: Davide De Date: Fri, 15 Sep 2023 10:34:35 +0200 Subject: [PATCH 3/3] Rephrase description - delete AngularJS as client example due to the fact that it works with other clients as well --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6b64b91..1db93e1 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,7 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.valdr/valdr-bean-validation/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.valdr/valdr-bean-validation/) [![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/netceteragroup/valdr-bean-validation/blob/master/LICENSE) -[Bean Validation](http://beanvalidation.org/) (JSR 303) plugin for [valdr](https://github.com/netceteragroup/valdr), -the new AngularJS Model Validator. +[Bean Validation](http://beanvalidation.org/) (JSR 303) plugin for [valdr](https://github.com/netceteragroup/valdr) @@ -27,13 +26,13 @@ the new AngularJS Model Validator. valdr Bean Validation parses Java model classes for Bean Validation constraints (aka JSR 303 annotations) and extracts their information into a [JSON document to be used by valdr](https://github.com/netceteragroup/valdr#constraints-json). This allows to apply the exact same -validation rules on the server and on the AngularJS client. +validation rules on the server and on the client. ## Features - _offline use:_ CLI client which can be integrated into build process to produce static valdr JSON which is packaged and delivered with the web application -- _online use:_ Servlet which parses model classes at runtime and sends JSON back to AngularJS client (e.g. during +- _online use:_ Servlet which parses model classes at runtime and sends JSON back to the client (e.g. during client start or on-demand) - both Servlet and CLI client support a number of [config options](https://github.com/netceteragroup/valdr-bean-validation/blob/master/valdr-bean-validation-demo/src/main/resources/valdr-bean-validation.json) - list of packages to scan