diff --git a/build.gradle b/build.gradle index fa62f629..edaf365e 100644 --- a/build.gradle +++ b/build.gradle @@ -50,6 +50,12 @@ subprojects { apply plugin: "com.github.mxenabled.vogue" apply plugin: "io.freefair.lombok" + ext { + mockitoVersion = "[4.0,5.0)" + spockVersion = "2.4-M1-groovy-4.0" + junitVersion = "[5.9.0,5.10.0)" + } + dependencies { constraints { api("com.google.code.gson:gson") { @@ -99,9 +105,9 @@ subprojects { // ----------------------------------------------------------------- } - testImplementation "org.mockito:mockito-inline:[4.0,5.0)" - testImplementation "org.spockframework:spock-core:2.4-M1-groovy-4.0" - testImplementation "org.junit.jupiter:junit-jupiter-api:[5.9.0,5.10.0)" + testImplementation "org.mockito:mockito-inline:${project.ext.mockitoVersion}" + testImplementation "org.spockframework:spock-core:${project.ext.spockVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-api:${project.ext.junitVersion}" } test { useJUnitPlatform() } @@ -243,3 +249,8 @@ task subdependencies { } project.tasks.getByPath("dependencies").finalizedBy("subdependencies") + +wrapper { + gradleVersion = "7.5.1" + distributionType = Wrapper.DistributionType.BIN +} diff --git a/common/gradle.lockfile b/common/gradle.lockfile index 3c5cbd82..440ea391 100644 --- a/common/gradle.lockfile +++ b/common/gradle.lockfile @@ -36,10 +36,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -75,7 +75,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.slf4j:slf4j-api:1.7.30=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j org.slf4j:slf4j-api:2.0.9=spotbugs diff --git a/context/gradle.lockfile b/context/gradle.lockfile index a3c29735..885b7d38 100644 --- a/context/gradle.lockfile +++ b/context/gradle.lockfile @@ -46,10 +46,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -85,7 +85,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.slf4j:slf4j-api:1.7.30=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j org.slf4j:slf4j-api:2.0.9=spotbugs diff --git a/gateway-generator/gradle.lockfile b/gateway-generator/gradle.lockfile index 4c280e16..7f3956c0 100644 --- a/gateway-generator/gradle.lockfile +++ b/gateway-generator/gradle.lockfile @@ -59,10 +59,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -104,7 +104,7 @@ org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs org.projectlombok:lombok:1.18.24=runtimeClasspath,testRuntimeClasspath -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j diff --git a/gateway/gradle.lockfile b/gateway/gradle.lockfile index ea9ae8ea..2d1534e2 100644 --- a/gateway/gradle.lockfile +++ b/gateway/gradle.lockfile @@ -56,10 +56,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -100,7 +100,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.reflections:reflections:0.10.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.slf4j:slf4j-api:1.7.32=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a..249e5832 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradlew b/gradlew index 1b6c7873..a69d9cb6 100755 --- a/gradlew +++ b/gradlew @@ -205,6 +205,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32..f127cfd4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/http/gradle.lockfile b/http/gradle.lockfile index f96a0208..cc08794f 100644 --- a/http/gradle.lockfile +++ b/http/gradle.lockfile @@ -56,10 +56,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -100,7 +100,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:1.7.30=compileClasspath,testCompileClasspath org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath diff --git a/messaging/gradle.lockfile b/messaging/gradle.lockfile index 0eca2820..8d40e490 100644 --- a/messaging/gradle.lockfile +++ b/messaging/gradle.lockfile @@ -47,10 +47,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -86,7 +86,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.slf4j:slf4j-api:1.7.30=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j org.slf4j:slf4j-api:2.0.9=spotbugs diff --git a/test-gateway-generator/gradle.lockfile b/test-gateway-generator/gradle.lockfile index 3e699e41..68b5dff1 100644 --- a/test-gateway-generator/gradle.lockfile +++ b/test-gateway-generator/gradle.lockfile @@ -46,9 +46,9 @@ net.bytebuddy:byte-buddy:1.12.19=testCompileClasspath,testRuntimeClasspath net.sf.saxon:Saxon-HE:12.3=spotbugs org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -88,7 +88,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.6=spotbugs org.projectlombok:lombok:1.18.24=runtimeClasspath,testRuntimeClasspath -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j diff --git a/test-gateways/gradle.lockfile b/test-gateways/gradle.lockfile index 3c114d02..9407b6ea 100644 --- a/test-gateways/gradle.lockfile +++ b/test-gateways/gradle.lockfile @@ -61,10 +61,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=annotationProcessor,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -105,7 +105,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.reflections:reflections:0.10.2=annotationProcessor,runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:1.7.32=annotationProcessor,runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j diff --git a/test-models/gradle.lockfile b/test-models/gradle.lockfile index fa3fb7e1..44e37bf9 100644 --- a/test-models/gradle.lockfile +++ b/test-models/gradle.lockfile @@ -55,10 +55,10 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy-bom:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.groovy:groovy:4.0.6=testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs @@ -99,7 +99,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j diff --git a/testing/build.gradle b/testing/build.gradle index c6eedf4f..b2e1efc6 100644 --- a/testing/build.gradle +++ b/testing/build.gradle @@ -1,9 +1,10 @@ dependencies { - api "org.spockframework:spock-junit4:[2.0,3.0)" + api "org.spockframework:spock-junit4:${project.ext.spockVersion}" implementation project(":gateway") - implementation "org.mockito:mockito-inline:[4.0,5.0)" - implementation "org.spockframework:spock-core:[2.0,3.0)" - implementation "org.junit.jupiter:junit-jupiter-api:[5.9.0,5.10.0)" - runtimeOnly "org.junit.jupiter:junit-jupiter-engine:[5.9.0,5.10.0)" + implementation "org.assertj:assertj-core:[3.0,4.0)" + implementation "org.mockito:mockito-inline:${project.ext.mockitoVersion}" + implementation "org.spockframework:spock-core:${project.ext.spockVersion}" + implementation "org.junit.jupiter:junit-jupiter-api:${project.ext.junitVersion}" + runtimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.ext.junitVersion}" } diff --git a/testing/gradle.lockfile b/testing/gradle.lockfile index 2f8bb83a..ed4a037c 100644 --- a/testing/gradle.lockfile +++ b/testing/gradle.lockfile @@ -37,7 +37,6 @@ commons-lang:commons-lang:2.6=runtimeClasspath,testRuntimeClasspath commons-logging:commons-logging:1.2=runtimeClasspath,testRuntimeClasspath info.picocli:picocli:4.1.4=checkstyle io.github.cdimascio:dotenv-java:2.3.2=runtimeClasspath,testRuntimeClasspath -io.leangen.geantyref:geantyref:1.3.16=runtimeClasspath,testRuntimeClasspath io.opentracing:opentracing-api:0.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.opentracing:opentracing-noop:0.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath io.opentracing:opentracing-util:0.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath @@ -47,7 +46,7 @@ jakarta.xml.soap:jakarta.xml.soap-api:1.4.2=compileClasspath,runtimeClasspath,te jaxen:jaxen:2.0.0=spotbugs junit:junit:4.13.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath net.bytebuddy:byte-buddy-agent:1.12.19=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -net.bytebuddy:byte-buddy:1.12.19=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +net.bytebuddy:byte-buddy:1.17.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath net.sf.saxon:Saxon-HE:12.3=spotbugs net.sf.saxon:Saxon-HE:9.9.1-6=checkstyle net.sourceforge.pmd:pmd-core:6.54.0=pmd @@ -57,12 +56,12 @@ org.antlr:antlr4-runtime:4.7.2=pmd org.antlr:antlr4-runtime:4.8-1=checkstyle org.apache.bcel:bcel:6.6.1=spotbugs org.apache.commons:commons-lang3:3.13.0=spotbugs -org.apache.commons:commons-lang3:3.17.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-lang3:3.18.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.commons:commons-lang3:3.8.1=pmd org.apache.commons:commons-text:1.10.0=spotbugs -org.apache.commons:commons-text:1.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.groovy:groovy-bom:4.0.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.apache.groovy:groovy:4.0.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.commons:commons-text:1.14.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.groovy:groovy-bom:4.0.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.apache.groovy:groovy:4.0.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs org.apache.httpcomponents.core5:httpcore5-h2:5.1.3=spotbugs org.apache.httpcomponents.core5:httpcore5:5.1.3=spotbugs @@ -71,27 +70,28 @@ org.apache.httpcomponents:httpcore:4.4.13=runtimeClasspath,testRuntimeClasspath org.apache.logging.log4j:log4j-api:2.22.0=spotbugs org.apache.logging.log4j:log4j-core:2.22.0=spotbugs org.apiguardian:apiguardian-api:1.1.2=compileClasspath,testCompileClasspath +org.assertj:assertj-core:3.27.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.checkerframework:checker-qual:2.10.0=checkstyle org.checkerframework:checker-qual:3.12.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.dom4j:dom4j:2.1.4=spotbugs org.glassfish.jaxb:jaxb-runtime:2.3.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.glassfish.jaxb:txw2:2.3.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest-core:1.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.hamcrest:hamcrest:3.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.jacoco:org.jacoco.agent:0.8.8=jacocoAgent,jacocoAnt org.jacoco:org.jacoco.ant:0.8.8=jacocoAnt org.jacoco:org.jacoco.core:0.8.8=jacocoAnt org.jacoco:org.jacoco.report:0.8.8=jacocoAnt org.javassist:javassist:3.28.0-GA=runtimeClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-api:5.12.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.jupiter:junit-jupiter-engine:5.12.2=runtimeClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-commons:1.12.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit.platform:junit-platform-engine:1.12.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.junit:junit-bom:5.12.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-api:5.9.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.jupiter:junit-jupiter-engine:5.9.3=runtimeClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-commons:1.9.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit.platform:junit-platform-engine:1.9.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.junit:junit-bom:5.9.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.mockito:mockito-core:4.11.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.mockito:mockito-inline:4.11.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.objenesis:objenesis:3.3=runtimeClasspath,testRuntimeClasspath -org.opentest4j:opentest4j:1.3.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.opentest4j:opentest4j:1.2.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.ow2.asm:asm-analysis:9.2=jacocoAnt org.ow2.asm:asm-analysis:9.6=spotbugs org.ow2.asm:asm-commons:9.2=jacocoAnt @@ -102,15 +102,14 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.reflections:reflections:0.10.2=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:1.7.32=runtimeClasspath,testRuntimeClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j org.slf4j:slf4j-api:2.0.9=spotbugs org.slf4j:slf4j-simple:2.0.0=spotbugsSlf4j -org.spockframework:spock-bom:2.4-M6-groovy-4.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.spockframework:spock-core:2.4-M6-groovy-4.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.spockframework:spock-junit4:2.4-M6-groovy-4.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.spockframework:spock-core:2.4-M1-groovy-4.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.spockframework:spock-junit4:2.4-M1-groovy-4.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.xmlresolver:xmlresolver:5.2.0=spotbugs org.yaml:snakeyaml:1.33=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath empty=signatures,spotbugsPlugins diff --git a/testing/src/main/java/com/mx/path/testing/util/DeepReflectionEquals.java b/testing/src/main/java/com/mx/path/testing/util/DeepReflectionEquals.java new file mode 100644 index 00000000..95a4d64f --- /dev/null +++ b/testing/src/main/java/com/mx/path/testing/util/DeepReflectionEquals.java @@ -0,0 +1,75 @@ +package com.mx.path.testing.util; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; +import static org.mockito.ArgumentMatchers.argThat; + +import org.mockito.ArgumentMatcher; + +/** + * A Mockito {@link ArgumentMatcher} that performs a deep reflection-based equality check + * using AssertJ's recursive comparison. + *
+ * This matcher is particularly useful for verifying method arguments when the object being passed + * does not implement {@link Object#equals(Object)}, or when you need to exclude specific + * fields (such as timestamps, auto-generated IDs, or random tokens) from the comparison. + *
+ * + * Usage Example: + *+ * // Verify that save was called with a specific object, ignoring the "id" field + * verify(myRepository).save(deepRefEq(expectedEntity, "id")); + *+ * + * @param
+ * This is the primary entry point for using this matcher within Mockito's {@code verify} + * or {@code when} clauses. + *
+ * + * @param value the expected value to match against + * @param excludeFields (Optional) a list of field names to exclude from the comparison + * @param+ * This method serves as a utility assertion; if the objects are not deeply equal or if their classes + * do not exactly match, it will throw an {@link AssertionError} providing detailed information about the failure. + *
+ * + * @param obj1 the first object to compare + * @param obj2 the second object to compare + * @throws AssertionError if the objects are not deeply equal, not the same class, or if either object is null. + */ + public static void deepEquals(Object obj1, Object obj2) { + AssertionsForClassTypes.assertThat(obj2) + .isNotNull(); + AssertionsForClassTypes.assertThat(obj1) + .isNotNull() + .hasSameClassAs(obj2) + .usingRecursiveComparison() + .isEqualTo(obj2); + } +} diff --git a/testing/src/test/groovy/com/mx/path/testing/util/DeepReflectionEqualsTest.groovy b/testing/src/test/groovy/com/mx/path/testing/util/DeepReflectionEqualsTest.groovy new file mode 100644 index 00000000..b3ca1945 --- /dev/null +++ b/testing/src/test/groovy/com/mx/path/testing/util/DeepReflectionEqualsTest.groovy @@ -0,0 +1,72 @@ +package com.mx.path.testing.util + +import static DeepReflectionEquals.deepRefEq +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.verify + +import com.mx.testing.data.Address +import com.mx.testing.data.User +import com.mx.testing.data.UserService + +import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent + +import spock.lang.Specification + +class DeepReflectionEqualsTest extends Specification { + + UserService mockUserService + + def setup() { + mockUserService = mock(UserService) + } + + def "should successfully verify invocation when actual and expected objects are deeply equal"() { + given: + def actualUser = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) + def expectedUser = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) + + when: + mockUserService.save(actualUser) + + then: + verify(mockUserService).save(deepRefEq(expectedUser)) + } + + def "should successfully verify invocation when ignoring a mismatched field"() { + given: + def actualUser = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) + def expectedUser = new User(id: 2, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) // ID mismatch + + when: + mockUserService.save(actualUser) + + then: + verify(mockUserService).save(deepRefEq(expectedUser, "id")) + } + + def "should fail verification when ignoring the wrong field"() { + given: + def actualUser = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) + def expectedUser = new User(id: 2, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) // ID mismatch + mockUserService.save(actualUser) + + when: + verify(mockUserService).save(deepRefEq(expectedUser, "name")) + + then: + thrown(ArgumentsAreDifferent) + } + + def "should fail verification when a nested field value does not match"() { + given: + def actualUser = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) + def expectedUser = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "22222")) // zip code mismatch + mockUserService.save(actualUser) + + when: + verify(mockUserService).save(deepRefEq(expectedUser)) + + then: + thrown(ArgumentsAreDifferent) + } +} diff --git a/testing/src/test/groovy/com/mx/path/testing/util/TestUtilsTest.groovy b/testing/src/test/groovy/com/mx/path/testing/util/TestUtilsTest.groovy new file mode 100644 index 00000000..d4df0032 --- /dev/null +++ b/testing/src/test/groovy/com/mx/path/testing/util/TestUtilsTest.groovy @@ -0,0 +1,63 @@ +package com.mx.path.testing.util + +import com.mx.testing.data.Address +import com.mx.testing.data.Person +import com.mx.testing.data.User + +import spock.lang.Specification + +class TestUtilsTest extends Specification { + + def "deepEquals should return true for two deeply equal but different object instances"() { + given: + def user1 = new User(id: 1, name: "Alice", address: new Address(street: "123 Main St", zipCode: "11111")) + def user2 = new User(id: 1, name: "Alice", address: new Address(street: "123 Main St", zipCode: "11111")) + + when: + TestUtils.deepEquals(user1, user2) + + then: + noExceptionThrown() + } + + def "deepEquals should return false when a nested field value does not match"() { + given: + def user1 = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "11111")) + def user2 = new User(id: 1, name: "Bob", address: new Address(street: "123 Main St", zipCode: "22222")) // zip code mismatch + + when: + TestUtils.deepEquals(user1, user2) + + then: + thrown(AssertionError) + } + + def "deepEquals should return false for objects with different types"() { + given: + def obj1 = new User(id: 1, name: "Charlie", address: new Address(street: "456 Side Ave", zipCode: "33333")) + def obj2 = new Person(id: 1, name: "Charlie", address: new Address(street: "456 Side Ave", zipCode: "33333")) // type mismatch + + when: + TestUtils.deepEquals(obj1, obj2) + + then: + thrown(AssertionError) + } + + def "deepEquals should return false if either object is null"() { + given: + def user = new User(id: 1, name: "Alice", address: new Address(street: "123 Main St", zipCode: "11111")) + + when: "obj1 is null" + TestUtils.deepEquals(null, user) + + then: + thrown(AssertionError) + + when: "obj2 is null" + TestUtils.deepEquals(user, null) + + then: + thrown(AssertionError) + } +} diff --git a/testing/src/test/java/com/mx/testing/data/Address.java b/testing/src/test/java/com/mx/testing/data/Address.java new file mode 100644 index 00000000..8a9f7e92 --- /dev/null +++ b/testing/src/test/java/com/mx/testing/data/Address.java @@ -0,0 +1,11 @@ +package com.mx.testing.data; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class Address { + private String street; + private String zipCode; +} diff --git a/testing/src/test/java/com/mx/testing/data/Person.java b/testing/src/test/java/com/mx/testing/data/Person.java new file mode 100644 index 00000000..9aa6e7df --- /dev/null +++ b/testing/src/test/java/com/mx/testing/data/Person.java @@ -0,0 +1,12 @@ +package com.mx.testing.data; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class Person { + private Integer id; + private String name; + private Address address; +} diff --git a/testing/src/test/java/com/mx/testing/data/User.java b/testing/src/test/java/com/mx/testing/data/User.java new file mode 100644 index 00000000..82acabb3 --- /dev/null +++ b/testing/src/test/java/com/mx/testing/data/User.java @@ -0,0 +1,12 @@ +package com.mx.testing.data; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class User { + private Integer id; + private String name; + private Address address; +} diff --git a/testing/src/test/java/com/mx/testing/data/UserService.java b/testing/src/test/java/com/mx/testing/data/UserService.java new file mode 100644 index 00000000..f9716eb9 --- /dev/null +++ b/testing/src/test/java/com/mx/testing/data/UserService.java @@ -0,0 +1,5 @@ +package com.mx.testing.data; + +public interface UserService { + void save(User user); +} diff --git a/utilities/gradle.lockfile b/utilities/gradle.lockfile index 4bc98748..049254fb 100644 --- a/utilities/gradle.lockfile +++ b/utilities/gradle.lockfile @@ -71,7 +71,7 @@ org.ow2.asm:asm-util:9.6=spotbugs org.ow2.asm:asm:9.2=jacocoAnt org.ow2.asm:asm:9.3=pmd org.ow2.asm:asm:9.6=spotbugs -org.projectlombok:lombok:1.18.38=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath +org.projectlombok:lombok:1.18.42=annotationProcessor,compileClasspath,lombok,testAnnotationProcessor,testCompileClasspath org.slf4j:slf4j-api:2.0.0=spotbugsSlf4j org.slf4j:slf4j-api:2.0.9=spotbugs org.slf4j:slf4j-simple:2.0.0=spotbugsSlf4j