diff --git a/.editorconfig b/.editorconfig
index 232e34e..dd1a844 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,4 +1,7 @@
[*.{kt,kts}]
indent_size = 2
max_line_length = 180
-disabled_rules=import-ordering
+ktlint_standard_function-signature = disabled
+ktlint_standard_no-empty-first-line-in-class-body = disabled
+ktlint_standard_string-template-indent = disabled
+ktlint_standard_multiline-expression-wrapping = disabled
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d1dbe51..7c66396 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -12,24 +12,12 @@ jobs:
strategy:
fail-fast: false
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Setup java
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v4
with:
- java-version: 1.8
- - name: Cache dependencies
- uses: actions/cache@v2
- with:
- path: ~/.gradle/caches
- key: ${{ runner.os }}-gradle-caches-${{ hashFiles('build.gradle.kts') }}
- restore-keys: |
- ${{ runner.os }}-gradle-caches-
- - name: Cache wrapper
- uses: actions/cache@v2
- with:
- path: ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- restore-keys: |
- ${{ runner.os }}-gradle-wrapper-
+ java-version: 11
+ - name: Setup Gradle
+ uses: gradle/actions/setup-gradle@v4
- name: Build
run: ./gradlew build
diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml
index 405a2b3..2e581e6 100644
--- a/.github/workflows/gradle-wrapper-validation.yml
+++ b/.github/workflows/gradle-wrapper-validation.yml
@@ -6,5 +6,5 @@ jobs:
name: "Validation"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - uses: gradle/wrapper-validation-action@v1
+ - uses: actions/checkout@v4
+ - uses: gradle/actions/wrapper-validation@v3
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b395081..974e8ca 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -8,11 +8,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Setup java
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v4
with:
- java-version: 1.8
+ java-version: 11
- name: Check version not snapshot
run: |
PROJECT_VERSION=$(./gradlew -q printVersion | tail -n 1)
diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml
index 224e668..5ddca5f 100644
--- a/.github/workflows/snapshot.yml
+++ b/.github/workflows/snapshot.yml
@@ -8,11 +8,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Setup java
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v4
with:
- java-version: 1.8
+ java-version: 11
- name: Check version is snapshot
run: |
PROJECT_VERSION=$(./gradlew -q printVersion | tail -n 1)
diff --git a/README.md b/README.md
index 938c3fc..b9ae022 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
JSON Content Validator (JCV) allows you to compare JSON contents with embedded validation.
-[![Build Status](https://github.com/ekino/jcv/workflows/Build%20branch/badge.svg?branch=master)](https://github.com/ekino/jcv/actions?query=workflow%3A%22Build+branch%22+branch%3Amaster)
+[![Build](https://github.com/ekino/jcv/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/ekino/jcv/actions/workflows/build.yml)
[![GitHub (pre-)release](https://img.shields.io/github/release/ekino/jcv/all.svg)](https://github.com/ekino/jcv/releases)
[![Maven Central](https://img.shields.io/maven-central/v/com.ekino.oss.jcv/jcv-core)](https://search.maven.org/search?q=g:com.ekino.oss.jcv)
[![GitHub license](https://img.shields.io/github/license/ekino/jcv.svg)](https://github.com/ekino/jcv/blob/master/LICENSE.md)
@@ -17,7 +17,7 @@ JSON Content Validator (JCV) allows you to compare JSON contents with embedded v
* [AssertJ module](#assertj-module)
* [Hamcrest module](#hamcrest-module)
* [WireMock module](#wiremock-module)
-* [Validators](#validators)
+* [Learn more](#learn-more)
## Summary
@@ -80,7 +80,7 @@ Maven
org.skyscreamer
jsonassert
- 1.5.0
+ 1.5.3
test
@@ -97,7 +97,7 @@ Gradle
```groovy
dependencies {
...
- testImplementation 'org.skyscreamer:jsonassert:1.5.0'
+ testImplementation 'org.skyscreamer:jsonassert:1.5.3'
testImplementation 'com.ekino.oss.jcv:jcv-core:1.6.0-SNAPSHOT'
...
}
@@ -160,13 +160,13 @@ Maven
org.skyscreamer
jsonassert
- 1.5.0
+ 1.5.3
test
org.assertj
assertj-core
- 3.9.1
+ 3.26.3
test
@@ -183,8 +183,8 @@ Gradle
```groovy
dependencies {
...
- testImplementation 'org.skyscreamer:jsonassert:1.5.0'
- testImplementation 'org.assertj:assertj-core:3.9.1'
+ testImplementation 'org.skyscreamer:jsonassert:1.5.3'
+ testImplementation 'org.assertj:assertj-core:3.26.3'
testImplementation 'com.ekino.oss.jcv:jcv-assertj:1.6.0-SNAPSHOT'
...
}
@@ -218,13 +218,13 @@ Maven
org.skyscreamer
jsonassert
- 1.5.0
+ 1.5.3
test
org.hamcrest
hamcrest
- 2.1
+ 3.0
test
@@ -241,8 +241,8 @@ Gradle
```groovy
dependencies {
...
- testImplementation 'org.skyscreamer:jsonassert:1.5.0'
- testImplementation 'org.hamcrest:hamcrest:2.1'
+ testImplementation 'org.skyscreamer:jsonassert:1.5.3'
+ testImplementation 'org.hamcrest:hamcrest:3.0'
testImplementation 'com.ekino.oss.jcv:jcv-hamcrest:1.6.0-SNAPSHOT'
...
}
@@ -330,13 +330,13 @@ Maven
org.skyscreamer
jsonassert
- 1.5.0
+ 1.5.3
test
- com.github.tomakehurst
- wiremock-jre8
- 2.27.2
+ org.wiremock
+ wiremock
+ 3.9.1
test
@@ -353,8 +353,8 @@ Gradle
```groovy
dependencies {
...
- testImplementation 'org.skyscreamer:jsonassert:1.5.0'
- testImplementation 'com.github.tomakehurst:wiremock-jre8:2.27.2'
+ testImplementation 'org.skyscreamer:jsonassert:1.5.3'
+ testImplementation 'org.wiremock:wiremock:3.9.1'
testImplementation 'com.ekino.oss.jcv:jcv-wiremock:1.6.0-SNAPSHOT'
...
}
diff --git a/build.gradle.kts b/build.gradle.kts
index b9c17ad..4f9434a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -3,11 +3,14 @@ import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask
plugins {
base
- kotlin("jvm") version "1.4.10" apply false
- id("com.ekino.oss.plugin.kotlin-quality") version "2.0.0" apply false
- id("net.researchgate.release") version "2.8.1"
- id("se.bjurr.gitchangelog.git-changelog-gradle-plugin") version "1.64"
- id("org.jetbrains.dokka") version "1.4.0-rc"
+ `maven-publish`
+ signing
+ alias(libs.plugins.kotlin.jvm) apply false
+ alias(libs.plugins.ktlint) apply false
+ alias(libs.plugins.detekt)
+ alias(libs.plugins.release)
+ alias(libs.plugins.changelog)
+ alias(libs.plugins.dokka)
}
allprojects {
@@ -15,67 +18,62 @@ allprojects {
repositories {
mavenCentral()
- jcenter()
}
-
- registerProperties(
- "kotlin.version" to "1.4.10",
- "commons-io.version" to "2.7",
- "jsonassert.version" to "1.5.0",
- "assertj.version" to "3.16.1",
- "hamcrest.version" to "2.2",
- "junit-jupiter.version" to "5.6.2",
- "assertk-jvm.version" to "0.22",
- "wiremock.version" to "2.27.2"
- )
}
-tasks.create("printVersion") {
- doLast {
- val version: String by project
- println(version)
+tasks {
+ register("printVersion") {
+ doLast {
+ println(project.version.toString())
+ }
+ }
+
+ register("gitChangelogTask") {
+ file = File("CHANGELOG.md")
+ templateContent = file("template_changelog.mustache").readText()
}
}
-tasks.create("gitChangelogTask") {
- file = File("CHANGELOG.md")
- templateContent = file("template_changelog.mustache").readText()
+detekt {
+ buildUponDefaultConfig = true
+ config.setFrom("config/detekt.yml")
}
subprojects {
apply()
apply()
+ apply()
- configure {
+ publishing {
publications {
- create("mavenJava") {
+ register("mavenJava") {
pom {
- name.set("JCV")
- description.set("JSON Content Validator (JCV) allows you to compare JSON contents with embedded validation.")
- url.set("https://github.com/ekino/jcv")
+ name = "JCV"
+ description = "JSON Content Validator (JCV) allows you to compare JSON contents with embedded validation."
+ url = "https://github.com/ekino/jcv"
licenses {
license {
- name.set("MIT License (MIT)")
- url.set("https://opensource.org/licenses/mit-license")
+ name = "MIT License (MIT)"
+ url = "https://opensource.org/licenses/mit-license"
}
}
developers {
developer {
- name.set("Léo Millon")
- email.set("leo.millon@ekino.com")
- organization.set("ekino")
- organizationUrl.set("https://www.ekino.com/")
+ name = "Léo Millon"
+ email = "leo.millon@ekino.com"
+ organization = "ekino"
+ organizationUrl = "https://www.ekino.com/"
}
}
scm {
- connection.set("scm:git:git://github.com/ekino/jcv.git")
- developerConnection.set("scm:git:ssh://github.com:ekino/jcv.git")
- url.set("https://github.com/ekino/jcv")
+ connection = "scm:git:git://github.com/ekino/jcv.git"
+ developerConnection = "scm:git:ssh://github.com:ekino/jcv.git"
+ url = "https://github.com/ekino/jcv"
}
organization {
- name.set("ekino")
- url.set("https://www.ekino.com/")
+ name = "ekino"
+ url = "https://www.ekino.com/"
}
}
repositories {
@@ -95,4 +93,9 @@ subprojects {
}
}
}
+
+ signing {
+ setRequired { gradle.taskGraph.hasTask("publish") }
+ sign(publishing.publications["mavenJava"])
+ }
}
diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore
deleted file mode 100644
index 9666bc4..0000000
--- a/buildSrc/.gitignore
+++ /dev/null
@@ -1,137 +0,0 @@
-
-# Created by https://www.gitignore.io/api/java,kotlin,gradle,intellij+all
-
-### Intellij+all ###
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/**/usage.statistics.xml
-.idea/**/dictionaries
-.idea/**/shelf
-
-# Generated files
-.idea/**/contentModel.xml
-
-# Sensitive or high-churn files
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-.idea/**/dbnavigator.xml
-
-# Gradle
-.idea/**/gradle.xml
-.idea/**/libraries
-
-# Gradle and Maven with auto-import
-# When using Gradle or Maven with auto-import, you should exclude module files,
-# since they will be recreated, and may cause churn. Uncomment if using
-# auto-import.
-# .idea/modules.xml
-# .idea/*.iml
-# .idea/modules
-
-# CMake
-cmake-build-*/
-
-# Mongo Explorer plugin
-.idea/**/mongoSettings.xml
-
-# File-based project format
-*.iws
-
-# IntelliJ
-out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-# Editor-based Rest Client
-.idea/httpRequests
-
-### Intellij+all Patch ###
-# Ignores the whole .idea folder and all .iml files
-# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
-
-.idea/
-
-# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
-
-*.iml
-modules.xml
-.idea/misc.xml
-*.ipr
-
-### Java ###
-# Compiled class file
-*.class
-
-# Log file
-*.log
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.nar
-*.ear
-*.zip
-*.tar.gz
-*.rar
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-### Kotlin ###
-# Compiled class file
-
-# Log file
-
-# BlueJ files
-
-# Mobile Tools for Java (J2ME)
-
-# Package Files #
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-
-### Gradle ###
-.gradle
-/build/
-
-# Ignore Gradle GUI config
-gradle-app.setting
-
-# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
-!gradle-wrapper.jar
-
-# Cache of project
-.gradletasknamecache
-
-# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
-# gradle/wrapper/gradle-wrapper.properties
-
-
-# End of https://www.gitignore.io/api/java,kotlin,gradle,intellij+all
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
deleted file mode 100644
index 72e4229..0000000
--- a/buildSrc/build.gradle.kts
+++ /dev/null
@@ -1,7 +0,0 @@
-plugins {
- `kotlin-dsl`
-}
-
-repositories {
- jcenter()
-}
diff --git a/buildSrc/src/main/kotlin/utils.kt b/buildSrc/src/main/kotlin/utils.kt
deleted file mode 100644
index 4039938..0000000
--- a/buildSrc/src/main/kotlin/utils.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright (c) 2019 ekino (https://www.ekino.com/)
- */
-import org.gradle.api.Project
-import org.gradle.kotlin.dsl.PluginDependenciesSpecScope
-import org.gradle.kotlin.dsl.extra
-
-fun Project.registerProperties(vararg properties: Pair) = mapOf(*properties)
- .forEach {
- project.extra.set(it.key, it.value)
- }
-
-fun Project.prop(propertyName: String) = project.extra[propertyName]
diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml
new file mode 100644
index 0000000..42797a7
--- /dev/null
+++ b/config/detekt/detekt.yml
@@ -0,0 +1,8 @@
+naming:
+ ClassNaming:
+ excludes: &testFolders
+ - '**/test/**'
+
+complexity:
+ LongMethod:
+ excludes: *testFolders
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 0000000..523a2aa
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,33 @@
+[versions]
+changelog = "2.1.2"
+detekt = "1.23.7"
+dokka = "1.9.20"
+kotlin = "2.0.20"
+ktlint = "12.1.1"
+release = "3.0.2"
+assertj = "3.26.3"
+assertk = "0.28.1"
+commons-io = "2.17.0"
+hamcrest = "3.0"
+jsonassert = "1.5.3"
+junit-jupiter = "5.11.1"
+kohttp = "0.12.0"
+wiremock = "3.9.1"
+
+[libraries]
+assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }
+assertk = { module = "com.willowtreeapps.assertk:assertk", version.ref = "assertk" }
+commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" }
+hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
+jsonassert = { module = "org.skyscreamer:jsonassert", version.ref = "jsonassert" }
+junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
+kohttp-jackson = { module = "io.github.rybalkinsd:kohttp-jackson", version.ref = "kohttp" }
+wiremock = { module = "org.wiremock:wiremock", version.ref = "wiremock" }
+
+[plugins]
+kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
+ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
+detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
+release = { id = "net.researchgate.release", version.ref = "release" }
+changelog = { id = "se.bjurr.gitchangelog.git-changelog-gradle-plugin", version.ref = "changelog" }
+dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index f3d88b1..a4b76b9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 6c9a224..df97d72 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 2fe81a7..f5feea6 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
#
-# Copyright 2015 the original author or authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,80 +15,116 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,87 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=`expr $i + 1`
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ 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.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 62bd9b9..9d21a21 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -13,8 +13,10 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
-@if "%DEBUG%" == "" @echo off
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +27,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -54,48 +57,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
: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/jcv-assertj/build.gradle.kts b/jcv-assertj/build.gradle.kts
index 0885f5a..b125c39 100644
--- a/jcv-assertj/build.gradle.kts
+++ b/jcv-assertj/build.gradle.kts
@@ -1,10 +1,8 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
kotlin("jvm")
`java-library`
- signing
- id("com.ekino.oss.plugin.kotlin-quality")
+ id("org.jlleitschuh.gradle.ktlint")
+ id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
}
@@ -18,20 +16,17 @@ java {
withSourcesJar()
}
+kotlin {
+ jvmToolchain(11)
+}
+
val javadocJar by tasks.registering(Jar::class) {
dependsOn("dokkaHtml")
archiveClassifier.set("javadoc")
- from(buildDir.resolve("dokka"))
+ from(layout.buildDirectory.dir("dokka"))
}
tasks {
- withType {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8.toString()
- apiVersion = "1.3"
- }
- }
-
withType {
useJUnitPlatform()
jvmArgs("-Duser.language=en")
@@ -41,7 +36,7 @@ tasks {
dokkaSourceSets {
configureEach {
reportUndocumented = false
- jdkVersion = 8
+ jdkVersion = 11
}
}
}
@@ -52,36 +47,24 @@ tasks {
}
}
-val publicationName = "mavenJava"
-
publishing {
publications {
- named(publicationName) {
+ named("mavenJava") {
artifact(javadocJar.get())
from(components["java"])
}
}
}
-signing {
- sign(publishing.publications[publicationName])
-}
-
dependencies {
-
- implementation(kotlin("stdlib-jdk8"))
+ implementation(kotlin("stdlib"))
api(project(":jcv-core"))
- implementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
- implementation(group = "org.assertj", name = "assertj-core", version = "${prop("assertj.version")}")
-
- testImplementation(
- group = "org.junit.jupiter",
- name = "junit-jupiter",
- version = "${prop("junit-jupiter.version")}"
- )
+ implementation(libs.jsonassert)
+ implementation(libs.assertj.core)
- testImplementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
- testImplementation(group = "org.assertj", name = "assertj-core", version = "${prop("assertj.version")}")
- testImplementation(group = "commons-io", name = "commons-io", version = "${prop("commons-io.version")}")
+ testImplementation(libs.junit.jupiter)
+ testImplementation(libs.jsonassert)
+ testImplementation(libs.assertj.core)
+ testImplementation(libs.commons.io)
}
diff --git a/jcv-assertj/src/main/kotlin/com/ekino/oss/jcv/assertion/assertj/JsonCompareAssert.kt b/jcv-assertj/src/main/kotlin/com/ekino/oss/jcv/assertion/assertj/JsonCompareAssert.kt
index 39515fd..0c8a533 100644
--- a/jcv-assertj/src/main/kotlin/com/ekino/oss/jcv/assertion/assertj/JsonCompareAssert.kt
+++ b/jcv-assertj/src/main/kotlin/com/ekino/oss/jcv/assertion/assertj/JsonCompareAssert.kt
@@ -31,10 +31,11 @@ class JsonCompareAssert(actualJson: String, private val jsonComparator: JsonComp
* @return the created assertion object
*/
@JvmStatic
- fun assertThatJson(actualJson: String) = JsonCompareAssert(
- actualJson,
- JsonComparator(JSONCompareMode.NON_EXTENSIBLE, Validators.defaultValidators())
- )
+ fun assertThatJson(actualJson: String) =
+ JsonCompareAssert(
+ actualJson,
+ JsonComparator(JSONCompareMode.NON_EXTENSIBLE, Validators.defaultValidators()),
+ )
}
/**
@@ -108,7 +109,6 @@ class JsonCompareAssert(actualJson: String, private val jsonComparator: JsonComp
* @see JSONCompare.compareJSON
*/
fun isValidAgainst(expectedJson: String): JsonCompareAssert {
-
isNotNull
Objects.requireNonNull(jsonComparator, "Json comparator definition is missing")
diff --git a/jcv-core/build.gradle.kts b/jcv-core/build.gradle.kts
index b1a4e71..20461d5 100644
--- a/jcv-core/build.gradle.kts
+++ b/jcv-core/build.gradle.kts
@@ -1,10 +1,8 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
kotlin("jvm")
`java-library`
- signing
- id("com.ekino.oss.plugin.kotlin-quality")
+ id("org.jlleitschuh.gradle.ktlint")
+ id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
}
@@ -18,20 +16,17 @@ java {
withSourcesJar()
}
+kotlin {
+ jvmToolchain(11)
+}
+
val javadocJar by tasks.registering(Jar::class) {
dependsOn("dokkaHtml")
archiveClassifier.set("javadoc")
- from(buildDir.resolve("dokka"))
+ from(layout.buildDirectory.dir("dokka"))
}
tasks {
- withType {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8.toString()
- apiVersion = "1.3"
- }
- }
-
withType {
useJUnitPlatform()
jvmArgs("-Duser.language=en")
@@ -41,7 +36,7 @@ tasks {
dokkaSourceSets {
configureEach {
reportUndocumented = false
- jdkVersion = 8
+ jdkVersion = 11
}
}
}
@@ -52,38 +47,23 @@ tasks {
}
}
-val publicationName = "mavenJava"
-
publishing {
publications {
- named(publicationName) {
+ named("mavenJava") {
artifact(javadocJar.get())
from(components["java"])
}
}
}
-signing {
- sign(publishing.publications[publicationName])
-}
-
dependencies {
- implementation(kotlin("stdlib-jdk8", version = "${prop("kotlin.version")}"))
- implementation(kotlin("reflect", version = "${prop("kotlin.version")}"))
- implementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
-
- testImplementation(
- group = "org.junit.jupiter",
- name = "junit-jupiter",
- version = "${prop("junit-jupiter.version")}"
- )
+ implementation(kotlin("stdlib"))
+ implementation(kotlin("reflect"))
+ implementation(libs.jsonassert)
- testImplementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
- testImplementation(
- group = "com.willowtreeapps.assertk",
- name = "assertk-jvm",
- version = "${prop("assertk-jvm.version")}"
- ) {
+ testImplementation(libs.junit.jupiter)
+ testImplementation(libs.jsonassert)
+ testImplementation(libs.assertk) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
}
}
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/JsonComparator.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/JsonComparator.kt
index a178b35..896ebbb 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/JsonComparator.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/JsonComparator.kt
@@ -31,7 +31,6 @@ class JsonComparator(mode: JSONCompareMode, validators: List key to value?.let { listOf(it) }.orEmpty() },
- matchingByValidator.asSequence().map { it.toPair() }
+ matchingByValidator.asSequence().map { it.toPair() },
)
.flatten()
.toMap()
@@ -166,7 +165,7 @@ class JsonComparator(mode: JSONCompareMode, validators: List,
actualElements: List,
- actualValueMatchedIndexes: MutableSet
+ actualValueMatchedIndexes: MutableSet,
): Map {
return parsedExpectedElements
.asSequence()
@@ -177,7 +176,7 @@ class JsonComparator(mode: JSONCompareMode, validators: List
actualElement
.takeUnless { actualValueMatchedIndexes.contains(index) }
- ?.takeIf { it -> expectedElement.key == it }
+ ?.takeIf { expectedElement.key == it }
?.also { actualValueMatchedIndexes.add(index) }
?.let { ActualElement(index, actualElement) }
}
@@ -189,7 +188,7 @@ class JsonComparator(mode: JSONCompareMode, validators: List,
key: String?,
actualElements: List,
- actualValueMatchedIndexes: Set
+ actualValueMatchedIndexes: Set,
): Map> {
return parsedExpectedElements
.asSequence()
@@ -200,12 +199,14 @@ class JsonComparator(mode: JSONCompareMode, validators: List
actualElement
.takeUnless { actualValueMatchedIndexes.contains(index) }
- ?.takeIf { it ->
+ ?.takeIf {
try {
expectedElement.customization
?.matches(key, it, expectedElement.key, JSONCompareResult())
?: false
- } catch (e: ValueMatcherException) {
+ } catch (
+ @Suppress("SwallowedException") e: ValueMatcherException,
+ ) {
false
}
}
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/ContainsComparator.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/ContainsComparator.kt
index fffc075..04d3f66 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/ContainsComparator.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/ContainsComparator.kt
@@ -19,7 +19,7 @@ class ContainsComparator(
*
* @param value the value to search for
*/
- private val value: String
+ private val value: String,
) : JsonValueComparator {
override fun hasCorrectValue(actual: String?, expected: String?): Boolean {
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/EndsWithComparator.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/EndsWithComparator.kt
index d68773b..0798a01 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/EndsWithComparator.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/EndsWithComparator.kt
@@ -19,7 +19,7 @@ class EndsWithComparator(
*
* @param value the value to search for
*/
- private val value: String
+ private val value: String,
) : JsonValueComparator {
override fun hasCorrectValue(actual: String?, expected: String?): Boolean {
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/NotEmptyComparator.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/NotEmptyComparator.kt
index 3598dc8..d517389 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/NotEmptyComparator.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/comparator/NotEmptyComparator.kt
@@ -10,7 +10,7 @@ import java.util.Objects
class NotEmptyComparator : JsonValueComparator {
override fun hasCorrectValue(actual: String?, expected: String?): Boolean {
- if (actual != null && actual.isNotEmpty()) {
+ if (actual.isNullOrEmpty().not()) {
return true
}
throw ValueMatcherException("Value should not be empty", Objects.toString(expected), Objects.toString(actual))
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/DateTimeFormatComparatorInitializer.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/DateTimeFormatComparatorInitializer.kt
index f27e232..b0d4dcb 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/DateTimeFormatComparatorInitializer.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/DateTimeFormatComparatorInitializer.kt
@@ -29,7 +29,7 @@ class DateTimeFormatComparatorInitializer : TwoParametersComparatorInitializer {
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/Initializers.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/Initializers.kt
index 6019a88..1949e0f 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/Initializers.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/initializer/Initializers.kt
@@ -22,7 +22,7 @@ object Initializers {
@JvmStatic
fun parameterizedValidator(
id: String,
- initializer: TemplatedComparatorInitializer
+ initializer: TemplatedComparatorInitializer,
): JsonValidator =
DefaultParameterizedTemplateValidator(id, initializer)
@@ -34,7 +34,7 @@ object Initializers {
@JvmOverloads
fun comparatorWith1Parameter(
required: Boolean = true,
- initializer: OneParameterComparatorInitializer
+ initializer: OneParameterComparatorInitializer,
): TemplatedComparatorInitializer =
TemplatedComparatorInitializer { validatorTemplateManager ->
val parameter = getOrThrowParameter(0, required, validatorTemplateManager)
@@ -45,7 +45,7 @@ object Initializers {
fun comparatorWith2Parameters(
param1Required: Boolean = true,
param2Required: Boolean = true,
- initializer: TwoParametersComparatorInitializer
+ initializer: TwoParametersComparatorInitializer,
): TemplatedComparatorInitializer {
return TemplatedComparatorInitializer { validatorTemplateManager ->
val parameter1 = getOrThrowParameter(0, param1Required, validatorTemplateManager)
@@ -57,7 +57,7 @@ object Initializers {
private fun getOrThrowParameter(
index: Int,
required: Boolean,
- validatorTemplateManager: ValidatorTemplateManager
+ validatorTemplateManager: ValidatorTemplateManager,
): String? {
val parameter = validatorTemplateManager.extractParameter(index)
require(!(required && parameter == null)) {
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultJsonValidator.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultJsonValidator.kt
index f317825..0bfbcdc 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultJsonValidator.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultJsonValidator.kt
@@ -9,7 +9,7 @@ import org.skyscreamer.jsonassert.ValueMatcher
internal class DefaultJsonValidator(
private val contextMatcher: JsonContextMatcher,
- private val valueComparator: ValueMatcher
+ private val valueComparator: ValueMatcher,
) : JsonValidator {
override fun getContextMatcher(): JsonContextMatcher = contextMatcher
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultParameterizedTemplateValidator.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultParameterizedTemplateValidator.kt
index 2c9a8a7..8646143 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultParameterizedTemplateValidator.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/DefaultParameterizedTemplateValidator.kt
@@ -8,7 +8,7 @@ import org.skyscreamer.jsonassert.ValueMatcher
class DefaultParameterizedTemplateValidator(
validatorId: String,
- private val comparatorInitializer: TemplatedComparatorInitializer
+ private val comparatorInitializer: TemplatedComparatorInitializer,
) : ValueParameterizedTemplateValidator(validatorId) {
override fun getValueComparator(validatorTemplateManager: ValidatorTemplateManager): ValueMatcher {
diff --git a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/ValidatorsDSL.kt b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/ValidatorsDSL.kt
index 764cef6..c2c28e7 100644
--- a/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/ValidatorsDSL.kt
+++ b/jcv-core/src/main/kotlin/com/ekino/oss/jcv/core/validator/ValidatorsDSL.kt
@@ -24,7 +24,7 @@ open class ValidatorBuilder {
fun templatedValidator(
validatorId: String,
- init: TemplatedComparatorBuilder.() -> TemplatedComparatorInitializer
+ init: TemplatedComparatorBuilder.() -> TemplatedComparatorInitializer,
) =
Initializers.parameterizedValidator(validatorId, init(TemplatedComparatorBuilder()))
@@ -101,15 +101,17 @@ class AnyOfOperatorBuilder {
class ComparatorWithParameterBuilder(private val validatorTemplateManager: ValidatorTemplateManager) {
fun getFirstRequiredParam() = getRequiredParam(0)
+
fun getSecondRequiredParam() = getRequiredParam(1)
fun getFirstParam() = getParam(0)
+
fun getSecondParam() = getParam(1)
fun getParam(index: Int) = validatorTemplateManager.extractParameter(index)
fun getRequiredParam(index: Int) = requireNotNull(
getParam(index),
- { "No parameter at index $index found in validator '${validatorTemplateManager.extractTemplateContent()}'" }
+ { "No parameter at index $index found in validator '${validatorTemplateManager.extractTemplateContent()}'" },
)
}
diff --git a/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/JsonComparatorTest.kt b/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/JsonComparatorTest.kt
index 4e0f28c..144db52 100644
--- a/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/JsonComparatorTest.kt
+++ b/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/JsonComparatorTest.kt
@@ -5,10 +5,10 @@ package com.ekino.oss.jcv.core
import assertk.all
import assertk.assertAll
+import assertk.assertFailure
import assertk.assertThat
import assertk.assertions.hasMessage
import assertk.assertions.isEqualTo
-import assertk.assertions.isFailure
import assertk.assertions.isFalse
import assertk.assertions.isInstanceOf
import assertk.assertions.isNotNull
@@ -38,19 +38,19 @@ class JsonComparatorTest {
private fun comparator(
vararg validators: JsonValidator = Validators.defaultValidators().toTypedArray(),
- mode: JSONCompareMode = JSONCompareMode.NON_EXTENSIBLE
+ mode: JSONCompareMode = JSONCompareMode.NON_EXTENSIBLE,
) = JsonComparator(mode, validators.toList())
private fun comparator(
validators: List>,
- mode: JSONCompareMode = JSONCompareMode.NON_EXTENSIBLE
+ mode: JSONCompareMode = JSONCompareMode.NON_EXTENSIBLE,
) = JsonComparator(mode, validators)
private fun compare(
actualJson: String,
expectedJson: String,
comparator: JsonComparator = Companion.comparator,
- body: (JSONCompareResult) -> Unit = {}
+ body: (JSONCompareResult) -> Unit = {},
) {
body.invoke(JSONCompare.compareJSON(expectedJson, actualJson, comparator))
}
@@ -62,10 +62,9 @@ class JsonComparatorTest {
@Test
fun `sample JSON validation`() {
-
compare(
loadJson("test_sample_json_actual.json"),
- loadJson("test_sample_json_expected.json")
+ loadJson("test_sample_json_expected.json"),
) {
assertAll {
assertThat(it.passed()).isTrue()
@@ -76,10 +75,9 @@ class JsonComparatorTest {
@Test
fun `default validators`() {
-
compare(
loadJson("test_default_validators_actual.json"),
- loadJson("test_default_validators_expected.json")
+ loadJson("test_default_validators_expected.json"),
) {
assertAll {
assertThat(it.passed()).isTrue()
@@ -90,7 +88,6 @@ class JsonComparatorTest {
@Test
fun `prefix matcher`() {
-
compare(
loadJson("test_prefix_matcher_actual.json"),
loadJson("test_prefix_matcher_expected.json"),
@@ -98,8 +95,8 @@ class JsonComparatorTest {
validators {
+defaultValidators()
+forPathPrefix("child.child.level", comparator { actual, _ -> actual == 9999 })
- }
- )
+ },
+ ),
) {
assertAll {
assertThat(it.passed()).isTrue()
@@ -110,7 +107,6 @@ class JsonComparatorTest {
@Test
fun `custom validator id in value matcher`() {
-
compare(
loadJson("test_validator_id_in_value_matcher_actual_invalid.json"),
loadJson("test_validator_id_in_value_matcher_expected.json"),
@@ -126,12 +122,12 @@ class JsonComparatorTest {
throw ValueMatcherException(
"Value should be '$specificValue'",
specificValue,
- Objects.toString(actual)
+ Objects.toString(actual),
)
- }
+ },
)
- }
- )
+ },
+ ),
) {
assertAll {
assertThat(it.passed()).isFalse()
@@ -141,7 +137,7 @@ class JsonComparatorTest {
Expected: THE_VALUE
got: {#someSpecificValue#}
- """.trimIndent()
+ """.trimIndent(),
)
}
}
@@ -149,15 +145,14 @@ class JsonComparatorTest {
@Test
fun `unknown date time format language tag`() {
-
- assertThat {
+ assertFailure {
compare(
// language=json
"""{"field_name": "3 Feb 2011"}""",
// language=json
- """{"field_name": "{#date_time_format:d MMM uuu;some_TAG#}"}"""
+ """{"field_name": "{#date_time_format:d MMM uuu;some_TAG#}"}""",
)
- }.isFailure().all {
+ }.all {
isInstanceOf(IllegalArgumentException::class.java)
hasMessage("Invalid language tag some_TAG")
}
@@ -165,15 +160,14 @@ class JsonComparatorTest {
@Test
fun `unknown date time format pattern`() {
-
- assertThat {
+ assertFailure {
compare(
// language=json
"""{"field_name": "2011-12-03T10:15:30Z"}""",
// language=json
- """{"field_name": "{#date_time_format:some_unknown_pattern#}"}"""
+ """{"field_name": "{#date_time_format:some_unknown_pattern#}"}""",
)
- }.isFailure().all {
+ }.all {
isInstanceOf(IllegalArgumentException::class.java)
message().isNotNull().startsWith("Unknown pattern")
}
@@ -181,7 +175,6 @@ class JsonComparatorTest {
@Test
fun `validator errors`() {
-
tableOf("actual", "expected", "error")
.row(
// language=json
@@ -193,7 +186,7 @@ class JsonComparatorTest {
Expected: {#contains:llo wor#}
got: hello_world!
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -205,7 +198,7 @@ class JsonComparatorTest {
Expected: {#starts_with:llo_wor#}
got: hello_world!
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -217,7 +210,7 @@ class JsonComparatorTest {
Expected: {#ends_with:llo_wor#}
got: hello_world!
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -229,7 +222,7 @@ class JsonComparatorTest {
Expected: {#regex:.*llo ?w.r.*#}
got: hello_world!
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -241,7 +234,7 @@ class JsonComparatorTest {
Expected: {#uuid#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -253,7 +246,7 @@ class JsonComparatorTest {
Expected: {#not_null#}
got: null
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -265,7 +258,7 @@ class JsonComparatorTest {
Expected: {#not_empty#}
got:
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -277,7 +270,7 @@ class JsonComparatorTest {
Expected: {#url#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -289,7 +282,7 @@ class JsonComparatorTest {
Expected: {#url_ending:?param#}
got: some value/?param
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -301,7 +294,7 @@ class JsonComparatorTest {
Expected: {#url_ending:/path?param2#}
got: http://some.url:9999/path?param
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -313,7 +306,7 @@ class JsonComparatorTest {
Expected: {#url_regex:^.+some\.url.+/path\?param$#}
got: some value/?param
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -325,7 +318,7 @@ class JsonComparatorTest {
Expected: {#url_regex:^.+some\.url.+/path\?param$#}
got: http://some_url:9999/path?param
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -337,7 +330,7 @@ class JsonComparatorTest {
Expected: {#templated_url#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -349,7 +342,7 @@ class JsonComparatorTest {
Expected: {#templated_url_ending:{?param}#}
got: some value {?param}
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -361,7 +354,7 @@ class JsonComparatorTest {
Expected: {#templated_url_ending:/path{?param2}#}
got: http://some.url:9999/path{?param}
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -373,7 +366,7 @@ class JsonComparatorTest {
Expected: {#templated_url_regex:^.+some\.url.+/path\{\?param\}$#}
got: some value/{?param}
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -385,7 +378,7 @@ class JsonComparatorTest {
Expected: {#templated_url_regex:^.+some\.url.+/path\{\?param\}$#}
got: http://some_url:9999/path{?param}
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -397,7 +390,7 @@ class JsonComparatorTest {
Expected: {#boolean_type#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -409,7 +402,7 @@ class JsonComparatorTest {
Expected: {#string_type#}
got: true
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -421,7 +414,7 @@ class JsonComparatorTest {
Expected: {#number_type#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -433,7 +426,7 @@ class JsonComparatorTest {
Expected: {#array_type#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -445,7 +438,7 @@ class JsonComparatorTest {
Expected: {#object_type#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.row(
// language=json
@@ -457,12 +450,12 @@ class JsonComparatorTest {
Expected: {#date_time_format:iso_instant#}
got: some value
- """.trimIndent()
+ """.trimIndent(),
)
.forAll { actual, expected, error ->
compare(
actualJson = actual,
- expectedJson = expected
+ expectedJson = expected,
) {
assertAll {
assertThat(it.passed()).isFalse()
@@ -477,13 +470,11 @@ class JsonComparatorTest {
*/
@Nested
inner class ArrayWithSimpleValuesTest {
-
@Test
fun `should handle validators in arrays with simple values`() {
-
compare(
loadJson("array_with_simple_values/test_actual.json"),
- loadJson("array_with_simple_values/test_expected.json")
+ loadJson("array_with_simple_values/test_expected.json"),
) {
assertAll {
assertThat(it.passed()).isTrue()
@@ -494,7 +485,6 @@ class JsonComparatorTest {
@Test
fun `should throw an error if element count does not match between the two arrays`() {
-
compare(
// language=json
"""
@@ -513,7 +503,7 @@ class JsonComparatorTest {
"{#contains:value_#}"
]
}
- """.trimIndent()
+ """.trimIndent(),
) {
assertAll {
assertThat(it.passed()).isFalse()
@@ -524,7 +514,6 @@ class JsonComparatorTest {
@Test
fun `should throw a detailed error if some elements did not match`() {
-
compare(
// language=json
"""
@@ -549,7 +538,7 @@ class JsonComparatorTest {
"{#contains:value_#}"
]
}
- """.trimIndent()
+ """.trimIndent(),
) {
assertAll {
assertThat(it.passed()).isFalse()
@@ -562,7 +551,7 @@ class JsonComparatorTest {
some_array[2] -> {#uuid#} matched with: [[0] -> cd820a36-aa32-42ea-879d-293ba5f3c1e5,[4] -> 839ceac0-2e60-4405-b27c-db2ac753d809]
some_array[3] -> value_2 matched with: []
some_array[4] -> {#contains:value_#} matched with: [[3] -> value_3]
- """.trimIndent()
+ """.trimIndent(),
)
}
}
diff --git a/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/validator/ValidatorTemplateManagerTest.kt b/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/validator/ValidatorTemplateManagerTest.kt
index d7a9dee..814d4df 100644
--- a/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/validator/ValidatorTemplateManagerTest.kt
+++ b/jcv-core/src/test/kotlin/com/ekino/oss/jcv/core/validator/ValidatorTemplateManagerTest.kt
@@ -21,7 +21,6 @@ class ValidatorTemplateManagerTest {
@Test
fun `simple validator id extraction`() {
-
val manager = ValidatorTemplateManager("{#my_validator#}")
assertThat(manager.extractId()).isEqualTo("my_validator")
@@ -29,23 +28,20 @@ class ValidatorTemplateManagerTest {
@Test
fun `validator id extraction`() {
-
assertThat(defaultTemplateManager.extractId()).isEqualTo("my_validator")
}
@Test
fun `parameters extraction`() {
-
assertThat(defaultTemplateManager.extractParameters()).containsExactly(
"some ; param 1",
"and another one \\; ...",
- "and the last one"
+ "and the last one",
)
}
@Test
fun `parameter extraction by index`() {
-
val manager = defaultTemplateManager
assertAll {
diff --git a/jcv-hamcrest/build.gradle.kts b/jcv-hamcrest/build.gradle.kts
index cd3ef6d..12f4e11 100644
--- a/jcv-hamcrest/build.gradle.kts
+++ b/jcv-hamcrest/build.gradle.kts
@@ -1,10 +1,8 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
kotlin("jvm")
`java-library`
- signing
- id("com.ekino.oss.plugin.kotlin-quality")
+ id("org.jlleitschuh.gradle.ktlint")
+ id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
}
@@ -18,20 +16,17 @@ java {
withSourcesJar()
}
+kotlin {
+ jvmToolchain(11)
+}
+
val javadocJar by tasks.registering(Jar::class) {
dependsOn("dokkaHtml")
archiveClassifier.set("javadoc")
- from(buildDir.resolve("dokka"))
+ from(layout.buildDirectory.dir("dokka"))
}
tasks {
- withType {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8.toString()
- apiVersion = "1.3"
- }
- }
-
withType {
useJUnitPlatform()
jvmArgs("-Duser.language=en")
@@ -41,7 +36,7 @@ tasks {
dokkaSourceSets {
configureEach {
reportUndocumented = false
- jdkVersion = 8
+ jdkVersion = 11
}
}
}
@@ -52,34 +47,23 @@ tasks {
}
}
-val publicationName = "mavenJava"
-
publishing {
publications {
- named(publicationName) {
+ named("mavenJava") {
artifact(javadocJar.get())
from(components["java"])
}
}
}
-signing {
- sign(publishing.publications[publicationName])
-}
-
dependencies {
api(project(":jcv-core"))
- implementation(kotlin("stdlib-jdk8"))
- implementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
- implementation(group = "org.hamcrest", name = "hamcrest", version = "${prop("hamcrest.version")}")
-
- testImplementation(
- group = "org.junit.jupiter",
- name = "junit-jupiter",
- version = "${prop("junit-jupiter.version")}"
- )
+ implementation(kotlin("stdlib"))
+ implementation(libs.jsonassert)
+ implementation(libs.hamcrest)
- testImplementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
- testImplementation(group = "org.hamcrest", name = "hamcrest", version = "${prop("hamcrest.version")}")
- testImplementation(group = "commons-io", name = "commons-io", version = "${prop("commons-io.version")}")
+ testImplementation(libs.junit.jupiter)
+ testImplementation(libs.jsonassert)
+ testImplementation(libs.hamcrest)
+ testImplementation(libs.commons.io)
}
diff --git a/jcv-hamcrest/src/main/kotlin/com/ekino/oss/jcv/assertion/hamcrest/JsonCompareMatcher.kt b/jcv-hamcrest/src/main/kotlin/com/ekino/oss/jcv/assertion/hamcrest/JsonCompareMatcher.kt
index adee2a8..92603bf 100644
--- a/jcv-hamcrest/src/main/kotlin/com/ekino/oss/jcv/assertion/hamcrest/JsonCompareMatcher.kt
+++ b/jcv-hamcrest/src/main/kotlin/com/ekino/oss/jcv/assertion/hamcrest/JsonCompareMatcher.kt
@@ -21,7 +21,6 @@ class JsonCompareMatcher(private val jsonComparator: JSONComparator, private val
private var result: JSONCompareResult? = null
override fun describeTo(description: Description) {
-
description.appendText(result?.message ?: "A valid JSON")
}
diff --git a/jcv-wiremock/build.gradle.kts b/jcv-wiremock/build.gradle.kts
index 10e4191..470cb18 100644
--- a/jcv-wiremock/build.gradle.kts
+++ b/jcv-wiremock/build.gradle.kts
@@ -1,10 +1,8 @@
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
kotlin("jvm")
`java-library`
- signing
- id("com.ekino.oss.plugin.kotlin-quality")
+ id("org.jlleitschuh.gradle.ktlint")
+ id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
}
@@ -18,20 +16,17 @@ java {
withSourcesJar()
}
+kotlin {
+ jvmToolchain(11)
+}
+
val javadocJar by tasks.registering(Jar::class) {
dependsOn("dokkaHtml")
archiveClassifier.set("javadoc")
- from(buildDir.resolve("dokka"))
+ from(layout.buildDirectory.dir("dokka"))
}
tasks {
- withType {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8.toString()
- apiVersion = "1.3"
- }
- }
-
withType {
useJUnitPlatform()
jvmArgs("-Duser.language=en")
@@ -41,7 +36,7 @@ tasks {
dokkaSourceSets {
configureEach {
reportUndocumented = false
- jdkVersion = 8
+ jdkVersion = 11
}
}
}
@@ -52,41 +47,26 @@ tasks {
}
}
-val publicationName = "mavenJava"
-
publishing {
publications {
- named(publicationName) {
+ named("mavenJava") {
artifact(javadocJar.get())
from(components["java"])
}
}
}
-signing {
- sign(publishing.publications[publicationName])
-}
-
dependencies {
api(project(":jcv-core"))
- implementation(kotlin("stdlib-jdk8"))
- implementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
- implementation(group = "com.github.tomakehurst", name = "wiremock-jre8", version = "${prop("wiremock.version")}")
-
- testImplementation(
- group = "org.junit.jupiter",
- name = "junit-jupiter",
- version = "${prop("junit-jupiter.version")}"
- )
+ implementation(kotlin("stdlib"))
+ implementation(libs.jsonassert)
+ implementation(libs.wiremock)
- testImplementation(group = "org.skyscreamer", name = "jsonassert", version = "${prop("jsonassert.version")}")
- testImplementation(
- group = "com.willowtreeapps.assertk",
- name = "assertk-jvm",
- version = "${prop("assertk-jvm.version")}"
- ) {
+ testImplementation(libs.junit.jupiter)
+ testImplementation(libs.jsonassert)
+ testImplementation(libs.assertk) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
}
- testImplementation(group = "com.github.tomakehurst", name = "wiremock-jre8", version = "${prop("wiremock.version")}")
- testImplementation("io.github.rybalkinsd:kohttp-jackson:0.12.0")
+ testImplementation(libs.wiremock)
+ testImplementation(libs.kohttp.jackson)
}
diff --git a/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPattern.kt b/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPattern.kt
index 43601d9..e0f7286 100644
--- a/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPattern.kt
+++ b/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPattern.kt
@@ -17,12 +17,11 @@ class EqualToJcvPattern(
@JsonProperty("ignoreArrayOrder")
val ignoreArrayOrder: Boolean? = null,
@JsonProperty("ignoreExtraElements")
- val ignoreExtraElements: Boolean? = null
+ val ignoreExtraElements: Boolean? = null,
) : StringValuePattern(json) {
override fun match(value: String?): MatchResult {
-
- if (value == null || value.isBlank()) {
+ if (value.isNullOrBlank()) {
return MatchResult.noMatch()
}
@@ -49,7 +48,7 @@ class EqualToJcvPattern(
}
private fun buildJsonComparator(): JsonComparator {
- val jsonCompareMode = JSONCompareMode.values()
+ val jsonCompareMode = JSONCompareMode.entries
.find { it.isExtensible == (ignoreExtraElements ?: false) && it.hasStrictOrder() == !(ignoreArrayOrder ?: false) }
?: throw IllegalArgumentException("Cannot find json compare mode for ignoreExtraElements=$ignoreExtraElements and ignoreArrayOrder=$ignoreArrayOrder")
return JsonComparator(jsonCompareMode, defaultValidators())
@@ -63,11 +62,12 @@ class EqualToJcvPattern(
private fun toMatchResult(actual: Int, maxDistance: Int): MatchResult = object : MatchResult() {
override fun isExactMatch(): Boolean = actual == 0
+
override fun getDistance(): Double = actual.toDouble() / maxDistance.toDouble()
}
private fun JSONCompareResult.getDistance(): Int {
- val fieldErrors = listOfNotNull(fieldFailures, fieldMissing, fieldUnexpected).sumBy { it.count() }
+ val fieldErrors = listOfNotNull(fieldFailures, fieldMissing, fieldUnexpected).sumOf { it.count() }
return fieldErrors + if (failed() && fieldErrors == 0) 1 else 0
}
diff --git a/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtension.kt b/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtension.kt
index 5d9ff90..b558b0d 100644
--- a/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtension.kt
+++ b/jcv-wiremock/src/main/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtension.kt
@@ -20,13 +20,13 @@ class JcvRequestMatcherExtension : RequestMatcherExtension() {
fun toParameters(
json: String,
ignoreArrayOrder: Boolean = false,
- ignoreExtraElements: Boolean = false
+ ignoreExtraElements: Boolean = false,
): Parameters = Parameters.from(
mapOf(
PARAM_EXPECTED_JSON_NAME to json,
PARAM_IGNORE_ARRAY_ORDER_NAME to ignoreArrayOrder,
- PARAM_IGNORE_EXTRA_ELEMENTS_NAME to ignoreExtraElements
- )
+ PARAM_IGNORE_EXTRA_ELEMENTS_NAME to ignoreExtraElements,
+ ),
)
@JvmStatic
@@ -34,7 +34,7 @@ class JcvRequestMatcherExtension : RequestMatcherExtension() {
fun toRequestMatcher(
json: String,
ignoreArrayOrder: Boolean = false,
- ignoreExtraElements: Boolean = false
+ ignoreExtraElements: Boolean = false,
): ValueMatcher = ValueMatcher { request ->
val body = request.bodyAsString
?.takeIf { it.isNotBlank() }
@@ -42,7 +42,7 @@ class JcvRequestMatcherExtension : RequestMatcherExtension() {
return@ValueMatcher EqualToJcvPattern(
json = json,
ignoreArrayOrder = ignoreArrayOrder,
- ignoreExtraElements = ignoreExtraElements
+ ignoreExtraElements = ignoreExtraElements,
)
.match(body)
}
@@ -54,7 +54,7 @@ class JcvRequestMatcherExtension : RequestMatcherExtension() {
return toRequestMatcher(
json = parameters.getJsonAsString(PARAM_EXPECTED_JSON_NAME),
ignoreArrayOrder = parameters.getBoolean(PARAM_IGNORE_ARRAY_ORDER_NAME, false),
- ignoreExtraElements = parameters.getBoolean(PARAM_IGNORE_EXTRA_ELEMENTS_NAME, false)
+ ignoreExtraElements = parameters.getBoolean(PARAM_IGNORE_EXTRA_ELEMENTS_NAME, false),
)
.match(request)
}
diff --git a/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPatternTest.kt b/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPatternTest.kt
index f664b14..283ca8c 100644
--- a/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPatternTest.kt
+++ b/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/EqualToJcvPatternTest.kt
@@ -31,7 +31,7 @@ class EqualToJcvPatternTest {
"three": 3,
"four": 4
}
- """
+ """,
)
.transform { it.distance }
.isZero()
@@ -55,7 +55,7 @@ class EqualToJcvPatternTest {
"three": 7,
"four": 8
}
- """
+ """,
)
.transform { it.distance }
.isEqualTo(0.5)
@@ -74,7 +74,7 @@ class EqualToJcvPatternTest {
}
""" equalToJcv """
[1, 2, 3]
- """
+ """,
)
.transform { it.distance }
.isEqualTo(1.0)
@@ -93,7 +93,7 @@ class EqualToJcvPatternTest {
}
""" equalToJcv """
{}
- """
+ """,
)
.transform { it.distance }
.isEqualTo(1.0)
@@ -112,7 +112,7 @@ class EqualToJcvPatternTest {
}
""" equalToJcv """
[]
- """
+ """,
)
.transform { it.distance }
.isEqualTo(1.0)
@@ -131,7 +131,7 @@ class EqualToJcvPatternTest {
"three": 3,
"four": 4
}
- """
+ """,
)
.transform { it.distance }
.isEqualTo(1.0)
@@ -150,7 +150,7 @@ class EqualToJcvPatternTest {
"three": 3,
"four": 4
}
- """
+ """,
)
.transform { it.distance }
.isEqualTo(1.0)
@@ -186,7 +186,7 @@ class EqualToJcvPatternTest {
"four": "FOUR"
}
}
- """
+ """,
)
.transform { it.distance }
.isBetween(0.3, 0.4)
@@ -210,7 +210,7 @@ class EqualToJcvPatternTest {
"two": 2,
"four": 4
}
- """
+ """,
)
.transform { it.isExactMatch }
.isTrue()
@@ -224,7 +224,7 @@ class EqualToJcvPatternTest {
[1, 2, 3, 4]
""" equalToJcv """
[1, 3, 2, 4]
- """
+ """,
)
.transform { it.isExactMatch }
.isFalse()
@@ -240,7 +240,7 @@ class EqualToJcvPatternTest {
"""
[1, 3, 2, 4]
"""
- }
+ },
)
.transform { it.isExactMatch }
.isTrue()
@@ -282,7 +282,7 @@ class EqualToJcvPatternTest {
]
}
"""
- }
+ },
)
.transform { it.isExactMatch }
.isTrue()
@@ -310,7 +310,7 @@ class EqualToJcvPatternTest {
"six": 6
}
"""
- }
+ },
)
.transform { it.isExactMatch }
.isTrue()
@@ -346,7 +346,7 @@ class EqualToJcvPatternTest {
"six": 6
}
"""
- }
+ },
)
.transform { it.isExactMatch }
.isTrue()
@@ -372,7 +372,7 @@ class EqualToJcvPatternTest {
}
}
}
- """
+ """,
)
.transform { it.isExactMatch }
.isFalse()
@@ -428,7 +428,7 @@ class EqualToJcvPatternTest {
//language=XML
"""
- """
+ """,
)
assertThat(result.isExactMatch).isFalse()
assertThat(result.distance).isEqualTo(1.0)
@@ -468,7 +468,7 @@ class EqualToJcvPatternTest {
}
]
}
- """
+ """,
)
.transform { it.isExactMatch }
.isFalse()
@@ -505,7 +505,7 @@ class EqualToJcvPatternTest {
"four": 4
}
]
- """
+ """,
)
.transform { it.isExactMatch }
.isFalse()
@@ -526,7 +526,7 @@ class EqualToJcvPatternTest {
"name": "BBB",
"addresses": []
}
- """
+ """,
)
.transform { it.isExactMatch }
.isFalse()
@@ -555,7 +555,7 @@ class EqualToJcvPatternTest {
"addresses": []
}
"""
- }
+ },
)
.transform { it.isExactMatch }
.isFalse()
@@ -584,7 +584,7 @@ class EqualToJcvPatternTest {
"addresses": {}
}
"""
- }
+ },
)
.transform { it.isExactMatch }
.isFalse()
@@ -600,7 +600,7 @@ class EqualToJcvPatternTest {
"""
["a","b", "d","c","e","f","g","h"]
"""
- }
+ },
)
.transform { it.isExactMatch }
.isTrue()
@@ -650,7 +650,7 @@ class EqualToJcvPatternTest {
]
}
"""
- }
+ },
)
.transform { it.isExactMatch }
.isTrue()
@@ -662,6 +662,6 @@ private infix fun String.equalToJcv(actual: String?) = this.equalToJcv { actual
private fun String.equalToJcv(ignoreArrayOrder: Boolean? = null, ignoreExtraElements: Boolean? = null, actual: () -> String?) = EqualToJcvPattern(
json = this,
ignoreArrayOrder = ignoreArrayOrder,
- ignoreExtraElements = ignoreExtraElements
+ ignoreExtraElements = ignoreExtraElements,
)
.match(actual())
diff --git a/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtensionTest.kt b/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtensionTest.kt
index 506a624..b0c812c 100644
--- a/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtensionTest.kt
+++ b/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/JcvRequestMatcherExtensionTest.kt
@@ -5,19 +5,19 @@ import assertk.assertions.isEqualTo
import assertk.assertions.isTrue
import com.github.tomakehurst.wiremock.http.ContentTypeHeader
import com.github.tomakehurst.wiremock.http.Cookie
+import com.github.tomakehurst.wiremock.http.FormParameter
import com.github.tomakehurst.wiremock.http.HttpHeader
import com.github.tomakehurst.wiremock.http.HttpHeaders
import com.github.tomakehurst.wiremock.http.QueryParameter
import com.github.tomakehurst.wiremock.http.Request
import com.github.tomakehurst.wiremock.http.RequestMethod
-import com.google.common.base.Optional
import org.junit.jupiter.api.Test
+import java.util.Optional
class JcvRequestMatcherExtensionTest {
@Test
fun `should create parameters from extension utils`() {
-
// Given
val json =
//language=JSON
@@ -31,7 +31,7 @@ class JcvRequestMatcherExtensionTest {
val parameters = JcvRequestMatcherExtension.toParameters(
json,
ignoreArrayOrder = ignoreArrayOrder,
- ignoreExtraElements = ignoreExtraElements
+ ignoreExtraElements = ignoreExtraElements,
)
// Then
@@ -42,7 +42,6 @@ class JcvRequestMatcherExtensionTest {
@Test
fun `should create value matcher from extension utils`() {
-
// Given
val json =
//language=JSON
@@ -56,7 +55,7 @@ class JcvRequestMatcherExtensionTest {
val valueMatcher = JcvRequestMatcherExtension.toRequestMatcher(
json,
ignoreArrayOrder = ignoreArrayOrder,
- ignoreExtraElements = ignoreExtraElements
+ ignoreExtraElements = ignoreExtraElements,
)
// Then
@@ -136,6 +135,14 @@ class JcvRequestMatcherExtensionTest {
throw UnsupportedOperationException()
}
+ override fun formParameter(p0: String?): FormParameter {
+ throw UnsupportedOperationException()
+ }
+
+ override fun formParameters(): MutableMap {
+ throw UnsupportedOperationException()
+ }
+
override fun getBody(): ByteArray = bodyAsString.toByteArray()
override fun getBodyAsString(): String = stringBodyProvider()
@@ -163,6 +170,10 @@ class JcvRequestMatcherExtensionTest {
override fun getOriginalRequest(): Optional {
throw UnsupportedOperationException()
}
+
+ override fun getProtocol(): String {
+ throw UnsupportedOperationException()
+ }
}
}
}
diff --git a/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/WireMockEqualToJcvExtensionTest.kt b/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/WireMockEqualToJcvExtensionTest.kt
index 3057365..083bdfd 100644
--- a/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/WireMockEqualToJcvExtensionTest.kt
+++ b/jcv-wiremock/src/test/kotlin/com/ekino/oss/jcv/assertion/wiremock/WireMockEqualToJcvExtensionTest.kt
@@ -27,7 +27,7 @@ private val wireMockServer by lazy {
WireMockConfiguration()
.dynamicPort()
.extensions(JcvRequestMatcherExtension())
- .usingFilesUnderClasspath("src/test/resources/wiremock/config")
+ .usingFilesUnderClasspath("src/test/resources/wiremock/config"),
)
}
@@ -79,7 +79,7 @@ class WireMockEqualToJcvExtensionTest {
"field_2": "fa04e3fc-1e14-43e1-9097-d7817755435e"
}
""".trimIndent(),
- 200
+ 200,
),
Arguments.of(
defaultExpectedJson,
@@ -90,8 +90,8 @@ class WireMockEqualToJcvExtensionTest {
"field_2": "non uuid value"
}
""".trimIndent(),
- 404
- )
+ 404,
+ ),
)
@Suppress("unused")
@@ -105,7 +105,7 @@ class WireMockEqualToJcvExtensionTest {
"field_2": "fa04e3fc-1e14-43e1-9097-d7817755435e"
}
""".trimIndent(),
- 200
+ 200,
),
Arguments.of(
//language=JSON
@@ -115,8 +115,8 @@ class WireMockEqualToJcvExtensionTest {
"field_2": "non uuid value"
}
""".trimIndent(),
- 404
- )
+ 404,
+ ),
)
}
@@ -135,20 +135,20 @@ class WireMockEqualToJcvExtensionTest {
fun `should use 'equalToJcv' request matcher via code config`(
expectedJson: String,
actualJson: String,
- expectedResponseCode: Int
+ expectedResponseCode: Int,
) {
val targetPath = "/via_code/test"
wireMockServer.stubFor(
post(urlEqualTo(targetPath))
.andMatching(
- JcvRequestMatcherExtension.toRequestMatcher(json = expectedJson)
+ JcvRequestMatcherExtension.toRequestMatcher(json = expectedJson),
)
.willReturn(
aResponse()
.withHeader("Content-Type", "text/plain")
.withStatus(200)
- .withBody("OK")
- )
+ .withBody("OK"),
+ ),
)
@Suppress("unused")
@@ -161,7 +161,7 @@ class WireMockEqualToJcvExtensionTest {
@MethodSource("viaFileDataProvider")
fun `should use 'equalToJcv' request matcher via file config`(
actualJson: String,
- expectedResponseCode: Int
+ expectedResponseCode: Int,
) {
val targetPath = "/via_file/test"