diff --git a/.env b/.env index 7749e97..a913c60 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -CONFLUENT_KAFKA_VERSION=7.2.11 \ No newline at end of file +CONFLUENT_KAFKA_VERSION=7.9.2 \ No newline at end of file diff --git a/.github/workflows/docker-contrib.yml b/.github/workflows/docker-contrib.yml index 9b5c188..bc5257a 100644 --- a/.github/workflows/docker-contrib.yml +++ b/.github/workflows/docker-contrib.yml @@ -23,19 +23,19 @@ jobs: id-token: write steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache # https://github.com/docker/build-push-action - name: Setup Docker Buildx - uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 # Build locally Docker image with Buildx # https://github.com/docker/build-push-action - name: Docker build with unit tests id: build-and-test - uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: . load: true diff --git a/.github/workflows/docker-publish-when-release.yml b/.github/workflows/docker-publish-when-release.yml index 236da19..47fa8ec 100644 --- a/.github/workflows/docker-publish-when-release.yml +++ b/.github/workflows/docker-publish-when-release.yml @@ -11,6 +11,10 @@ on: # Publish semver tags as releases. tags: [ 'v*.*.*' ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ !contains(github.ref, 'refs/tags/') }} + env: ORIGIN_REPOSITORY: lectra-tech/kapoeira # Dockerhub @@ -32,7 +36,7 @@ jobs: id-token: write steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Detect a forked repository if: ${{ github.repository != env.ORIGIN_REPOSITORY }} @@ -46,21 +50,19 @@ jobs: # https://github.com/sigstore/cosign-installer - name: Install Cosign if: ${{ github.repository == env.ORIGIN_REPOSITORY }} - uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0 - with: - cosign-release: 'v2.4.0' + uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0 # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache # https://github.com/docker/setup-buildx-action - name: Setup Docker Buildx - uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 + uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | @@ -70,7 +72,7 @@ jobs: # https://github.com/docker/build-push-action - name: Docker build with unit tests id: build-and-test - uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: . load: true @@ -94,7 +96,7 @@ jobs: # Login against a Docker registry # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 with: registry: ${{ env.REGISTRY }} username: ${{ env.REGISTRY_USERNAME }} @@ -105,7 +107,7 @@ jobs: - name: Docker build for many platforms and push into ${{ env.REGISTRY }} if: ${{ contains(github.ref, 'refs/tags/') }} id: build-and-push - uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: . platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/nexus-release.yml b/.github/workflows/nexus-release.yml index 28935de..cef23a8 100644 --- a/.github/workflows/nexus-release.yml +++ b/.github/workflows/nexus-release.yml @@ -2,14 +2,12 @@ name: Release on: workflow_dispatch: push: - branches: - - 'feat/**' #publish snapshots - - 'main' #also publish snapshots - useful before releasing tags: - '**' #publish a release + jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 env: PGP_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} PGP_SECRET : ${{ secrets.GPG_SECRET }} @@ -17,14 +15,16 @@ jobs: SONATYPE_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.NEXUS_USERNAME }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: 0 - - uses: actions/setup-java@v4 + - uses: actions/setup-java@v5 with: distribution: temurin java-version: 21 cache: sbt + - name: Setup sbt launcher + uses: sbt/setup-sbt@v1 - name: Tests run: sbt test - name: Configure GPG Key diff --git a/Dockerfile b/Dockerfile index 47a9416..70936e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,13 @@ -FROM eclipse-temurin:21.0.4_7-jdk AS builder +FROM eclipse-temurin:25.0.1_8-jdk AS builder -ENV SCALA_VERSION=2.13.14 -ENV SBT_VERSION=1.10.1 +ENV SCALA_VERSION=2.13.17 +ENV SBT_VERSION=1.11.6 # Install tools... +RUN apt-get update && apt-get -y upgrade && apt-get -y install curl WORKDIR /opt/tools # scala -RUN curl -fsL https://downloads.typesafe.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz | tar xfz - -C . +RUN curl -fsL https://github.com/scala/scala/releases/download/v${SCALA_VERSION}/scala-${SCALA_VERSION}.tgz | tar xfz - -C . # sbt RUN curl -fsL https://github.com/sbt/sbt/releases/download/v${SBT_VERSION}/sbt-${SBT_VERSION}.tgz | tar xfz - -C . @@ -19,7 +20,7 @@ RUN javac -version RUN java -version RUN scalac -version RUN scala -version -RUN sbt -v sbtVersion -Dsbt.rootdir=true +RUN sbt -v sbtVersion -Dsbt.rootdir=true --allow-empty RUN chmod -R 777 /tmp WORKDIR /root @@ -30,10 +31,10 @@ RUN sbt update COPY .git .git COPY src/ ./src/ RUN sbt clean coverageOn test coverageReport coverageOff -RUN sbt "set assembly / test := {}" assembly +RUN sbt assembly RUN sbt dependencyUpdatesReport -FROM eclipse-temurin:21.0.4_7-jre AS release +FROM eclipse-temurin:25.0.1_8-jre AS release ENV KAFKA_BOOTSTRAP_SERVERS="localhost:9092" ENV KAFKA_USERNAME="" ENV KAFKA_PASSWORD="" diff --git a/README.adoc b/README.adoc index 1dfe4c9..fe4cdb7 100644 --- a/README.adoc +++ b/README.adoc @@ -524,6 +524,7 @@ Then expected records | topic_out | key1 | aValue | And assert aValue $.foo == "fooString" And assert aValue $.fooInt == 42 + And assert aValue $.fooDouble == 12.0038 +- 1E-4 And assert aValue $.foos has size 3 And assert aValue $.foos == ["item1","item2","item3"] And assert aValue $ match object {"foos":["item1","item2","item3"],"bar":{"baz":["item1","item2","item3"]}} diff --git a/build.sbt b/build.sbt index 839b1c0..81550ed 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,4 @@ -import xerial.sbt.Sonatype.{sonatypeCentralHost, sonatypeLegacy} - -ThisBuild / scalaVersion := "2.13.14" +ThisBuild / scalaVersion := "2.13.18" ThisBuild / organization := "com.lectra" ThisBuild / organizationName := "lectra" ThisBuild / licenses += "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt") @@ -12,50 +10,47 @@ ThisBuild / scmInfo := Some( "scm:git:git@github.com/lectra-tech/kapoeira.git" ) ) -//ThisBuild / sonatypeCredentialHost := sonatypeCentralHost -ThisBuild / sonatypeCredentialHost := "oss.sonatype.org" -ThisBuild / sonatypeRepository := "https://oss.sonatype.org/service/local" ThisBuild / versionScheme := Some("semver-spec") ThisBuild / homepage := Some(url("https://github.com/lectra-tech/kapoeira")) ThisBuild / developers := List( - Developer( "jvauchel", "Johanna Vauchel", "j.vauchel@lectra.com", url("https://github.com/jvauchel") ), - Developer("ThomasLegoahec", "Thomas Legoahec","t.legoahec@lectra.com",url("https://github.com/ThomasLegoahec")), + Developer("jvauchel", "Johanna Vauchel", "j.vauchel@lectra.com", url("https://github.com/jvauchel")), Developer("sebastienvidal", "Sébastien Vidal","s.vidal@lectra.com",url("https://github.com/sebastienvidal")), - Developer( "mrebiai", "Mehdi Rebiai", "m.rebiai@lectra.com", url("https://github.com/mrebiai") ), - Developer( "scarisey", "Sylvain Carisey", "s.carisey@lectra.com", url("https://github.com/scarisey") ), + Developer("mrebiai", "Mehdi Rebiai", "m.rebiai@lectra.com", url("https://github.com/mrebiai")), + Developer("scarisey", "Sylvain Carisey", "s.carisey@lectra.com", url("https://github.com/scarisey")), ) resolvers += "confluent" at "https://packages.confluent.io/maven/" -val zioVersion = "2.1.9" +val zioVersion = "2.1.23" lazy val root = (project in file(".")) .settings( name := "kapoeira", // assembly assembly / assemblyJarName := "kapoeira.jar", + assembly / test := {}, assembly / mainClass := Some("io.cucumber.core.cli.Main"), // confluent - libraryDependencies += "io.confluent" % "kafka-avro-serializer" % "7.2.12" exclude("javax.ws.rs", "javax.ws.rs-api"), - libraryDependencies += "io.confluent" % "kafka-json-schema-serializer" % "7.2.12" exclude("javax.ws.rs", "javax.ws.rs-api"), + libraryDependencies += "io.confluent" % "kafka-avro-serializer" % "7.9.5" exclude("javax.ws.rs", "javax.ws.rs-api"), + libraryDependencies += "io.confluent" % "kafka-json-schema-serializer" % "7.9.5" exclude("javax.ws.rs", "javax.ws.rs-api"), // more libs to include // https://github.com/confluentinc/schema-registry/blob/master/pom.xml libraryDependencies ++= Seq( - "org.apache.kafka" %% "kafka" % "3.2.3", - "io.cucumber" %% "cucumber-scala" % "8.23.1", + "org.apache.kafka" %% "kafka" % "3.9.1", + "io.cucumber" %% "cucumber-scala" % "8.38.0", "org.scalatest" %% "scalatest" % "3.2.19", - "com.typesafe" % "config" % "1.4.3", - "io.gatling" % "gatling-jsonpath" % "3.12.0", - "com.lihaoyi" %% "os-lib" % "0.10.7", - "ch.qos.logback" % "logback-classic" % "1.5.8" % Runtime, + "com.typesafe" % "config" % "1.4.5", + "io.gatling" % "gatling-jsonpath" % "3.14.9", + "com.lihaoyi" %% "os-lib" % "0.11.6", + "ch.qos.logback" % "logback-classic" % "1.5.22" % Runtime, "dev.zio" %% "zio" % zioVersion, "dev.zio" %% "zio-streams" % zioVersion, - "dev.zio" %% "zio-logging-slf4j2" % "2.3.1", + "dev.zio" %% "zio-logging-slf4j2" % "2.5.2", ), // only tests libraryDependencies ++= Seq( - "io.cucumber" % "cucumber-junit" % "7.19.0", - "org.scalamock" %% "scalamock" % "6.0.0", - "org.scalacheck" %% "scalacheck" % "1.18.1", + "io.cucumber" % "cucumber-junit" % "7.33.0", + "org.scalamock" %% "scalamock" % "7.5.2", + "org.scalacheck" %% "scalacheck" % "1.19.0", "dev.zio" %% "zio-test" % zioVersion, "dev.zio" %% "zio-test-sbt" % zioVersion ).map(_ % Test), @@ -66,11 +61,12 @@ lazy val root = (project in file(".")) ThisBuild / assemblyMergeStrategy := { case PathList(ps@_*) if ps.last == "module-info.class" => MergeStrategy.discard case "META-INF/io.netty.versions.properties" => MergeStrategy.first + case "META-INF/FastDoubleParser-NOTICE" => MergeStrategy.first case "kafka/kafka-version.properties" => MergeStrategy.first case "application.conf" => MergeStrategy.concat case "logback.xml" => MergeStrategy.first case x => - val oldStrategy = (assembly / assemblyMergeStrategy).value + val oldStrategy = (ThisBuild / assemblyMergeStrategy).value oldStrategy(x) } diff --git a/docs/headers/scala-header-comment.txt b/docs/headers/scala-header-comment.txt index 1de5cef..57537eb 100644 --- a/docs/headers/scala-header-comment.txt +++ b/docs/headers/scala-header-comment.txt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/project/build.properties b/project/build.properties index 23f7d97..a360cca 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.10.2 +sbt.version = 1.11.7 diff --git a/project/plugins.sbt b/project/plugins.sbt index 22e60f7..d85aa88 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.0") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.4.3") addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.6.1") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2") diff --git a/renovate.json b/renovate.json index 3d057d0..fddb4db 100644 --- a/renovate.json +++ b/renovate.json @@ -1,30 +1,45 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base", - "group:all", - ":gitSignOff" - ], - "vulnerabilityAlerts": { - "labels": [ - "security" - ] - }, - "schedule": [ - "before 9am on monday" - ], - "packageRules": [ - { - "matchPackagePrefixes": ["org.apache.kafka"], - "groupName": "kafka", - "allowedVersions": "<3.3", - "separateMajorMinor": false - }, - { - "matchPackagePrefixes": ["io.confluent"], - "groupName": "kafka", - "allowedVersions": "<7.3", - "separateMajorMinor": false - } + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base", + "group:all", + ":gitSignOff" + ], + "vulnerabilityAlerts": { + "labels": [ + "security" ] + }, + "schedule": [ + "* 0-4 * * 1-5" + ], + "automergeSchedule": [ + "* 6-9 * * 1-5" + ], + "packageRules": [ + { + "description": "Auto merge", + "matchUpdateTypes": ["major", "minor", "patch", "pin", "pinDigest", "digest"], + "automerge": true, + "automergeType": "pr" + }, + { + "description": "Kafka packages < 4.0", + "matchPackagePrefixes": [ + "org.apache.kafka" + ], + "groupName": "kafka", + "allowedVersions": "<4.0", + "separateMajorMinor": false + }, + { + "description": "Confluent packages < 8.0", + "matchPackagePrefixes": [ + "io.confluent" + ], + "groupName": "kafka", + "allowedVersions": "<8.0", + "separateMajorMinor": false + } + ] } \ No newline at end of file diff --git a/src/main/scala/com/lectra/kapoeira/Config.scala b/src/main/scala/com/lectra/kapoeira/Config.scala index b1d126b..8ef6185 100644 --- a/src/main/scala/com/lectra/kapoeira/Config.scala +++ b/src/main/scala/com/lectra/kapoeira/Config.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/AssertionContext.scala b/src/main/scala/com/lectra/kapoeira/domain/AssertionContext.scala index ca3eb70..e3af494 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/AssertionContext.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/AssertionContext.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/BackgroundContext.scala b/src/main/scala/com/lectra/kapoeira/domain/BackgroundContext.scala index 480c06c..16964ba 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/BackgroundContext.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/BackgroundContext.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/CallScript.scala b/src/main/scala/com/lectra/kapoeira/domain/CallScript.scala index cddb16c..b76c472 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/CallScript.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/CallScript.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/MergeMaps.scala b/src/main/scala/com/lectra/kapoeira/domain/MergeMaps.scala index 52efe8c..f4deec2 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/MergeMaps.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/MergeMaps.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/Record.scala b/src/main/scala/com/lectra/kapoeira/domain/Record.scala index cc42a3b..b95c19b 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/Record.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/Record.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/RecordRead.scala b/src/main/scala/com/lectra/kapoeira/domain/RecordRead.scala index 7ae6990..7a55780 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/RecordRead.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/RecordRead.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/Services.scala b/src/main/scala/com/lectra/kapoeira/domain/Services.scala index ba7b3e4..a40c2ce 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/Services.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/Services.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/TopicConfig.scala b/src/main/scala/com/lectra/kapoeira/domain/TopicConfig.scala index 78d445c..4ddba7a 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/TopicConfig.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/TopicConfig.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/WhenSteps.scala b/src/main/scala/com/lectra/kapoeira/domain/WhenSteps.scala index 30f948d..926e97e 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/WhenSteps.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/WhenSteps.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/functions/DefaultFunctionRepository.scala b/src/main/scala/com/lectra/kapoeira/domain/functions/DefaultFunctionRepository.scala index 830a9dc..b94594e 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/functions/DefaultFunctionRepository.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/functions/DefaultFunctionRepository.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/functions/Func.scala b/src/main/scala/com/lectra/kapoeira/domain/functions/Func.scala index 59380e4..cbba044 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/functions/Func.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/functions/Func.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/domain/functions/FunctionRepository.scala b/src/main/scala/com/lectra/kapoeira/domain/functions/FunctionRepository.scala index 496ef17..df4e18c 100644 --- a/src/main/scala/com/lectra/kapoeira/domain/functions/FunctionRepository.scala +++ b/src/main/scala/com/lectra/kapoeira/domain/functions/FunctionRepository.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/exception/AssertException.scala b/src/main/scala/com/lectra/kapoeira/exception/AssertException.scala index 603361c..77a5678 100644 --- a/src/main/scala/com/lectra/kapoeira/exception/AssertException.scala +++ b/src/main/scala/com/lectra/kapoeira/exception/AssertException.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/glue/Asserts.scala b/src/main/scala/com/lectra/kapoeira/glue/Asserts.scala index 44bcef7..d4a9a90 100644 --- a/src/main/scala/com/lectra/kapoeira/glue/Asserts.scala +++ b/src/main/scala/com/lectra/kapoeira/glue/Asserts.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,21 @@ object Asserts extends Matchers with LazyLogging { } ) + def approxEqual(assertionContext: AssertionContext, alias: String, jsonExpression: String, expected: String, approxRange: String):Assertion = + assertKafkaOutput( + assertionContext, + alias, + jsonExpression, + { actual => ( + for{ + x <- actual.double() + expected <- JsonExpr(expected).value.double() + approx <- JsonExpr(approxRange).value.double() + } yield{ x should equal ( expected +- approx ) } + ).fold(fail(s"${actual} equal ${expected} +- ${approxRange}"))(identity) + } + ) + def matchExactObject( assertionContext: AssertionContext, alias: String, @@ -150,6 +165,11 @@ object Asserts extends Matchers with LazyLogging { implicit class JsonNodeOps(val jsonNode: JsonNode) { + def double():Option[Double] ={ + val none = (_:Any) => Option.empty[Double] + jsonNode.fold(obj = none, arr = none, number = Some(_), strng = none, bln = none, bin = none, nullOrUndef = none) + } + def fold[T]( obj: JsonNode => T, arr: JsonNode => T, diff --git a/src/main/scala/com/lectra/kapoeira/glue/DataTableParser.scala b/src/main/scala/com/lectra/kapoeira/glue/DataTableParser.scala index 7617951..2443491 100644 --- a/src/main/scala/com/lectra/kapoeira/glue/DataTableParser.scala +++ b/src/main/scala/com/lectra/kapoeira/glue/DataTableParser.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/glue/FeaturesStepDefinitions.scala b/src/main/scala/com/lectra/kapoeira/glue/FeaturesStepDefinitions.scala index 7e00f60..9597c7c 100644 --- a/src/main/scala/com/lectra/kapoeira/glue/FeaturesStepDefinitions.scala +++ b/src/main/scala/com/lectra/kapoeira/glue/FeaturesStepDefinitions.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -176,7 +176,7 @@ class FeaturesStepDefinitions } // ASSERT - And("^assert\\s+(\\S+)\\s+(\\S+)\\s*==\\s*(.*)\\s*$") { + And("""^assert\s+(\S+)\s+(\S+)\s*==(?!\s+(?:[+-.eE0-9]+)\s+\+\-\s+(?:[+-.eE0-9]+)\s*)(?:\s*)(.*)(?:\s*)$""") { (alias: String, jsonExpression: String, expected: String) => logger.debug( s"Assert Step : (alias,jsonExpression,expected) ($alias,$jsonExpression,$expected)" @@ -226,6 +226,21 @@ class FeaturesStepDefinitions ) } + And("""^assert\s+(\S+)\s+(\$\S*)\s*==\s+([+-.eE0-9]+)\s+\+\-\s+([+-.eE0-9]+)\s*$""") { + (alias: String, jsonExpression: String, expectedJsonNumber: String,approximationJsonNumber:String) => + val interpolatedExpectedJson = + backgroundContext.substituteVariablesIn(expectedJsonNumber) + val interpolatedApproximationJson = + backgroundContext.substituteVariablesIn(approximationJsonNumber) + Asserts.approxEqual( + assertionContext, + alias, + jsonExpression, + interpolatedExpectedJson, + interpolatedApproximationJson + ) + } + And("^assert\\s+var\\s+(\\S+)\\s+(\\$\\S*)\\s+match\\s+object\\s+(.*)$") { (variableName: String, jsonExpression: String, expectedJson: String) => val interpolatedExpectedJson = diff --git a/src/main/scala/com/lectra/kapoeira/glue/FunctionManager.scala b/src/main/scala/com/lectra/kapoeira/glue/FunctionManager.scala index b299064..2e90a42 100644 --- a/src/main/scala/com/lectra/kapoeira/glue/FunctionManager.scala +++ b/src/main/scala/com/lectra/kapoeira/glue/FunctionManager.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/glue/package.scala b/src/main/scala/com/lectra/kapoeira/glue/package.scala index 05b6a29..feeba41 100644 --- a/src/main/scala/com/lectra/kapoeira/glue/package.scala +++ b/src/main/scala/com/lectra/kapoeira/glue/package.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/kafka/DataType.scala b/src/main/scala/com/lectra/kapoeira/kafka/DataType.scala index 313f164..81df660 100644 --- a/src/main/scala/com/lectra/kapoeira/kafka/DataType.scala +++ b/src/main/scala/com/lectra/kapoeira/kafka/DataType.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraAdmin.scala b/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraAdmin.scala index ee9420e..98904df 100644 --- a/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraAdmin.scala +++ b/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraAdmin.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraConsumer.scala b/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraConsumer.scala index 05b8f78..6ef00ca 100644 --- a/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraConsumer.scala +++ b/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraConsumer.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraProducer.scala b/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraProducer.scala index b1b40d8..9dbe1fe 100644 --- a/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraProducer.scala +++ b/src/main/scala/com/lectra/kapoeira/kafka/KapoeiraProducer.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/com/lectra/kapoeira/kafka/SchemaRegistry.scala b/src/main/scala/com/lectra/kapoeira/kafka/SchemaRegistry.scala index 08a9d92..3e93bef 100644 --- a/src/main/scala/com/lectra/kapoeira/kafka/SchemaRegistry.scala +++ b/src/main/scala/com/lectra/kapoeira/kafka/SchemaRegistry.scala @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2025 Lectra + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * License-Filename: LICENSE + */ package com.lectra.kapoeira.kafka import com.fasterxml.jackson.databind.JsonNode diff --git a/src/test/resources/application.conf b/src/test/resources/application.conf index 67696b6..540decd 100644 --- a/src/test/resources/application.conf +++ b/src/test/resources/application.conf @@ -4,4 +4,4 @@ kafka { basic.auth.credentials.source = "USER_INFO" basic.auth.user.info = "srUsername:srPassword" consumer.group.id = "kapoeira-test" -} \ No newline at end of file +} diff --git a/src/test/resources/features/assertions.feature b/src/test/resources/features/assertions.feature index b507bc3..e66cbba 100644 --- a/src/test/resources/features/assertions.feature +++ b/src/test/resources/features/assertions.feature @@ -19,10 +19,21 @@ Feature: assertions | topic_out | key1_${uuid} | aliasHeaders2.1 | value2.1 | | topic_out | key2_${uuid} | aliasHeaders2.2 | value2.2 | | topic_out | key3_${uuid} | aliasHeaders2.3 | value2.3 | + | topic_out | key4_${uuid} | aliasHeaders2.4 | value2.4 | And assert value2.1 $.qux == 42 And assert value2.2 $ has size 2 And assert value2.2 $ == [3,4] And assert value2.3 $ == "value2.3" + And assert value2.4 $.bar == "2020-09-09T10:49:25.871365100" + And assert value2.4 $.baz == "42.0 +- 0.1" + And assert value2.4 $.foo == 12.0038209653823934567890123456789 + And assert value2.4 $.foo == 12.0 +- 0.1 + And assert value2.4 $.foo == 12.1 +- 0.1 + And assert value2.4 $.foo == 12.0038 +- 1E-4 + And assert value2.4 $.foo == 12.0037 +- 1E-3 + And assert value2.4 $.foo == 12.0039 +- 1E-3 + And assert value2.4 $.foo == 12.003 +- 1E-3 + And assert value2.4 $.foo == 12.004 +- 1E-3 And assert aliasHeaders2.1 $ == {"foo":"bar","baz":"42"} And assert aliasHeaders2.1 $.foo == "bar" diff --git a/src/test/resources/features/records/keyheadersvalue.dat b/src/test/resources/features/records/keyheadersvalue.dat index ec2fdc5..17b2812 100644 --- a/src/test/resources/features/records/keyheadersvalue.dat +++ b/src/test/resources/features/records/keyheadersvalue.dat @@ -1,3 +1,4 @@ key1_${uuid}#{"qux":42}#{"foo":"bar","baz":42} key2_${uuid}#[3,4]#{"foo":"bar","baz":[1,2]} key3_${uuid}#value2.3#{"foo":"bar"} +key4_${uuid}#{"foo":12.0038209653823934567890123456789,"bar":"2020-09-09T10:49:25.871365100","baz":"42.0 +- 0.1"}#{"foo":"bar"} diff --git a/src/test/resources/features/scripts/externalEffectProducingToKafka.sh b/src/test/resources/features/scripts/externalEffectProducingToKafka.sh index 4835f81..791ae1f 100755 --- a/src/test/resources/features/scripts/externalEffectProducingToKafka.sh +++ b/src/test/resources/features/scripts/externalEffectProducingToKafka.sh @@ -2,7 +2,7 @@ SCRIPTNAME=$(basename "$0") RUNDIR=$(dirname "$(realpath $0)") -CP_IMAGE_NAME=confluentinc/cp-kafka-connect-base:7.2.11 +CP_IMAGE_NAME=confluentinc/cp-kafka-connect-base:7.9.2 function generateInput { local tmpFile=$1 diff --git a/src/test/scala/com/lectra/kapoeira/FeaturesTestRunner.scala b/src/test/scala/com/lectra/kapoeira/FeaturesTestRunner.scala index 2572456..0bbe87b 100644 --- a/src/test/scala/com/lectra/kapoeira/FeaturesTestRunner.scala +++ b/src/test/scala/com/lectra/kapoeira/FeaturesTestRunner.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/domain/AssertionContextTest.scala b/src/test/scala/com/lectra/kapoeira/domain/AssertionContextTest.scala index b6bbafb..c2b7475 100644 --- a/src/test/scala/com/lectra/kapoeira/domain/AssertionContextTest.scala +++ b/src/test/scala/com/lectra/kapoeira/domain/AssertionContextTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/domain/BackgroundContextTest.scala b/src/test/scala/com/lectra/kapoeira/domain/BackgroundContextTest.scala index bd77ed1..d918cf9 100644 --- a/src/test/scala/com/lectra/kapoeira/domain/BackgroundContextTest.scala +++ b/src/test/scala/com/lectra/kapoeira/domain/BackgroundContextTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/domain/MergeMapsSpec.scala b/src/test/scala/com/lectra/kapoeira/domain/MergeMapsSpec.scala index 3d6bb7f..83c9080 100644 --- a/src/test/scala/com/lectra/kapoeira/domain/MergeMapsSpec.scala +++ b/src/test/scala/com/lectra/kapoeira/domain/MergeMapsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/domain/WhenStepsSpec.scala b/src/test/scala/com/lectra/kapoeira/domain/WhenStepsSpec.scala index b00f56e..8d3d11a 100644 --- a/src/test/scala/com/lectra/kapoeira/domain/WhenStepsSpec.scala +++ b/src/test/scala/com/lectra/kapoeira/domain/WhenStepsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/glue/AssertsTest.scala b/src/test/scala/com/lectra/kapoeira/glue/AssertsTest.scala index dc863ab..b80d103 100644 --- a/src/test/scala/com/lectra/kapoeira/glue/AssertsTest.scala +++ b/src/test/scala/com/lectra/kapoeira/glue/AssertsTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,31 @@ class AssertsTest extends AnyFlatSpec with Matchers with MockFactory { behavior of "Asserts" + it should "assert approximatively equals on numbers" in { + val backgroundContext = mock[BackgroundContext] + val assertionContext = new AssertionContext(WhenStepsLive(backgroundContext, recordConsume, KapoeiraProducer.run _)) + val consumerRecord = + new ConsumerRecord("topic", 0, 0, "key", """{"foo": 12.003820965382393}""".getBytes.asInstanceOf[Any]) + val valueAlias = "valueAlias" + val keyValueRecord = KeyValueWithAliasesRecord("topic", "key", valueAlias) + (backgroundContext + .consumeTopic(_: String, _: Map[String, Int])(_: RecordConsumer)) + .expects(*, *, *) + .returning(Map("key" -> Seq(consumerRecord))) + val expectedConsumedRecords = List(keyValueRecord) + assertionContext.launchConsumption(expectedConsumedRecords) + + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.0038","0.0001" ) + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.0038","1E-4" ) + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.0037","1E-3" ) + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.0039","1E-3" ) + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.003","1E-3" ) + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.004","1E-3" ) + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.0","0.1" ) + Asserts.approxEqual(assertionContext, valueAlias, "$.foo", "12.1","0.1" ) + + } + it should "assert equality on literals" in { val backgroundContext = mock[BackgroundContext] val assertionContext = new AssertionContext(WhenStepsLive(backgroundContext, recordConsume, KapoeiraProducer.run _)) diff --git a/src/test/scala/com/lectra/kapoeira/glue/FunctionManagerTest.scala b/src/test/scala/com/lectra/kapoeira/glue/FunctionManagerTest.scala index d6f7e01..83f736b 100644 --- a/src/test/scala/com/lectra/kapoeira/glue/FunctionManagerTest.scala +++ b/src/test/scala/com/lectra/kapoeira/glue/FunctionManagerTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/glue/InterpolateTest.scala b/src/test/scala/com/lectra/kapoeira/glue/InterpolateTest.scala index 21419c8..4ab4f6f 100644 --- a/src/test/scala/com/lectra/kapoeira/glue/InterpolateTest.scala +++ b/src/test/scala/com/lectra/kapoeira/glue/InterpolateTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/glue/JsonNodeOpsTest.scala b/src/test/scala/com/lectra/kapoeira/glue/JsonNodeOpsTest.scala index 9bacb02..a8c73ef 100644 --- a/src/test/scala/com/lectra/kapoeira/glue/JsonNodeOpsTest.scala +++ b/src/test/scala/com/lectra/kapoeira/glue/JsonNodeOpsTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/glue/ReadHeadersTest.scala b/src/test/scala/com/lectra/kapoeira/glue/ReadHeadersTest.scala index a37fda2..d868088 100644 --- a/src/test/scala/com/lectra/kapoeira/glue/ReadHeadersTest.scala +++ b/src/test/scala/com/lectra/kapoeira/glue/ReadHeadersTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/com/lectra/kapoeira/glue/RecordReadTest.scala b/src/test/scala/com/lectra/kapoeira/glue/RecordReadTest.scala index 8d60c25..e38d584 100644 --- a/src/test/scala/com/lectra/kapoeira/glue/RecordReadTest.scala +++ b/src/test/scala/com/lectra/kapoeira/glue/RecordReadTest.scala @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Lectra + * Copyright (C) 2025 Lectra * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.