From 9604ee3633941ed9e42b76043f458e9a6b6475ac Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Thu, 27 Apr 2023 15:06:17 +0200 Subject: [PATCH 01/70] Update for next development version --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- examples/pom.xml | 2 +- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/jgiven/pom.xml | 2 +- extension/pom.xml | 2 +- extension/upcaster-test-core/pom.xml | 2 +- lib/fixtures/bankaccount/pom.xml | 2 +- lib/fixtures/giftcard/pom.xml | 2 +- lib/fixtures/pom.xml | 2 +- lib/pom.xml | 2 +- pom.xml | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index dcf332a..a56983e 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 83b8411..4b95cc9 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/pom.xml b/examples/pom.xml index 4c18ce7..e0e2b9e 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.0 + 4.7.4.1-SNAPSHOT examples diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index 5f21b79..dc9b97e 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/junit/pom.xml b/extension/jgiven/junit/pom.xml index f9f4977..3a7c815 100644 --- a/extension/jgiven/junit/pom.xml +++ b/extension/jgiven/junit/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index 5f9cbe1..8f93be8 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/pom.xml b/extension/jgiven/pom.xml index 8401d25..8c5efe8 100644 --- a/extension/jgiven/pom.xml +++ b/extension/jgiven/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.4.0 + 4.7.4.1-SNAPSHOT extension-jgiven diff --git a/extension/pom.xml b/extension/pom.xml index 6b7b72f..8d40a1c 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.0 + 4.7.4.1-SNAPSHOT extension diff --git a/extension/upcaster-test-core/pom.xml b/extension/upcaster-test-core/pom.xml index 0e71806..abfbfba 100644 --- a/extension/upcaster-test-core/pom.xml +++ b/extension/upcaster-test-core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing diff --git a/lib/fixtures/bankaccount/pom.xml b/lib/fixtures/bankaccount/pom.xml index 4b2a6f5..a43bdf0 100644 --- a/lib/fixtures/bankaccount/pom.xml +++ b/lib/fixtures/bankaccount/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index 0fa7f88..acb381c 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.4.0 + 4.7.4.1-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index 9725fa7..5ffdafa 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ lib - 4.7.4.0 + 4.7.4.1-SNAPSHOT fixtures diff --git a/lib/pom.xml b/lib/pom.xml index 671361d..ffdafa6 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.0 + 4.7.4.1-SNAPSHOT lib diff --git a/pom.xml b/pom.xml index 37f2505..6f50906 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.0 + 4.7.4.1-SNAPSHOT pom From 0fd01052bbfb80df2f24564fa36d5e40b31afee1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 23:01:50 +0200 Subject: [PATCH 02/70] chore(deps): bump maven-failsafe-plugin from 3.0.0 to 3.1.0 (#281) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6f50906..95fb3b3 100644 --- a/pom.xml +++ b/pom.xml @@ -268,7 +268,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.0.0 + 3.1.0 From a2ecced757e1d6b33f6acd71c3b518778b8288dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 23:02:24 +0200 Subject: [PATCH 03/70] chore(deps): bump maven-gpg-plugin from 3.0.1 to 3.1.0 (#280) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95fb3b3..e416365 100644 --- a/pom.xml +++ b/pom.xml @@ -376,7 +376,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.0.1 + 3.1.0 --batch From 52a6c258bae3773d6dd3033a3d47d9fdc9a99d31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 23:02:54 +0200 Subject: [PATCH 04/70] chore(deps): bump maven-surefire-plugin from 3.0.0 to 3.1.0 (#279) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e416365..de08daf 100644 --- a/pom.xml +++ b/pom.xml @@ -242,7 +242,7 @@ maven-surefire-plugin - 3.0.0 + 3.1.0 false kill From 36c242635e2d089f6075847689b94fbcc6f5a3f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 17:56:53 +0000 Subject: [PATCH 05/70] chore(deps): bump maven-assembly-plugin from 3.5.0 to 3.6.0 Bumps [maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.5.0 to 3.6.0. - [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.5.0...maven-assembly-plugin-3.6.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-assembly-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de08daf..c97f962 100644 --- a/pom.xml +++ b/pom.xml @@ -198,7 +198,7 @@ org.apache.maven.plugins maven-assembly-plugin - 3.5.0 + 3.6.0 assembly From dc77cb9be55dc559e03ffd5686cb7c5f6423743d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 May 2023 21:42:08 +0200 Subject: [PATCH 06/70] chore(deps-dev): bump jackson.version from 2.15.0 to 2.15.1 (#283) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de08daf..eda684b 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 1.2.5.0 - 2.15.0 + 2.15.1 4.13.2 5.9.3 2.1.4 From db3d3cebed5cfbdeb8a3b100cb49488a4911b3f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 May 2023 20:19:03 +0200 Subject: [PATCH 07/70] chore(deps): bump axon-bom from 4.7.3 to 4.7.4 (#284) Bumps [axon-bom](https://github.com/AxonFramework/axon-bom) from 4.7.3 to 4.7.4. - [Release notes](https://github.com/AxonFramework/axon-bom/releases) - [Commits](https://github.com/AxonFramework/axon-bom/compare/axon-4.7.3...axon-4.7.4) --- updated-dependencies: - dependency-name: org.axonframework:axon-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eda684b..ac5b21a 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 1.8.21 - 4.7.3 + 4.7.4 1.2.5 1.2.5.0 From 58db788ee3045aa3177bd80eeb240a5b7c205919 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 May 2023 20:01:30 +0200 Subject: [PATCH 08/70] chore(deps): bump maven-source-plugin from 3.2.1 to 3.3.0 (#285) Bumps [maven-source-plugin](https://github.com/apache/maven-source-plugin) from 3.2.1 to 3.3.0. - [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.2.1...maven-source-plugin-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-source-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ac5b21a..d697c3e 100644 --- a/pom.xml +++ b/pom.xml @@ -313,7 +313,7 @@ maven-source-plugin - 3.2.1 + 3.3.0 attach-sources From d4ad0fe3c05079c3cd4f9e9688cb75507320b2d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 May 2023 17:56:45 +0000 Subject: [PATCH 09/70] chore(deps): bump lombok from 1.18.26 to 1.18.28 Bumps [lombok](https://github.com/projectlombok/lombok) from 1.18.26 to 1.18.28. - [Release notes](https://github.com/projectlombok/lombok/releases) - [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown) - [Commits](https://github.com/projectlombok/lombok/compare/v1.18.26...v1.18.28) --- updated-dependencies: - dependency-name: org.projectlombok:lombok dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/fixtures/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index 5ffdafa..b1481b7 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -38,7 +38,7 @@ org.projectlombok lombok - 1.18.26 + 1.18.28 provided From 95f1bb15accbc78efc0a378ac3ac999da9e04319 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 20:26:03 +0200 Subject: [PATCH 10/70] chore(deps-dev): bump jackson.version from 2.15.1 to 2.15.2 (#288) Bumps `jackson.version` from 2.15.1 to 2.15.2. Updates `jackson-databind` from 2.15.1 to 2.15.2 - [Commits](https://github.com/FasterXML/jackson/commits) Updates `jackson-module-kotlin` from 2.15.1 to 2.15.2 - [Commits](https://github.com/FasterXML/jackson-module-kotlin/compare/jackson-module-kotlin-2.15.1...jackson-module-kotlin-2.15.2) Updates `jackson-datatype-jsr310` from 2.15.1 to 2.15.2 --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.module:jackson-module-kotlin dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d697c3e..0c6a638 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 1.2.5.0 - 2.15.1 + 2.15.2 4.13.2 5.9.3 2.1.4 From a3c14cd3d6cd214667a0fc6a768abb549f2f1322 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 21:25:41 +0200 Subject: [PATCH 11/70] chore(deps): bump gitflow-maven-plugin from 1.19.0 to 1.20.0 (#289) Bumps [gitflow-maven-plugin](https://github.com/aleksandr-m/gitflow-maven-plugin) from 1.19.0 to 1.20.0. - [Release notes](https://github.com/aleksandr-m/gitflow-maven-plugin/releases) - [Changelog](https://github.com/aleksandr-m/gitflow-maven-plugin/blob/master/CHANGELOG.md) - [Commits](https://github.com/aleksandr-m/gitflow-maven-plugin/compare/v1.19.0...v1.20.0) --- updated-dependencies: - dependency-name: com.amashchenko.maven.plugin:gitflow-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0c6a638..95b5a6f 100644 --- a/pom.xml +++ b/pom.xml @@ -354,7 +354,7 @@ com.amashchenko.maven.plugin gitflow-maven-plugin - 1.19.0 + 1.20.0 master From ba9c4c12c4430af8459bc5bd92c10221a0aa0b05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 20:02:36 +0200 Subject: [PATCH 12/70] chore(deps): bump maven-release-plugin from 3.0.0 to 3.0.1 (#291) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 95b5a6f..186f11a 100644 --- a/pom.xml +++ b/pom.xml @@ -210,7 +210,7 @@ maven-release-plugin - 3.0.0 + 3.0.1 forked-path true From 99abbc3869368c44f4cd92d5c3946871c4d99ee9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 12:28:23 +0200 Subject: [PATCH 13/70] chore(deps): bump dokka-maven-plugin from 1.8.10 to 1.8.20 (#290) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 186f11a..cef1b1a 100644 --- a/pom.xml +++ b/pom.xml @@ -275,7 +275,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.8.10 + 1.8.20 ${dokka.skip} From a4d033ed19c8913799ee6024f8c40e1273ba6448 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:57:37 +0200 Subject: [PATCH 14/70] chore(deps): bump maven-failsafe-plugin from 3.1.0 to 3.1.2 (#293) Bumps [maven-failsafe-plugin](https://github.com/apache/maven-surefire) from 3.1.0 to 3.1.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.0...surefire-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-failsafe-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cef1b1a..74373cb 100644 --- a/pom.xml +++ b/pom.xml @@ -268,7 +268,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.0 + 3.1.2 From d8767e37d7628be4700da742cda99212775376aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 19:58:11 +0200 Subject: [PATCH 15/70] chore(deps): bump maven-surefire-plugin from 3.1.0 to 3.1.2 (#292) Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.1.0 to 3.1.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.1.0...surefire-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 74373cb..f079347 100644 --- a/pom.xml +++ b/pom.xml @@ -242,7 +242,7 @@ maven-surefire-plugin - 3.1.0 + 3.1.2 false kill From e3dd95f9dd456f4bcf87770a8c093ff64b333edf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 17:58:50 +0000 Subject: [PATCH 16/70] chore(deps): bump kotlin.version from 1.8.21 to 1.8.22 Bumps `kotlin.version` from 1.8.21 to 1.8.22. Updates `kotlin-bom` from 1.8.21 to 1.8.22 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.8.22/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.21...v1.8.22) Updates `kotlin-maven-allopen` from 1.8.21 to 1.8.22 Updates `kotlin-maven-plugin` from 1.8.21 to 1.8.22 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f079347..4e69363 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 11 ${java.version} ${java.version} - 1.8.21 + 1.8.22 4.7.4 From 23a73af6d86c813f4ba640bee8c805455b9e163f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 16:00:38 +0200 Subject: [PATCH 17/70] chore(deps): bump logback-classic from 1.4.7 to 1.4.8 (#296) Bumps [logback-classic](https://github.com/qos-ch/logback) from 1.4.7 to 1.4.8. - [Commits](https://github.com/qos-ch/logback/compare/v_1.4.7...v_1.4.8) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index dc9b97e..e17f539 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -66,7 +66,7 @@ ch.qos.logback logback-classic - 1.4.7 + 1.4.8 test diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index 8f93be8..a405810 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -40,7 +40,7 @@ ch.qos.logback logback-classic - 1.4.7 + 1.4.8 test From ddf16ef66b066f2da18148b34918cd250f5d9a83 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:32:44 +0200 Subject: [PATCH 18/70] chore(deps): bump guava in /lib/fixtures/giftcard (#297) Bumps [guava](https://github.com/google/guava) from 31.1-jre to 32.0.0-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- lib/fixtures/giftcard/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index acb381c..70e6aac 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -20,7 +20,7 @@ com.google.guava guava - 31.1-jre + 32.0.0-jre From 1ee66bfd6136592541ba8d529289d52c19b78426 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:57:34 +0000 Subject: [PATCH 19/70] chore(deps-dev): bump mockito-core from 5.3.1 to 5.4.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 5.3.1 to 5.4.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.3.1...v5.4.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index a56983e..0f45af6 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -50,7 +50,7 @@ org.mockito mockito-core - 5.3.1 + 5.4.0 test From bb03583683d6a5db0746a03025edf227ba021eb6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:02:21 +0000 Subject: [PATCH 20/70] chore(deps): bump maven-clean-plugin from 3.2.0 to 3.3.1 Bumps [maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.2.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-clean-plugin/releases) - [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.2.0...maven-clean-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-clean-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4e69363..78afeb6 100644 --- a/pom.xml +++ b/pom.xml @@ -94,7 +94,7 @@ maven-clean-plugin - 3.2.0 + 3.3.1 From 53ac5694c3cd0ba2e3c444cf8179f4a3dbaede87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Jun 2023 17:24:27 +0000 Subject: [PATCH 21/70] chore(deps): bump axon-bom from 4.7.4 to 4.8.0 Bumps [axon-bom](https://github.com/AxonFramework/axon-bom) from 4.7.4 to 4.8.0. - [Release notes](https://github.com/AxonFramework/axon-bom/releases) - [Commits](https://github.com/AxonFramework/axon-bom/compare/axon-4.7.4...axon-4.8.0) --- updated-dependencies: - dependency-name: org.axonframework:axon-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 78afeb6..40da456 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 1.8.22 - 4.7.4 + 4.8.0 1.2.5 1.2.5.0 From 97d3a857eafedefb930b5224546b90317a3502be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jul 2023 10:25:47 +0200 Subject: [PATCH 22/70] chore(deps): bump guava from 32.0.0-jre to 32.1.1-jre (#301) --- lib/fixtures/giftcard/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index 70e6aac..eeefd16 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -20,7 +20,7 @@ com.google.guava guava - 32.0.0-jre + 32.1.1-jre From 8d3eae3dca1392bab77de8dd3763d1a5f454a2b4 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 4 Jul 2023 18:01:21 +0200 Subject: [PATCH 23/70] dependencies --- .github/release-notes.yml | 6 +- .github/workflows/development.yml | 28 ++--- .mvn/wrapper/maven-wrapper.properties | 6 +- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- extension/pom.xml | 2 +- extension/upcaster-test-core/pom.xml | 34 +++--- .../src/main/kotlin/UpcasterTestSupport.kt | 101 +++++++++++++++++- .../kotlin/AccountCreatedV0V1UpcasterTest.kt | 20 +--- .../src/test/kotlin/DummyUpcasterTest.kt | 94 ++++++++-------- pom.xml | 35 ++++-- 11 files changed, 199 insertions(+), 131 deletions(-) diff --git a/.github/release-notes.yml b/.github/release-notes.yml index 63ec6a6..2a430d8 100644 --- a/.github/release-notes.yml +++ b/.github/release-notes.yml @@ -1,7 +1,7 @@ - - changelog: sections: + - title: ":zap: Breaking Changes" + labels: [ "Type: breaking" ] - title: ":rocket: Enhancements & Features" labels: [ "Type: enhancement", "Type: documentation", "Type: example" ] - title: ":bug: Bug Fixes" @@ -13,4 +13,4 @@ changelog: labels: [ "Type: question" ] contributors: exclude: - names: [ "dependabot[bot]" ] + names: [ "dependabot[bot]", "codacy-badger" ] diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index ccc2b3c..4a2acb0 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -5,36 +5,22 @@ on: [ push ] jobs: build: runs-on: ubuntu-latest - name: Build and run tests on JDK 11 + name: Build and run tests steps: # Checkout the code - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Expose branch name run: echo ${{ github.ref }} - # Setup the cache - - name: Cache .m2 - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven - - # Get GPG private key into GPG -# - name: Import GPG Owner Trust -# run: echo ${{ secrets.GPG_OWNERTRUST }} | base64 --decode | gpg --import-ownertrust - -# - name: Import GPG key -# run: echo ${{ secrets.GPG_SECRET_KEYS }} | base64 --decode | gpg --import --no-tty --batch --yes - # Setup JDK and Maven - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 11.0.5 + distribution: 'zulu' + cache: maven server-id: ossrh server-username: OSS_CENTRAL_USERNAME # env variable for Maven Central server-password: OSS_CENTRAL_PASSWORD # env variable for Maven Central @@ -45,7 +31,7 @@ jobs: # Build - name: Build with Maven - run: ./mvnw clean verify -U -B -T4 + run: ./mvnw clean verify -U -B -T4 -ntp # # Publish snapshot # - name: Deploy a new snapshot to Maven Central diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 8c79a83..8e86bbe 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,14 @@ # to you 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 -# +# # http://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. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index 0f45af6..f10b3fe 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -38,7 +38,7 @@ org.slf4j slf4j-simple - 2.0.7 + 2.0.6 test diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 4b95cc9..a1e3e18 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -40,7 +40,7 @@ org.slf4j slf4j-simple - 2.0.7 + 2.0.6 test diff --git a/extension/pom.xml b/extension/pom.xml index 8d40a1c..38718bc 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -24,7 +24,7 @@ org.jetbrains.kotlin - kotlin-stdlib-jdk8 + kotlin-stdlib diff --git a/extension/upcaster-test-core/pom.xml b/extension/upcaster-test-core/pom.xml index abfbfba..e7aab5b 100644 --- a/extension/upcaster-test-core/pom.xml +++ b/extension/upcaster-test-core/pom.xml @@ -26,40 +26,30 @@ org.axonframework axon-configuration - - org.axonframework - axon-test - - - - org.dom4j - dom4j - ${dom4j.version} - - - com.fasterxml.jackson.core jackson-databind - ${jackson.version} - test com.fasterxml.jackson.module jackson-module-kotlin - ${jackson.version} - test com.fasterxml.jackson.datatype jackson-datatype-jsr310 - ${jackson.version} - test + + + org.dom4j + dom4j + ${dom4j.version} + + + - junit - junit - ${junit.version} + org.junit.jupiter + junit-jupiter + ${junit5.version} test @@ -72,7 +62,7 @@ org.slf4j slf4j-simple test - 2.0.7 + 2.0.6 diff --git a/extension/upcaster-test-core/src/main/kotlin/UpcasterTestSupport.kt b/extension/upcaster-test-core/src/main/kotlin/UpcasterTestSupport.kt index 4a48331..aee8619 100644 --- a/extension/upcaster-test-core/src/main/kotlin/UpcasterTestSupport.kt +++ b/extension/upcaster-test-core/src/main/kotlin/UpcasterTestSupport.kt @@ -1,5 +1,6 @@ package io.holixon.axon.testing.upcaster +import com.fasterxml.jackson.databind.JsonNode import org.axonframework.eventhandling.EventData import org.axonframework.messaging.MetaData import org.axonframework.serialization.Serializer @@ -7,11 +8,13 @@ import org.axonframework.serialization.SimpleSerializedObject import org.axonframework.serialization.SimpleSerializedType import org.axonframework.serialization.upcasting.event.InitialEventRepresentation import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation +import org.axonframework.serialization.upcasting.event.SingleEventUpcaster import org.dom4j.Document import org.dom4j.DocumentHelper import org.dom4j.io.SAXReader import java.io.StringReader import java.util.stream.Stream +import kotlin.reflect.KClass /** * Helper functions for upcaster tests. @@ -24,13 +27,19 @@ class UpcasterTestSupport { */ const val EMPTY_JSON = "{}" + /** + * Empty Document. + */ + val EMPTY_XML: Document = DocumentHelper.createDocument() + /** * Creates a stream containing a specified event as initial representation. * @param entry event serialized as data entry * */ @JvmStatic - fun initialEvent(entry: EventData, serializer: Serializer): Stream = Stream.of(InitialEventRepresentation(entry, serializer)) + fun initialEvent(entry: EventData, serializer: Serializer): Stream = + Stream.of(InitialEventRepresentation(entry, serializer)) /** @@ -44,6 +53,17 @@ class UpcasterTestSupport { fun jsonTestEventData(payloadJson: String, payloadTypeName: String, metaDataJson: String = EMPTY_JSON, revisionNumber: String? = null): EventData = testEventData(payloadJson, payloadTypeName, metaDataJson, revisionNumber) + /** + * Creates an event data object serialized as JSON. + * @param payloadJson JSON payload as string. + * @param metaDataJson JSON metadata as string. + * @param payloadType payload type represented as class. + * @param revisionNumber event revision. + */ + @JvmStatic + fun jsonTestEventData(payloadJson: String, payloadType: KClass<*>, metaDataJson: String = EMPTY_JSON, revisionNumber: String? = null): EventData = + testEventData(payloadJson, payloadType::class.java.name, metaDataJson, revisionNumber) + /** * Creates an event data object serialized as XML. * @param payloadDocument XML payload as Document. @@ -55,14 +75,13 @@ class UpcasterTestSupport { fun xmlTestEventData( payloadDocument: Document, payloadTypeName: String, - metaDataDocument: Document = DocumentHelper.createDocument(), + metaDataDocument: Document = EMPTY_XML, revisionNumber: String? = null ): EventData = testEventData(payloadDocument, payloadTypeName, metaDataDocument, revisionNumber) /** * Creates an event data object serialized as XML. * @param payloadDocument XML payload as String. - * @param metaDataDocument XML metadata as String. * @param payloadTypeName payload type name. * @param revisionNumber event revision. */ @@ -74,7 +93,7 @@ class UpcasterTestSupport { ): EventData = xmlTestEventData( payloadDocument = SAXReader().read(StringReader(payloadDocument)), payloadTypeName = payloadTypeName, - metaDataDocument = DocumentHelper.createDocument(), + metaDataDocument = EMPTY_XML, revisionNumber ) @@ -102,6 +121,80 @@ class UpcasterTestSupport { */ inline fun serializedObject(payload: T, payloadTypeName: String, revisionNumber: String?) = SimpleSerializedObject(payload, T::class.java, SimpleSerializedType(payloadTypeName, revisionNumber)) + + /** + * Creates a JSON upcaster operating on the JSON node using supplied upcast function. + * @param payloadTypeName type of the payload + * @param sourceRevision revision to upcast from. + * @param targetRevision revision to upcast to. + * @param upcastFunction function transforming the JSON. + */ + @JvmStatic + fun jsonNodeUpcaster(payloadTypeName: String, sourceRevision: String, targetRevision: String, upcastFunction: (JsonNode) -> JsonNode) = + object : SingleEventUpcaster() { + override fun canUpcast(representation: IntermediateEventRepresentation): Boolean = + representation.type.name == payloadTypeName && representation.type.revision == sourceRevision + + override fun doUpcast(intermediateRepresentation: IntermediateEventRepresentation): IntermediateEventRepresentation = + intermediateRepresentation.upcastPayload( + SimpleSerializedType(payloadTypeName, targetRevision), + JsonNode::class.java, + upcastFunction + ) + } + + /** + * Creates a JSON upcaster operating on the JSON node using supplied upcast function. + * @param payloadType type of the payload + * @param sourceRevision revision to upcast from. + * @param targetRevision revision to upcast to. + * @param upcastFunction function transforming the JSON. + */ + @JvmStatic + fun jsonNodeUpcaster(payloadType: KClass<*>, sourceRevision: String, targetRevision: String, upcastFunction: (JsonNode) -> JsonNode) = + jsonNodeUpcaster( + payloadTypeName = payloadType.java.name, + sourceRevision = sourceRevision, + targetRevision = targetRevision, + upcastFunction = upcastFunction + ) + + /** + * Creates an XML DOM4J Document upcaster operating on the Document using supplied upcast function. + * @param payloadTypeName type of the payload + * @param sourceRevision revision to upcast from. + * @param targetRevision revision to upcast to. + * @param upcastFunction function transforming the Document. + */ + @JvmStatic + fun xmlDocumentUpcaster(payloadTypeName: String, sourceRevision: String, targetRevision: String, upcastFunction: (Document) -> Document) = + object : SingleEventUpcaster() { + override fun canUpcast(representation: IntermediateEventRepresentation): Boolean = + representation.type.name == payloadTypeName && representation.type.revision == sourceRevision + + override fun doUpcast(intermediateRepresentation: IntermediateEventRepresentation): IntermediateEventRepresentation = + intermediateRepresentation.upcastPayload( + SimpleSerializedType(payloadTypeName, targetRevision), + Document::class.java, + upcastFunction + ) + } + + /** + * Creates an XML DOM4J Document upcaster operating on the Document using supplied upcast function. + * @param payloadType type of the payload + * @param sourceRevision revision to upcast from. + * @param targetRevision revision to upcast to. + * @param upcastFunction function transforming the Document. + */ + @JvmStatic + fun xmlDocumentUpcaster(payloadType: KClass<*>, sourceRevision: String, targetRevision: String, upcastFunction: (Document) -> Document) = + xmlDocumentUpcaster( + payloadTypeName = payloadType.java.name, + sourceRevision = sourceRevision, + targetRevision = targetRevision, + upcastFunction = upcastFunction + ) } } diff --git a/extension/upcaster-test-core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt b/extension/upcaster-test-core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt index 7e06772..5267d8e 100644 --- a/extension/upcaster-test-core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt +++ b/extension/upcaster-test-core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt @@ -1,18 +1,15 @@ package io.holixon.axon.testing.upcaster -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.initialEvent +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonNodeUpcaster import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonTestEventData import org.assertj.core.api.Assertions.assertThat import org.axonframework.serialization.Revision import org.axonframework.serialization.SerializedObject -import org.axonframework.serialization.SimpleSerializedType import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.EventUpcasterChain -import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation -import org.axonframework.serialization.upcasting.event.SingleEventUpcaster import org.junit.jupiter.api.Test import kotlin.streams.toList @@ -45,7 +42,7 @@ class AccountCreatedV0V1UpcasterTest { ) // AND an upcaster we wrote for this usecase - val upcaster = upcaster(payloadType = payloadType, sourceRevision = eventData.payload.type.revision, targetRevision = targetRevision) { + val upcaster = jsonNodeUpcaster(payloadTypeName = payloadType, sourceRevision = eventData.payload.type.revision, targetRevision = targetRevision) { (it as ObjectNode).apply { put("accountId", get("bankAccountId").asText()) remove("bankAccountId") @@ -68,17 +65,4 @@ class AccountCreatedV0V1UpcasterTest { assertThat(revision1data.initialBalance).isEqualTo(0) assertThat(revision1data.maximalBalance).isEqualTo(1000) } - - private fun upcaster(payloadType: String, sourceRevision: String, targetRevision: String, upcastFunction: (JsonNode) -> JsonNode) = - object : SingleEventUpcaster() { - override fun canUpcast(representation: IntermediateEventRepresentation): Boolean = - representation.type.name == payloadType && representation.type.revision == sourceRevision - - override fun doUpcast(intermediateRepresentation: IntermediateEventRepresentation): IntermediateEventRepresentation = - intermediateRepresentation.upcastPayload( - SimpleSerializedType(payloadType, targetRevision), - JsonNode::class.java, - upcastFunction - ) - } } diff --git a/extension/upcaster-test-core/src/test/kotlin/DummyUpcasterTest.kt b/extension/upcaster-test-core/src/test/kotlin/DummyUpcasterTest.kt index 1d5d0c1..b75b32e 100644 --- a/extension/upcaster-test-core/src/test/kotlin/DummyUpcasterTest.kt +++ b/extension/upcaster-test-core/src/test/kotlin/DummyUpcasterTest.kt @@ -1,38 +1,47 @@ package io.holixon.axon.testing.upcaster import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.thoughtworks.xstream.XStream +import com.thoughtworks.xstream.security.AnyTypePermission +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.EMPTY_JSON import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.initialEvent +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonNodeUpcaster import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonTestEventData +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlDocumentUpcaster import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlTestEventData import org.assertj.core.api.Assertions.assertThat import org.axonframework.serialization.Revision -import org.axonframework.serialization.SimpleSerializedType import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.EventUpcasterChain -import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation -import org.axonframework.serialization.upcasting.event.SingleEventUpcaster import org.axonframework.serialization.xml.XStreamSerializer -import org.dom4j.Document -import org.junit.Test -import java.util.function.Function +import org.junit.jupiter.api.Test import kotlin.streams.toList -class DummyUpcasterTest { - - private val jsonSerializer = JacksonSerializer.builder().objectMapper(jacksonObjectMapper()).build() - private val jsonUpcasters = EventUpcasterChain(DummyEventJsonUpcaster()) - - private val xmlSerializer = XStreamSerializer.builder().build() - private val xmlUpcasters = EventUpcasterChain(DummyEventXmlUpcaster()) +internal class DummyUpcasterTest { @Test - fun `should upcast json`() { + fun `should upcast json just changing the target revision`() { + val jsonSerializer = JacksonSerializer + .builder() + .lenientDeserialization() + .objectMapper( + jacksonObjectMapper() + .findAndRegisterModules() + ).build() + + val jsonUpcasters = EventUpcasterChain( + jsonNodeUpcaster(DummyEvent::class, "1", "2") { + it // do nothing + } + ) val json = """ {"value":"some"} """.trimIndent() - val result = jsonUpcasters.upcast(initialEvent(jsonTestEventData(json, "io.holixon.axon.testing.upcaster.DummyEvent", "{}", "1"), jsonSerializer)).toList() + val result = jsonUpcasters.upcast( + initialEvent(jsonTestEventData(json, DummyEvent::class, EMPTY_JSON, "1"), jsonSerializer) + ).toList() assertThat(result) .isNotNull @@ -46,13 +55,34 @@ class DummyUpcasterTest { } @Test - fun `should upcast xml`() { + fun `should upcast xml just changing the target revision`() { + + val xmlSerializer = XStreamSerializer + .builder() + .lenientDeserialization() + .xStream( + XStream() + .apply { addPermission(AnyTypePermission.ANY) } + ).build() + + val xmlUpcasters = EventUpcasterChain( + xmlDocumentUpcaster(DummyEvent::class, "1", "2") { + it // do nothing + } + ) val xml = """ some """.trimIndent() - val result = xmlUpcasters.upcast(initialEvent(xmlTestEventData(xml, "io.holixon.axon.testing.upcaster.DummyEvent", "1"), xmlSerializer)).toList() + val result = xmlUpcasters.upcast( + initialEvent( + xmlTestEventData( + xml, + DummyEvent::class.java.name, "1" + ), xmlSerializer + ) + ).toList() assertThat(result) .isNotNull @@ -64,7 +94,6 @@ class DummyUpcasterTest { val event: DummyEvent = xmlSerializer.deserialize(result[0].data) assertThat(event).isNotNull } - } @Revision("2") @@ -72,32 +101,3 @@ data class DummyEvent( val value: String ) - -class DummyEventJsonUpcaster : SingleEventUpcaster() { - - override fun canUpcast(representation: IntermediateEventRepresentation): Boolean = - representation.type.name == DummyEvent::class.java.name && representation.type.revision == "1" - - - override fun doUpcast(representation: IntermediateEventRepresentation): IntermediateEventRepresentation { - return representation.upcastPayload( - SimpleSerializedType(DummyEvent::class.java.name, "2"), - String::class.java, - Function.identity() - ) - } -} - -class DummyEventXmlUpcaster : SingleEventUpcaster() { - - override fun canUpcast(representation: IntermediateEventRepresentation): Boolean = - representation.type.name == DummyEvent::class.java.name && representation.type.revision == "1" - - override fun doUpcast(representation: IntermediateEventRepresentation): IntermediateEventRepresentation { - return representation.upcastPayload( - SimpleSerializedType(DummyEvent::class.java.name, "2"), - Document::class.java, - Function.identity() - ) - } -} diff --git a/pom.xml b/pom.xml index 66401ed..b3a56da 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.15.2 4.13.2 - 5.9.3 + 5.9.1 2.1.4 3.24.2 @@ -67,6 +67,14 @@ import + + com.fasterxml.jackson + jackson-bom + ${jackson.version} + import + pom + + io.holixon.axon.testing axon-testing-jgiven-core @@ -84,6 +92,13 @@ axon-testing-jgiven-junit5 ${project.version} + + + io.holixon.axon.testing + axon-testing-upcaster-core + ${project.version} + + @@ -117,7 +132,9 @@ - 1.8 + 11 + 1.8 + 1.8 spring all-open @@ -253,8 +270,6 @@ **/*Test_*.java **/*Tests_*.java - - -Djava.awt.headless=true ${argLine} -XX:+StartAttachListener -Xmx1024m -XX:MaxPermSize=256m ${surefireArgLine} @@ -342,7 +357,7 @@ ${java.version} - 3.5 + 3.9 @@ -431,14 +446,14 @@ Default build --> - - org.jacoco - jacoco-maven-plugin - org.apache.maven.plugins maven-enforcer-plugin + + org.jacoco + jacoco-maven-plugin + @@ -548,7 +563,7 @@ Apache 2.0 - http://www.apache.org/licenses/LICENSE-2.0 + https://www.apache.org/licenses/LICENSE-2.0 From e433cfee5a402207c859cafeaffc704b07ef7ad4 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 4 Jul 2023 20:16:52 +0200 Subject: [PATCH 24/70] dependencies --- extension/upcaster-test-core/pom.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extension/upcaster-test-core/pom.xml b/extension/upcaster-test-core/pom.xml index e7aab5b..45d4902 100644 --- a/extension/upcaster-test-core/pom.xml +++ b/extension/upcaster-test-core/pom.xml @@ -38,7 +38,12 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - + + org.jetbrains.kotlin + kotlin-compiler-embeddable + 1.8.22 + runtime + org.dom4j dom4j From 94716edd666023481a98d829d23441ac0b888adc Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 4 Jul 2023 22:14:22 +0200 Subject: [PATCH 25/70] new module --- extension/pom.xml | 2 +- .../core}/pom.xml | 41 +++++++++++-------- .../core}/src/main/kotlin/TestEventData.kt | 0 .../src/main/kotlin/UpcasterTestSupport.kt | 0 .../kotlin/AccountCreatedV0V1UpcasterTest.kt | 2 +- .../src/test/kotlin/DummyUpcasterTest.kt | 24 +++++------ extension/upcaster/junit5/pom.xml | 28 +++++++++++++ extension/upcaster/pom.xml | 28 +++++++++++++ pom.xml | 15 +++++-- 9 files changed, 103 insertions(+), 37 deletions(-) rename extension/{upcaster-test-core => upcaster/core}/pom.xml (87%) rename extension/{upcaster-test-core => upcaster/core}/src/main/kotlin/TestEventData.kt (100%) rename extension/{upcaster-test-core => upcaster/core}/src/main/kotlin/UpcasterTestSupport.kt (100%) rename extension/{upcaster-test-core => upcaster/core}/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt (96%) rename extension/{upcaster-test-core => upcaster/core}/src/test/kotlin/DummyUpcasterTest.kt (83%) create mode 100644 extension/upcaster/junit5/pom.xml create mode 100644 extension/upcaster/pom.xml diff --git a/extension/pom.xml b/extension/pom.xml index 38718bc..403d72b 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -14,7 +14,7 @@ jgiven - upcaster-test-core + upcaster diff --git a/extension/upcaster-test-core/pom.xml b/extension/upcaster/core/pom.xml similarity index 87% rename from extension/upcaster-test-core/pom.xml rename to extension/upcaster/core/pom.xml index 45d4902..2613045 100644 --- a/extension/upcaster-test-core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ - extension + extension-upcaster 4.7.4.1-SNAPSHOT @@ -30,20 +30,6 @@ com.fasterxml.jackson.core jackson-databind - - com.fasterxml.jackson.module - jackson-module-kotlin - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - org.jetbrains.kotlin - kotlin-compiler-embeddable - 1.8.22 - runtime - org.dom4j dom4j @@ -64,10 +50,29 @@ test - org.slf4j - slf4j-simple + com.fasterxml.jackson.module + jackson-module-kotlin + test + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + test + + + + ch.qos.logback + logback-classic + 1.4.8 + test + + diff --git a/extension/upcaster-test-core/src/main/kotlin/TestEventData.kt b/extension/upcaster/core/src/main/kotlin/TestEventData.kt similarity index 100% rename from extension/upcaster-test-core/src/main/kotlin/TestEventData.kt rename to extension/upcaster/core/src/main/kotlin/TestEventData.kt diff --git a/extension/upcaster-test-core/src/main/kotlin/UpcasterTestSupport.kt b/extension/upcaster/core/src/main/kotlin/UpcasterTestSupport.kt similarity index 100% rename from extension/upcaster-test-core/src/main/kotlin/UpcasterTestSupport.kt rename to extension/upcaster/core/src/main/kotlin/UpcasterTestSupport.kt diff --git a/extension/upcaster-test-core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt b/extension/upcaster/core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt similarity index 96% rename from extension/upcaster-test-core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt rename to extension/upcaster/core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt index 5267d8e..118b177 100644 --- a/extension/upcaster-test-core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt +++ b/extension/upcaster/core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt @@ -32,7 +32,7 @@ class AccountCreatedV0V1UpcasterTest { ) val payloadType = AccountCreatedEvent::class.java.name - val targetRevision = AccountCreatedEvent::class.java.getAnnotation(Revision::class.java).value + val targetRevision = "1" // AccountCreatedEvent::class.java.getAnnotation(Revision::class.java).value // AND GIVEN: an old event with revision "0" with bankAccountId (has to be renamed to accountId), and maximalBalance is missing! val eventData = jsonTestEventData( diff --git a/extension/upcaster-test-core/src/test/kotlin/DummyUpcasterTest.kt b/extension/upcaster/core/src/test/kotlin/DummyUpcasterTest.kt similarity index 83% rename from extension/upcaster-test-core/src/test/kotlin/DummyUpcasterTest.kt rename to extension/upcaster/core/src/test/kotlin/DummyUpcasterTest.kt index b75b32e..b0317af 100644 --- a/extension/upcaster-test-core/src/test/kotlin/DummyUpcasterTest.kt +++ b/extension/upcaster/core/src/test/kotlin/DummyUpcasterTest.kt @@ -1,5 +1,6 @@ package io.holixon.axon.testing.upcaster +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.thoughtworks.xstream.XStream import com.thoughtworks.xstream.security.AnyTypePermission @@ -14,20 +15,17 @@ import org.axonframework.serialization.Revision import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.EventUpcasterChain import org.axonframework.serialization.xml.XStreamSerializer +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import kotlin.streams.toList -internal class DummyUpcasterTest { +class DummyUpcasterTest { @Test + @Disabled // FIXME -> understand this! fun `should upcast json just changing the target revision`() { - val jsonSerializer = JacksonSerializer - .builder() - .lenientDeserialization() - .objectMapper( - jacksonObjectMapper() - .findAndRegisterModules() - ).build() + + val jsonSerializer = JacksonSerializer.builder().objectMapper(jacksonObjectMapper()).defaultTyping().lenientDeserialization().build() val jsonUpcasters = EventUpcasterChain( jsonNodeUpcaster(DummyEvent::class, "1", "2") { @@ -36,7 +34,7 @@ internal class DummyUpcasterTest { ) val json = """ - {"value":"some"} + {"someValue":"some"} """.trimIndent() val result = jsonUpcasters.upcast( @@ -72,7 +70,7 @@ internal class DummyUpcasterTest { ) val xml = """ - some + some """.trimIndent() val result = xmlUpcasters.upcast( @@ -96,8 +94,8 @@ internal class DummyUpcasterTest { } } -@Revision("2") +@Revision(value = "2") data class DummyEvent( - val value: String + @JsonProperty("someValue") + val someValue: String ) - diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml new file mode 100644 index 0000000..fb8a660 --- /dev/null +++ b/extension/upcaster/junit5/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + Axon Testing - Upcaster Testing in JUnit5 + + + io.holixon.axon.testing._ + extension-upcaster + 4.7.4.1-SNAPSHOT + + + io.holixon.axon.testing + axon-testing-upcaster-junit5 + + + + ${project.groupId} + axon-testing-upcaster-core + + + ch.qos.logback + logback-classic + 1.4.8 + test + + + diff --git a/extension/upcaster/pom.xml b/extension/upcaster/pom.xml new file mode 100644 index 0000000..f4b910a --- /dev/null +++ b/extension/upcaster/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + io.holixon.axon.testing._ + extension + 4.7.4.1-SNAPSHOT + + + extension-upcaster + pom + + + false + false + false + false + false + + + + core + junit5 + + + diff --git a/pom.xml b/pom.xml index b3a56da..c6fb441 100644 --- a/pom.xml +++ b/pom.xml @@ -99,6 +99,12 @@ ${project.version} + + io.holixon.axon.testing + axon-testing-upcaster-junit5 + ${project.version} + + @@ -133,8 +139,8 @@ 11 - 1.8 - 1.8 + 1.9 + 1.9 spring all-open @@ -243,14 +249,15 @@ pre-unit-test + initialize prepare-agent - pre-integration-test + report-unit-test - prepare-agent-integration + report From d54be428ab2c21c8dec570ebc5f67b147e920dbe Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 5 Jul 2023 01:03:31 +0200 Subject: [PATCH 26/70] ongoing --- .../axon/testing/upcaster/FileUtils.kt | 51 ++++++++++++++++ .../IntermediateRepresentationProvider.kt | 38 ++++++++++++ .../axon/testing/upcaster/UpcasterTest.kt | 19 ++++++ .../axon/testing/upcaster/FileUtilsTest.kt | 58 +++++++++++++++++++ .../finds_this_folder/marker.txt | 0 .../lists_files/10__some_text.json | 1 + .../lists_files/1__some_text.json | 1 + .../lists_files/1__some_text.xml | 1 + .../lists_files/2__some_text.json | 1 + 9 files changed, 170 insertions(+) create mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt create mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt create mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt create mode 100644 extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/finds_this_folder/marker.txt create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/10__some_text.json create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.json create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.xml create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/2__some_text.json diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt new file mode 100644 index 0000000..a9bc64c --- /dev/null +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt @@ -0,0 +1,51 @@ +package io.holixon.axon.testing.upcaster + +import org.junit.jupiter.api.extension.ExtensionContext +import java.io.File +import java.io.FileFilter +import java.nio.file.Files +import kotlin.io.path.Path + +/** + * Retrieves the test folder for this test context. + */ +fun ExtensionContext.getTestFolder(): File? { + val path = getTestFolderName()?.let { Path(it) } + return if (path != null && Files.exists(path) && path.toFile().isDirectory) { + path.toFile() + } else { + null + } +} + +/** + * Retrieves the test folder name for this test context. + */ +fun ExtensionContext.getTestFolderName() = IntermediateRepresentationProvider::class.java.getResource( + "/" + + (this.requiredTestClass.canonicalName + "." + this.requiredTestMethod.name.replace(' ', '_')) + .replace('.', '/') +)?.path + + +/** + * Retrieves a regex to match files with given ending. + * Will match files starting with digits having a name separated by a double underscore ("9234__my_file.txt") + * @param ending the desired ending without the leading dot. ("jpg") + */ +fun numberedFileRegex(ending: String) = Regex("^([0-9]+)_{2}(.*)(\\.$ending)$") + +/** + * Retrieve numbered files with given ending, sorted by the leading number descending. + * @param ending desired end of file without dot. + */ +fun File.getFiles(ending: String): List { + require(this.isDirectory) { "Provided reference ${this.name} must be a folder, but it was not." } + val regex = numberedFileRegex(ending) + val files = this.listFiles(FileFilter { + it.isFile + && it.name.matches(regex) + })?.toList() ?: listOf() + return files.sortedBy { regex.find(it.name)!!.groups[1]!!.value.toInt() } +} + diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt new file mode 100644 index 0000000..1bcbdf2 --- /dev/null +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt @@ -0,0 +1,38 @@ +package io.holixon.axon.testing.upcaster + +import org.junit.jupiter.api.extension.ExtensionContext +import org.junit.jupiter.params.provider.Arguments +import org.junit.jupiter.params.provider.ArgumentsProvider +import org.junit.jupiter.params.support.AnnotationConsumer +import java.util.stream.Stream + +class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer { + + private lateinit var eventEncoding: UpcasterTest.EventEncoding + + override fun provideArguments(context: ExtensionContext): Stream { + + sanitize() + val folderName = context.getTestFolderName(); + val folder = requireNotNull(context.getTestFolder()) { "Could not access the test data folder $folderName, consider defining it" } + + val ending = when (eventEncoding) { + UpcasterTest.EventEncoding.XML -> "xml" + UpcasterTest.EventEncoding.JSON -> "json" + UpcasterTest.EventEncoding.AVRO -> "avro" + } + val testFiles = folder.getFiles(ending) + require(testFiles.isNotEmpty()) { "Could not load any test data files (*.$eventEncoding) from provided folder $folderName" } + return Stream.of( + + ) + } + + override fun accept(annotation: UpcasterTest) { + this.eventEncoding = annotation.eventEncoding + } + + private fun sanitize() { + require(this::eventEncoding.isInitialized) { "Event encoding must be initialized to use this provider." } + } +} diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt new file mode 100644 index 0000000..458e2f3 --- /dev/null +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt @@ -0,0 +1,19 @@ +package io.holixon.axon.testing.upcaster + +import org.junit.jupiter.params.provider.ArgumentsSource + +@MustBeDocumented +@ArgumentsSource(IntermediateRepresentationProvider::class) +@Target(AnnotationTarget.FUNCTION) +annotation class UpcasterTest( + val eventEncoding: EventEncoding = EventEncoding.JSON, +) { + /** + * Type of event + */ + enum class EventEncoding { + XML, + JSON, + AVRO + } +} diff --git a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt new file mode 100644 index 0000000..568a7eb --- /dev/null +++ b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt @@ -0,0 +1,58 @@ +package io.holixon.axon.testing.upcaster + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtensionContext +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.Arguments +import org.junit.jupiter.params.provider.ArgumentsProvider +import org.junit.jupiter.params.provider.ArgumentsSource +import java.io.File +import java.io.FileFilter +import java.util.stream.Stream + +class FileUtilsTest { + + @ParameterizedTest + @ArgumentsSource(DummyFolderProvider::class) + fun `finds this folder`(file: File?) { + assertThat(file).isNotNull + } + + @ParameterizedTest + @ArgumentsSource(DummyFolderProvider::class) + fun `don't find this folder`(file: File?) { + assertThat(file).isNull() + } + + @ParameterizedTest + @ArgumentsSource(DummyFileStreamProvider::class) + fun `lists files`(files: List) { + assertThat(files).isNotEmpty + assertThat(files.map { it.name }).containsExactly( + "1__some_text.json", + "2__some_text.json", + "10__some_text.json", + ) + } + + @Test + fun regex_matches() { + val regex = numberedFileRegex("json") + assertThat("1__x.json".matches(regex)).isTrue() + assertThat("n1__x.json".matches(regex)).isFalse() + assertThat("1__x.xml".matches(regex)).isFalse() + } + + internal class DummyFolderProvider : ArgumentsProvider { + override fun provideArguments(ctx: ExtensionContext): Stream = + Stream.of(Arguments.of(ctx.getTestFolder())) + } + + internal class DummyFileStreamProvider : ArgumentsProvider { + override fun provideArguments(ctx: ExtensionContext): Stream = + Stream.of(Arguments.of( + ctx.getTestFolder()?.getFiles("json") + )) + } +} diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/finds_this_folder/marker.txt b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/finds_this_folder/marker.txt new file mode 100644 index 0000000..e69de29 diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/10__some_text.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/10__some_text.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/10__some_text.json @@ -0,0 +1 @@ +{} diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.json @@ -0,0 +1 @@ +{} diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.xml b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.xml new file mode 100644 index 0000000..e7cc390 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/1__some_text.xml @@ -0,0 +1 @@ + diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/2__some_text.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/2__some_text.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/FileUtilsTest/lists_files/2__some_text.json @@ -0,0 +1 @@ +{} From 020e11bcaa48ee83f0e18abee641fb1ff9fce9aa Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 5 Jul 2023 01:18:09 +0200 Subject: [PATCH 27/70] ongoing provider implemenetation --- .../axon/testing/upcaster}/TestEventData.kt | 0 .../testing/upcaster}/UpcasterTestSupport.kt | 0 .../AccountCreatedV0V1UpcasterTest.kt | 0 .../axon/testing/upcaster/DummyEvent.kt | 10 +++ .../upcaster/DummyUpcasterParametrizedTest.kt | 74 +++++++++++++++++++ .../testing/upcaster}/DummyUpcasterTest.kt | 7 -- extension/upcaster/junit5/pom.xml | 22 ++++++ .../IntermediateRepresentationProvider.kt | 7 +- 8 files changed, 112 insertions(+), 8 deletions(-) rename extension/upcaster/core/src/main/kotlin/{ => io/holixon/axon/testing/upcaster}/TestEventData.kt (100%) rename extension/upcaster/core/src/main/kotlin/{ => io/holixon/axon/testing/upcaster}/UpcasterTestSupport.kt (100%) rename extension/upcaster/core/src/test/kotlin/{ => io/holixon/axon/testing/upcaster}/AccountCreatedV0V1UpcasterTest.kt (100%) create mode 100644 extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyEvent.kt create mode 100644 extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt rename extension/upcaster/core/src/test/kotlin/{ => io/holixon/axon/testing/upcaster}/DummyUpcasterTest.kt (93%) diff --git a/extension/upcaster/core/src/main/kotlin/TestEventData.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/TestEventData.kt similarity index 100% rename from extension/upcaster/core/src/main/kotlin/TestEventData.kt rename to extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/TestEventData.kt diff --git a/extension/upcaster/core/src/main/kotlin/UpcasterTestSupport.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTestSupport.kt similarity index 100% rename from extension/upcaster/core/src/main/kotlin/UpcasterTestSupport.kt rename to extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTestSupport.kt diff --git a/extension/upcaster/core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/AccountCreatedV0V1UpcasterTest.kt similarity index 100% rename from extension/upcaster/core/src/test/kotlin/AccountCreatedV0V1UpcasterTest.kt rename to extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/AccountCreatedV0V1UpcasterTest.kt diff --git a/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyEvent.kt b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyEvent.kt new file mode 100644 index 0000000..2bcba9e --- /dev/null +++ b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyEvent.kt @@ -0,0 +1,10 @@ +package io.holixon.axon.testing.upcaster + +import com.fasterxml.jackson.annotation.JsonProperty +import org.axonframework.serialization.Revision + +@Revision(value = "2") +data class DummyEvent( + @JsonProperty("someValue") + val someValue: String +) diff --git a/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt new file mode 100644 index 0000000..37db39d --- /dev/null +++ b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt @@ -0,0 +1,74 @@ +package io.holixon.axon.testing.upcaster + +import com.thoughtworks.xstream.XStream +import com.thoughtworks.xstream.security.AnyTypePermission +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.initialEvent +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlDocumentUpcaster +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlTestEventData +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.serialization.upcasting.event.EventUpcasterChain +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation +import org.axonframework.serialization.xml.XStreamSerializer +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.MethodSource +import java.util.stream.Stream +import kotlin.streams.toList + +class DummyUpcasterParametrizedTest { + + companion object { + + val xmlSerializer = XStreamSerializer + .builder() + .lenientDeserialization() + .xStream( + XStream() + .apply { addPermission(AnyTypePermission.ANY) } + ).build() + + + @JvmStatic + fun createStream(): Stream> { + + val xml = """ + some + """.trimIndent() + + return Stream.of( + initialEvent( + xmlTestEventData( + xml, + DummyEvent::class.java.name, "1" + ), xmlSerializer + ) + ) + } + } + + @ParameterizedTest + @MethodSource("io.holixon.axon.testing.upcaster.DummyUpcasterParametrizedTest#createStream") + fun `should upcast xml just changing the target revision`(stream: Stream) { + + + val xmlUpcasters = EventUpcasterChain( + xmlDocumentUpcaster(DummyEvent::class, "1", "2") { + it // do nothing + } + ) + + val result = xmlUpcasters.upcast( + stream + ).toList() + + assertThat(result) + .isNotNull + .hasSize(1) + .element(0) + .extracting { it.data } + .isNotNull + + val event: DummyEvent = xmlSerializer.deserialize(result[0].data) + assertThat(event).isNotNull + } +} + diff --git a/extension/upcaster/core/src/test/kotlin/DummyUpcasterTest.kt b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterTest.kt similarity index 93% rename from extension/upcaster/core/src/test/kotlin/DummyUpcasterTest.kt rename to extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterTest.kt index b0317af..f59c8d7 100644 --- a/extension/upcaster/core/src/test/kotlin/DummyUpcasterTest.kt +++ b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterTest.kt @@ -1,6 +1,5 @@ package io.holixon.axon.testing.upcaster -import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.thoughtworks.xstream.XStream import com.thoughtworks.xstream.security.AnyTypePermission @@ -11,7 +10,6 @@ import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonTestEv import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlDocumentUpcaster import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlTestEventData import org.assertj.core.api.Assertions.assertThat -import org.axonframework.serialization.Revision import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.EventUpcasterChain import org.axonframework.serialization.xml.XStreamSerializer @@ -94,8 +92,3 @@ class DummyUpcasterTest { } } -@Revision(value = "2") -data class DummyEvent( - @JsonProperty("someValue") - val someValue: String -) diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index fb8a660..50a25bf 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -18,6 +18,28 @@ ${project.groupId} axon-testing-upcaster-core + + org.junit.jupiter + junit-jupiter-params + ${junit5.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + com.fasterxml.jackson.module + jackson-module-kotlin + test + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + test + ch.qos.logback logback-classic diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt index 1bcbdf2..1ff9191 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt @@ -6,6 +6,9 @@ import org.junit.jupiter.params.provider.ArgumentsProvider import org.junit.jupiter.params.support.AnnotationConsumer import java.util.stream.Stream +/** + * Provider for intermediate representation of events read from file system. + */ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer { private lateinit var eventEncoding: UpcasterTest.EventEncoding @@ -24,7 +27,9 @@ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer val testFiles = folder.getFiles(ending) require(testFiles.isNotEmpty()) { "Could not load any test data files (*.$eventEncoding) from provided folder $folderName" } return Stream.of( - + Arguments.of( + testFiles.map { it.readText() } + ) ) } From d32e73f7004adeb8b8d1092c22f1976d63efa2b7 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 5 Jul 2023 02:07:09 +0200 Subject: [PATCH 28/70] provide named stream and implement file content provider, #304 --- .../axon/testing/upcaster/FileUtils.kt | 12 +++++------ .../IntermediateRepresentationProvider.kt | 17 ++++++++++++---- .../axon/testing/upcaster/UpcasterTest.kt | 5 ++++- .../axon/testing/upcaster/FileUtilsTest.kt | 9 +++++---- .../IntermediateRepresentationProviderTest.kt | 20 +++++++++++++++++++ .../receives_json_files/1__some_event.json | 1 + .../receives_xml_files/1__node.xml | 1 + .../receives_xml_files/2__node.xml | 1 + 8 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__some_event.json create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/1__node.xml create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__node.xml diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt index a9bc64c..0025157 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt @@ -10,8 +10,9 @@ import kotlin.io.path.Path * Retrieves the test folder for this test context. */ fun ExtensionContext.getTestFolder(): File? { - val path = getTestFolderName()?.let { Path(it) } - return if (path != null && Files.exists(path) && path.toFile().isDirectory) { + val folderPathAsString = IntermediateRepresentationProvider::class.java.getResource("/" + getTestFolderName())?.path ?: return null + val path = Path(folderPathAsString) + return if (Files.exists(path) && path.toFile().isDirectory) { path.toFile() } else { null @@ -21,11 +22,8 @@ fun ExtensionContext.getTestFolder(): File? { /** * Retrieves the test folder name for this test context. */ -fun ExtensionContext.getTestFolderName() = IntermediateRepresentationProvider::class.java.getResource( - "/" - + (this.requiredTestClass.canonicalName + "." + this.requiredTestMethod.name.replace(' ', '_')) - .replace('.', '/') -)?.path +fun ExtensionContext.getTestFolderName(): String = + (this.requiredTestClass.canonicalName + "." + this.requiredTestMethod.name.replace(' ', '_')).replace('.', '/') /** diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt index 1ff9191..266838c 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt @@ -1,5 +1,6 @@ package io.holixon.axon.testing.upcaster +import org.junit.jupiter.api.Named import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider @@ -16,8 +17,8 @@ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer override fun provideArguments(context: ExtensionContext): Stream { sanitize() - val folderName = context.getTestFolderName(); - val folder = requireNotNull(context.getTestFolder()) { "Could not access the test data folder $folderName, consider defining it" } + val folderName = context.getTestFolderName() + val folder = requireNotNull(context.getTestFolder()) { "Could not access the test data folder $folderName, consider creating it in your resources folder." } val ending = when (eventEncoding) { UpcasterTest.EventEncoding.XML -> "xml" @@ -25,10 +26,13 @@ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer UpcasterTest.EventEncoding.AVRO -> "avro" } val testFiles = folder.getFiles(ending) - require(testFiles.isNotEmpty()) { "Could not load any test data files (*.$eventEncoding) from provided folder $folderName" } + require(testFiles.isNotEmpty()) { "Could not load any test data files (*.$ending) from provided folder $folderName." } return Stream.of( Arguments.of( - testFiles.map { it.readText() } + NamedStream( + name = "*.$ending files from $folderName", + stream = testFiles.map { it.readText().trim() }.stream() + ) ) ) } @@ -40,4 +44,9 @@ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer private fun sanitize() { require(this::eventEncoding.isInitialized) { "Event encoding must be initialized to use this provider." } } + + class NamedStream(private val name: String, private val stream: Stream): Stream by stream, Named> { + override fun getName(): String = name + override fun getPayload(): Stream = stream + } } diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt index 458e2f3..caed334 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt @@ -1,10 +1,13 @@ package io.holixon.axon.testing.upcaster +import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource @MustBeDocumented -@ArgumentsSource(IntermediateRepresentationProvider::class) @Target(AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.RUNTIME) +@ParameterizedTest(name = "Using {arguments}") +@ArgumentsSource(value = IntermediateRepresentationProvider::class) annotation class UpcasterTest( val eventEncoding: EventEncoding = EventEncoding.JSON, ) { diff --git a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt index 568a7eb..c97699e 100644 --- a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt +++ b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt @@ -8,7 +8,6 @@ import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider import org.junit.jupiter.params.provider.ArgumentsSource import java.io.File -import java.io.FileFilter import java.util.stream.Stream class FileUtilsTest { @@ -51,8 +50,10 @@ class FileUtilsTest { internal class DummyFileStreamProvider : ArgumentsProvider { override fun provideArguments(ctx: ExtensionContext): Stream = - Stream.of(Arguments.of( - ctx.getTestFolder()?.getFiles("json") - )) + Stream.of( + Arguments.of( + ctx.getTestFolder()?.getFiles("json") + ) + ) } } diff --git a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt new file mode 100644 index 0000000..adb5b23 --- /dev/null +++ b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt @@ -0,0 +1,20 @@ +package io.holixon.axon.testing.upcaster + +import org.assertj.core.api.Assertions.assertThat +import java.util.stream.Stream +import kotlin.streams.toList + + +class IntermediateRepresentationProviderTest { + + @UpcasterTest(eventEncoding = UpcasterTest.EventEncoding.JSON) + fun `receives json files`(events: Stream) { + assertThat(events.toList()).containsExactly("""{ "json": 1 }""", """{ "json": 2 }""") + } + + @UpcasterTest(eventEncoding = UpcasterTest.EventEncoding.XML) + fun `receives xml files`(events: Stream) { + assertThat(events.toList()).containsExactly("""1""", """2""") + } + +} diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__some_event.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__some_event.json new file mode 100644 index 0000000..bdfa100 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__some_event.json @@ -0,0 +1 @@ +{ "json": 1 } diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/1__node.xml b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/1__node.xml new file mode 100644 index 0000000..805164e --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/1__node.xml @@ -0,0 +1 @@ +1 diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__node.xml b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__node.xml new file mode 100644 index 0000000..aa01694 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__node.xml @@ -0,0 +1 @@ +2 From 23dc1281b41070efef96e772a92e8e09ce92ea89 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 5 Jul 2023 02:08:01 +0200 Subject: [PATCH 29/70] provide named stream and implement file content provider, #304 --- .../receives_json_files/1__test.xml | 1 + .../receives_json_files/2__some_event.json | 1 + .../receives_xml_files/2__some_event.json | 1 + 3 files changed, 3 insertions(+) create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__test.xml create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/2__some_event.json create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__some_event.json diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__test.xml b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__test.xml new file mode 100644 index 0000000..936a4dc --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/1__test.xml @@ -0,0 +1 @@ +1 diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/2__some_event.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/2__some_event.json new file mode 100644 index 0000000..03c2e70 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_files/2__some_event.json @@ -0,0 +1 @@ +{ "json": 2 } diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__some_event.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__some_event.json new file mode 100644 index 0000000..03c2e70 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_xml_files/2__some_event.json @@ -0,0 +1 @@ +{ "json": 2 } From 7efa40380ffef3d7c93197fd76d4562ddd1404e3 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 5 Jul 2023 03:00:08 +0200 Subject: [PATCH 30/70] wip, fixmes to implement --- .../FixedPayloadTypeAndRevisionProvider.kt | 12 ++ .../PayloadTypeAndRevisionProvider.kt | 6 + .../upcaster/DummyUpcasterParametrizedTest.kt | 14 +-- .../IntermediateRepresentationProvider.kt | 104 ++++++++++++++++-- .../upcaster/TestInstanceReflectionUtils.kt | 19 ++++ .../axon/testing/upcaster/UpcasterTest.kt | 2 + .../IntermediateRepresentationProviderTest.kt | 12 ++ 7 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt create mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt new file mode 100644 index 0000000..619cd61 --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt @@ -0,0 +1,12 @@ +package io.holixon.axon.testing.upcaster + +/** + * PayloadTypeAndRevisionProvider returning fixed values. + */ +class FixedPayloadTypeAndRevisionProvider( + private val payloadTypeName: String, + private val payloadRevision: String? +) : PayloadTypeAndRevisionProvider { + override fun getPayloadType(payload: Any): String = payloadTypeName + override fun getRevision(payload: Any): String? = payloadRevision +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt new file mode 100644 index 0000000..3be78ae --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt @@ -0,0 +1,6 @@ +package io.holixon.axon.testing.upcaster + +interface PayloadTypeAndRevisionProvider { + fun getPayloadType(payload: Any): String + fun getRevision(payload: Any): String? +} diff --git a/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt index 37db39d..b4228a3 100644 --- a/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt +++ b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt @@ -17,15 +17,14 @@ import kotlin.streams.toList class DummyUpcasterParametrizedTest { companion object { - - val xmlSerializer = XStreamSerializer + private val xmlSerializer = XStreamSerializer .builder() .lenientDeserialization() .xStream( XStream() .apply { addPermission(AnyTypePermission.ANY) } ).build() - + private val fixedPayloadTypeAndRevisionProvider = FixedPayloadTypeAndRevisionProvider(DummyEvent::class.java.name, "1") @JvmStatic fun createStream(): Stream> { @@ -36,10 +35,12 @@ class DummyUpcasterParametrizedTest { return Stream.of( initialEvent( - xmlTestEventData( + entry = xmlTestEventData( xml, - DummyEvent::class.java.name, "1" - ), xmlSerializer + fixedPayloadTypeAndRevisionProvider.getPayloadType(xml), + fixedPayloadTypeAndRevisionProvider.getRevision(xml) + ), + serializer = xmlSerializer ) ) } @@ -49,7 +50,6 @@ class DummyUpcasterParametrizedTest { @MethodSource("io.holixon.axon.testing.upcaster.DummyUpcasterParametrizedTest#createStream") fun `should upcast xml just changing the target revision`(stream: Stream) { - val xmlUpcasters = EventUpcasterChain( xmlDocumentUpcaster(DummyEvent::class, "1", "2") { it // do nothing diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt index 266838c..1007691 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt @@ -1,52 +1,138 @@ package io.holixon.axon.testing.upcaster +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.EMPTY_XML +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.initialEvent +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonTestEventData +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlTestEventData +import org.axonframework.eventhandling.EventData +import org.dom4j.io.SAXReader import org.junit.jupiter.api.Named import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider import org.junit.jupiter.params.support.AnnotationConsumer +import java.io.File +import java.io.StringReader import java.util.stream.Stream +import kotlin.reflect.KClass /** * Provider for intermediate representation of events read from file system. */ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer { + private lateinit var payloadTypeAndRevisionProviderClazz: KClass private lateinit var eventEncoding: UpcasterTest.EventEncoding override fun provideArguments(context: ExtensionContext): Stream { - + // make sure provider is initialized correctly. sanitize() + + // retrieve the test file folder val folderName = context.getTestFolderName() val folder = requireNotNull(context.getTestFolder()) { "Could not access the test data folder $folderName, consider creating it in your resources folder." } - val ending = when (eventEncoding) { - UpcasterTest.EventEncoding.XML -> "xml" - UpcasterTest.EventEncoding.JSON -> "json" - UpcasterTest.EventEncoding.AVRO -> "avro" - } + // retrieve test files + val ending = this.eventEncoding.encodingEnding() val testFiles = folder.getFiles(ending) require(testFiles.isNotEmpty()) { "Could not load any test data files (*.$ending) from provided folder $folderName." } + + // find payload type and revision provider + val payloadTypeAndRevisionProvider = + requireNotNull(context.getPayloadTypeAndRevisionProvider(this.payloadTypeAndRevisionProviderClazz)) + + // FIXME: content provider + val contentProvider = ContentProvider() + + // find serializer + val serializer = + requireNotNull(context.getSerializer(this.eventEncoding)) { "Could not find serializer for $eventEncoding. Consider defining it as a member variable of the test." } + + // construct intermediate representation return Stream.of( Arguments.of( NamedStream( name = "*.$ending files from $folderName", - stream = testFiles.map { it.readText().trim() }.stream() + stream = testFiles.map { file -> + Payload( + content = contentProvider.invoke(file), + payloadType = payloadTypeAndRevisionProvider.getPayloadType(file), + revision = payloadTypeAndRevisionProvider.getRevision(file), + metadata = null // FIXME -> support metadata + ) + }.map { + initialEvent( + entry = it.entry(this.eventEncoding), + serializer = serializer + ) + }.stream() ) ) ) } + @FunctionalInterface + class ContentProvider : (File) -> Any { + override fun invoke(file: File): Any { + return file.readText().trim() + } + } + + class Payload( + val content: Any, + val payloadType: String, + val revision: String? = null, + val metadata: Any? = null + ) { + fun entry(encoding: UpcasterTest.EventEncoding): EventData<*> { + return when (encoding) { + UpcasterTest.EventEncoding.XML -> + xmlTestEventData( + payloadDocument = SAXReader().read( + StringReader(this.content as String) + ), + payloadTypeName = this.payloadType, + metaDataDocument = metadata?.let { + SAXReader().read( + StringReader(metadata as String) + ) + } ?: EMPTY_XML, + revisionNumber = this.revision + ) + + UpcasterTest.EventEncoding.JSON -> jsonTestEventData( + payloadJson = this.content as String, + payloadTypeName = this.payloadType, + metaDataJson = metadata as? String ?: UpcasterTestSupport.EMPTY_JSON, + revisionNumber = this.revision + ) + + else -> throw IllegalArgumentException("Not implemented for $encoding") + } + } + + } + override fun accept(annotation: UpcasterTest) { this.eventEncoding = annotation.eventEncoding + this.payloadTypeAndRevisionProviderClazz = annotation.payloadTypeProvider } private fun sanitize() { require(this::eventEncoding.isInitialized) { "Event encoding must be initialized to use this provider." } + require(this::payloadTypeAndRevisionProviderClazz.isInitialized) { "Payload Type and Revision provider must be initialized to use this provider." } } - class NamedStream(private val name: String, private val stream: Stream): Stream by stream, Named> { + class NamedStream(private val name: String, private val stream: Stream) : Stream by stream, Named> { override fun getName(): String = name - override fun getPayload(): Stream = stream + override fun getPayload(): Stream = stream } + + private fun UpcasterTest.EventEncoding.encodingEnding() = + when (this) { + io.holixon.axon.testing.upcaster.UpcasterTest.EventEncoding.XML -> "xml" + io.holixon.axon.testing.upcaster.UpcasterTest.EventEncoding.JSON -> "json" + io.holixon.axon.testing.upcaster.UpcasterTest.EventEncoding.AVRO -> "avro" + } + } diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt new file mode 100644 index 0000000..2b3d759 --- /dev/null +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt @@ -0,0 +1,19 @@ +package io.holixon.axon.testing.upcaster + +import org.axonframework.serialization.Serializer +import org.junit.jupiter.api.extension.ExtensionContext +import kotlin.reflect.KClass + +/** + * Extracts the serializer from the test instance. + */ +fun ExtensionContext.getSerializer(encoding: UpcasterTest.EventEncoding): Serializer? { + TODO("implement me") +} + +/** + * Extracts the PayloadTypeAndRevisionProvider from the tet instance. + */ +fun ExtensionContext.getPayloadTypeAndRevisionProvider(clazz: KClass): PayloadTypeAndRevisionProvider? { + TODO("implement me") +} diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt index caed334..2044308 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt @@ -2,6 +2,7 @@ package io.holixon.axon.testing.upcaster import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource +import kotlin.reflect.KClass @MustBeDocumented @Target(AnnotationTarget.FUNCTION) @@ -10,6 +11,7 @@ import org.junit.jupiter.params.provider.ArgumentsSource @ArgumentsSource(value = IntermediateRepresentationProvider::class) annotation class UpcasterTest( val eventEncoding: EventEncoding = EventEncoding.JSON, + val payloadTypeProvider: KClass ) { /** * Type of event diff --git a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt index adb5b23..742a409 100644 --- a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt +++ b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt @@ -1,12 +1,24 @@ package io.holixon.axon.testing.upcaster +import com.thoughtworks.xstream.XStream +import com.thoughtworks.xstream.security.AnyTypePermission import org.assertj.core.api.Assertions.assertThat +import org.axonframework.serialization.xml.XStreamSerializer import java.util.stream.Stream import kotlin.streams.toList class IntermediateRepresentationProviderTest { + private val xmlSerializer = XStreamSerializer + .builder() + .lenientDeserialization() + .xStream( + XStream() + .apply { addPermission(AnyTypePermission.ANY) } + ).build() + + @UpcasterTest(eventEncoding = UpcasterTest.EventEncoding.JSON) fun `receives json files`(events: Stream) { assertThat(events.toList()).containsExactly("""{ "json": 1 }""", """{ "json": 2 }""") From 53a386b607d9874d340fa3940d0f019b7de29e1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 18:29:39 +0200 Subject: [PATCH 31/70] chore(deps): bump slf4j-simple from 2.0.6 to 2.0.7 (#306) Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 2.0.6 to 2.0.7. - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.6...v_2.0.7) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index f10b3fe..0f45af6 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -38,7 +38,7 @@ org.slf4j slf4j-simple - 2.0.6 + 2.0.7 test diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index a1e3e18..4b95cc9 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -40,7 +40,7 @@ org.slf4j slf4j-simple - 2.0.6 + 2.0.7 test From 7f3faabf4174fa4efc1e40556287f771dac712fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 18:30:10 +0200 Subject: [PATCH 32/70] chore(deps): bump junit-jupiter from 5.9.1 to 5.9.3 (#305) Bumps [junit-jupiter](https://github.com/junit-team/junit5) from 5.9.1 to 5.9.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.1...r5.9.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6fb441..b21cb12 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 2.15.2 4.13.2 - 5.9.1 + 5.9.3 2.1.4 3.24.2 From 40401caf47ff17049cb997524704c3cf5ed27a6a Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 7 Jul 2023 01:37:10 +0200 Subject: [PATCH 33/70] fixed the build, kotlin is compiled again, implement upcaster test provider with tesst, fix #304 --- .../BankAccountAggregateJgivenKotlinTest.kt | 2 +- .../MoneyTransferSagaJgivenKotlinTest.kt | 2 +- .../AccountCreatedEventUpcastingKotlinTest.kt | 107 ++++++++++ ...account.event.AccountCreatedEvent__12.json | 5 + ...nkaccount.event.AccountCreatedEvent__0.xml | 5 + examples/pom.xml | 1 + extension/pom.xml | 14 -- extension/upcaster/core/pom.xml | 6 +- .../FixedPayloadTypeAndRevisionProvider.kt | 12 -- .../upcaster/MessageContentProvider.kt | 25 +++ .../axon/testing/upcaster/MessageEncoding.kt | 32 +++ .../PayloadTypeAndRevisionProvider.kt | 6 +- .../ConstantMetadataMessageContentProvider.kt | 17 ++ .../DefaultStringMessageContentProvider.kt | 31 +++ .../DelegatingMessageContentProvider.kt | 21 ++ ...unctionalMetadataMessageContentProvider.kt | 19 ++ ...taticTestInstanceMessageContentProvider.kt | 8 + .../axon/testing/upcaster/file/FileUtils.kt | 41 ++++ ...nameBasedPayloadTypeAndRevisionProvider.kt | 25 +++ .../FixedPayloadTypeAndRevisionProvider.kt | 20 ++ ...tInstancePayloadTypeAndRevisionProvider.kt | 8 + .../upcaster/DummyUpcasterParametrizedTest.kt | 5 +- extension/upcaster/junit5/pom.xml | 1 + .../testing/upcaster/ExtensionContextUtils.kt | 116 +++++++++++ .../axon/testing/upcaster/FileUtils.kt | 49 ----- .../IntermediateRepresentationProvider.kt | 182 +++++++++--------- .../upcaster/TestInstanceReflectionUtils.kt | 19 -- .../testing/upcaster/TestReflectionUtils.kt | 35 ++++ .../axon/testing/upcaster/UpcasterTest.kt | 17 +- .../axon/testing/upcaster/FileUtilsTest.kt | 2 + .../IntermediateRepresentationProviderTest.kt | 53 +++-- .../receives_json_events/1__some_event.json | 1 + .../receives_json_events/1__test.xml | 1 + .../2__some_event__2.json | 1 + lib/fixtures/bankaccount/pom.xml | 1 - .../event/AccountCreatedEvent.java | 2 + lib/fixtures/pom.xml | 4 + pom.xml | 157 ++++++++++----- 38 files changed, 793 insertions(+), 260 deletions(-) create mode 100644 examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt create mode 100644 examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json create mode 100644 examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml delete mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageContentProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/ConstantMetadataMessageContentProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DefaultStringMessageContentProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DelegatingMessageContentProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/FunctionalMetadataMessageContentProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/StaticTestInstanceMessageContentProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FilenameBasedPayloadTypeAndRevisionProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FixedPayloadTypeAndRevisionProvider.kt create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/StaticTestInstancePayloadTypeAndRevisionProvider.kt create mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt delete mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt delete mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt create mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestReflectionUtils.kt create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__some_event.json create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__test.xml create mode 100644 extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/2__some_event__2.json diff --git a/examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt b/examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt index 333cc93..d7146e8 100644 --- a/examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt +++ b/examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt @@ -18,7 +18,7 @@ import org.junit.Test class BankAccountAggregateJgivenKotlinTest : AggregateFixtureScenarioTest() { @ProvidedScenarioState - private val fixture = aggregateTestFixtureBuilder(BankAccountAggregate::class).build() + private val fixture = aggregateTestFixtureBuilder().build() @Test fun `create account`() { diff --git a/examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt b/examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt index 46d1c02..91902a9 100644 --- a/examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt +++ b/examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt @@ -15,7 +15,7 @@ import org.junit.Test class MoneyTransferSagaJgivenKotlinTest : SagaFixtureScenarioTest() { @ProvidedScenarioState - private val fixture = sagaTestFixtureBuilder(MoneyTransferSaga::class) + private val fixture = sagaTestFixtureBuilder() .registerStartRecordingCallback({}) .build() diff --git a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt new file mode 100644 index 0000000..7efebda --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt @@ -0,0 +1,107 @@ +package io.holixon.axon.testing.examples.upcaster.junit5.kotlin + +import com.fasterxml.jackson.databind.node.ObjectNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.thoughtworks.xstream.XStream +import com.thoughtworks.xstream.security.AnyTypePermission +import fixture.bankaccount.event.AccountCreatedEvent +import io.holixon.axon.testing.upcaster.MessageEncoding +import io.holixon.axon.testing.upcaster.UpcasterTest +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonNodeUpcaster +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlDocumentUpcaster +import io.holixon.axon.testing.upcaster.content.DefaultStringMessageContentProvider +import io.holixon.axon.testing.upcaster.payloadtype.FilenameBasedPayloadTypeAndRevisionProvider +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.serialization.json.JacksonSerializer +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation +import org.axonframework.serialization.upcasting.event.SingleEventUpcaster +import org.axonframework.serialization.xml.XStreamSerializer +import java.util.stream.Stream + +class AccountCreatedEventUpcastingKotlinTest { + + companion object { + private val xmlSerializer: XStreamSerializer = + XStreamSerializer.builder().lenientDeserialization().xStream(XStream().apply { addPermission(AnyTypePermission.ANY) }).build() + private val jacksonSerializer: JacksonSerializer = JacksonSerializer.builder().lenientDeserialization().objectMapper(jacksonObjectMapper()).build() + } + + @UpcasterTest( + messageEncoding = MessageEncoding.XSTREAM, + payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider::class, + messageContentProvider = DefaultStringMessageContentProvider::class + ) + fun upcasts_account_created_xstream(events: List) { + val payloadType: String = AccountCreatedEvent::class.java.name + val upcaster: SingleEventUpcaster = xmlDocumentUpcaster(payloadType, "0", "1") { + it.apply { + selectNodes("//$payloadType").forEach { node -> + // replace bank account id with account id + val accountId = (node as org.dom4j.Element).addElement("accountId") + val bankAccountId = node.element("bankAccountId") + accountId.addText(bankAccountId.text) + node.remove(bankAccountId) + + // add max balance + val maxBalance: org.dom4j.Element = node.addElement("maximalBalance") + maxBalance.addText("1000") + } + } + } + val upcastedStream: Stream = upcaster.upcast(events.stream()) + val upcastedEvents = upcastedStream.map { ier -> + xmlSerializer.deserialize( + ier.getData( + org.dom4j.Document::class.java + ) + ) + } + assertThat(upcastedEvents) + .hasSize(1) + .element(0) + .isEqualTo( + AccountCreatedEvent + .builder() + .accountId("4711") + .customerId("Customer1") + .initialBalance(100) + .maximalBalance(1000) + .build() + ) + } + + @UpcasterTest( + messageEncoding = MessageEncoding.JACKSON, + payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider::class, + messageContentProvider = DefaultStringMessageContentProvider::class + ) + fun upcasts_account_created_jackson(events: List) { + val payloadType: String = AccountCreatedEvent::class.java.name + val upcaster: SingleEventUpcaster = jsonNodeUpcaster(payloadType, "12", "13") { + (it as ObjectNode).apply { + put("accountId", get("bankAccountId").asText()) + remove("bankAccountId") + put("maximalBalance", 1000) + } + } + val upcastedStream: Stream = upcaster.upcast(events.stream()) + val upcastedEvents = upcastedStream.map { ier -> + val event: AccountCreatedEvent = jacksonSerializer.deserialize( + ier.data + ) + event + } + assertThat(upcastedEvents) + .hasSize(1) + .element(0) + .isEqualTo( + AccountCreatedEvent + .builder() + .accountId("4711") + .customerId("Customer1") + .initialBalance(100) + .maximalBalance(1000) + .build() + ) + } +} diff --git a/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json new file mode 100644 index 0000000..3ebe054 --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json @@ -0,0 +1,5 @@ +{ + "bankAccountId": "4711", + "customerId": "Customer1", + "initialBalance": 100 +} diff --git a/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml new file mode 100644 index 0000000..4e2197a --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml @@ -0,0 +1,5 @@ + + 4711 + Customer1 + 100 + diff --git a/examples/pom.xml b/examples/pom.xml index e0e2b9e..576ffa2 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -20,6 +20,7 @@ bankaccount-jgiven-junit4 bankaccount-jgiven-junit5 + bankaccount-upcaster-junit5 diff --git a/extension/pom.xml b/extension/pom.xml index 403d72b..1cdaf1c 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -22,20 +22,6 @@ org.jetbrains.kotlin kotlin-reflect - - org.jetbrains.kotlin - kotlin-stdlib - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - org.jetbrains.kotlin - kotlin-maven-plugin - - - diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index 2613045..aa5fccb 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -35,7 +35,11 @@ dom4j ${dom4j.version} - + + jaxen + jaxen + ${jaxen.version} + org.junit.jupiter diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt deleted file mode 100644 index 619cd61..0000000 --- a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/FixedPayloadTypeAndRevisionProvider.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.holixon.axon.testing.upcaster - -/** - * PayloadTypeAndRevisionProvider returning fixed values. - */ -class FixedPayloadTypeAndRevisionProvider( - private val payloadTypeName: String, - private val payloadRevision: String? -) : PayloadTypeAndRevisionProvider { - override fun getPayloadType(payload: Any): String = payloadTypeName - override fun getRevision(payload: Any): String? = payloadRevision -} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageContentProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageContentProvider.kt new file mode 100644 index 0000000..bc0577e --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageContentProvider.kt @@ -0,0 +1,25 @@ +package io.holixon.axon.testing.upcaster + +import java.io.File + +/** + * Reads message file and retrieves the payload and metadata of the message. + */ +interface MessageContentProvider { + + /** + * Retrieves message payload. + * @param file message file. + * @param messageEncoding encoding. + * @return content. + */ + fun getMessagePayload(file: File, messageEncoding: MessageEncoding): Any + + /** + * Retrieves message metadata. + * @param file message file. + * @param messageEncoding encoding. + * @return metadata or null. + */ + fun getMessageMetadata(file: File, messageEncoding: MessageEncoding): Any +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt new file mode 100644 index 0000000..8e17d34 --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt @@ -0,0 +1,32 @@ +package io.holixon.axon.testing.upcaster + +/** + * Event encoding. + */ +enum class MessageEncoding { + /** + * XML written by XStream. + */ + XSTREAM, + + /** + * JSON written by Jackson. + */ + JACKSON, + + /** + * AVRO single object encoded format. + */ + AVRO_SINGLE_OBJECT; + + /** + * Retrieves the default file ending for specified encoding. + */ + fun defaultFileEnding() = + when (this) { + XSTREAM -> "xml" + JACKSON -> "json" + AVRO_SINGLE_OBJECT -> "avro" // FIXME: what is the best ending here -> @jangalinski + } + +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt index 3be78ae..f0d87b7 100644 --- a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/PayloadTypeAndRevisionProvider.kt @@ -1,6 +1,8 @@ package io.holixon.axon.testing.upcaster +import java.io.File + interface PayloadTypeAndRevisionProvider { - fun getPayloadType(payload: Any): String - fun getRevision(payload: Any): String? + fun getPayloadType(ending: String, file: File): String + fun getRevision(ending: String, file: File): String? } diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/ConstantMetadataMessageContentProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/ConstantMetadataMessageContentProvider.kt new file mode 100644 index 0000000..d5bc091 --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/ConstantMetadataMessageContentProvider.kt @@ -0,0 +1,17 @@ +package io.holixon.axon.testing.upcaster.content + +import io.holixon.axon.testing.upcaster.MessageContentProvider +import io.holixon.axon.testing.upcaster.MessageEncoding +import java.io.File + +class ConstantMetadataMessageContentProvider( + private val fixedMetaData: Any +) : MessageContentProvider { + override fun getMessagePayload(file: File, messageEncoding: MessageEncoding): Any { + throw UnsupportedOperationException("Metadata message content provider can't be used to extract message content.") + } + + override fun getMessageMetadata(file: File, messageEncoding: MessageEncoding): Any { + return fixedMetaData + } +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DefaultStringMessageContentProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DefaultStringMessageContentProvider.kt new file mode 100644 index 0000000..a8af88c --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DefaultStringMessageContentProvider.kt @@ -0,0 +1,31 @@ +package io.holixon.axon.testing.upcaster.content + +import io.holixon.axon.testing.upcaster.MessageContentProvider +import io.holixon.axon.testing.upcaster.MessageEncoding +import io.holixon.axon.testing.upcaster.UpcasterTestSupport +import org.dom4j.io.SAXReader +import java.io.File +import java.io.StringReader + +/** + * Returns content as string. + */ +class DefaultStringMessageContentProvider : MessageContentProvider { + + override fun getMessagePayload(file: File, messageEncoding: MessageEncoding): Any { + val contentAsString = file.readText().trim() + return when (messageEncoding) { + MessageEncoding.JACKSON -> contentAsString + MessageEncoding.XSTREAM -> SAXReader().read(StringReader(contentAsString)) + else -> throw IllegalArgumentException("Unsupported encoding format $messageEncoding") + } + } + + override fun getMessageMetadata(file: File, messageEncoding: MessageEncoding): Any { + return when (messageEncoding) { + MessageEncoding.JACKSON -> UpcasterTestSupport.EMPTY_JSON + MessageEncoding.XSTREAM -> UpcasterTestSupport.EMPTY_XML + else -> throw IllegalArgumentException("Unsupported encoding format $messageEncoding") + } + } +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DelegatingMessageContentProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DelegatingMessageContentProvider.kt new file mode 100644 index 0000000..a9e4949 --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/DelegatingMessageContentProvider.kt @@ -0,0 +1,21 @@ +package io.holixon.axon.testing.upcaster.content + +import io.holixon.axon.testing.upcaster.MessageContentProvider +import io.holixon.axon.testing.upcaster.MessageEncoding +import java.io.File + +/** + * Delegates to other message content providers. + */ +class DelegatingMessageContentProvider( + private val contentMessageContentProvider: MessageContentProvider, + private val metadataMessageContentProvider: MessageContentProvider +) : MessageContentProvider { + override fun getMessagePayload(file: File, messageEncoding: MessageEncoding): Any { + return contentMessageContentProvider.getMessagePayload(file, messageEncoding) + } + + override fun getMessageMetadata(file: File, messageEncoding: MessageEncoding): Any { + return metadataMessageContentProvider.getMessageMetadata(file, messageEncoding) + } +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/FunctionalMetadataMessageContentProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/FunctionalMetadataMessageContentProvider.kt new file mode 100644 index 0000000..e183d59 --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/FunctionalMetadataMessageContentProvider.kt @@ -0,0 +1,19 @@ +package io.holixon.axon.testing.upcaster.content + +import io.holixon.axon.testing.upcaster.MessageContentProvider +import io.holixon.axon.testing.upcaster.MessageEncoding +import java.io.File + +/** + * Functional implementation for inline implementations. + */ +@FunctionalInterface +interface FunctionalMetadataMessageContentProvider : MessageContentProvider, (File, MessageEncoding) -> Any { + override fun getMessagePayload(file: File, messageEncoding: MessageEncoding): Any { + throw UnsupportedOperationException("Metadata message content provider can't be used to extract message content.") + } + + override fun getMessageMetadata(file: File, messageEncoding: MessageEncoding): Any { + return invoke(file, messageEncoding) + } +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/StaticTestInstanceMessageContentProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/StaticTestInstanceMessageContentProvider.kt new file mode 100644 index 0000000..e1bb145 --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/StaticTestInstanceMessageContentProvider.kt @@ -0,0 +1,8 @@ +package io.holixon.axon.testing.upcaster.content + +import io.holixon.axon.testing.upcaster.MessageContentProvider + +/** + * Marker implementation delegating to the provider retrieved from the instance variable of the test. + */ +class StaticTestInstanceMessageContentProvider(impl: MessageContentProvider) : MessageContentProvider by impl diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt new file mode 100644 index 0000000..84523bf --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt @@ -0,0 +1,41 @@ +package io.holixon.axon.testing.upcaster.file + +import java.io.File +import java.io.FileFilter + +/** + * Retrieves a regex to match files with given ending. + * Will match files starting with digits having a name separated by a double underscore ("9234__my_file.txt") + * @param ending the desired ending without the leading dot. ("jpg") + */ +fun numberedFileRegex(ending: String) = Regex("^([0-9]+)_{2}(.*)(\\.$ending)$") + + +/** + * Extracts the effective part of the file name matching the numbered file regex with given extension ("9234__my_file__123.txt"). + * @param ending the desired ending without the leading dot. ("txt") + * @return effective name ("my_file__123"). + */ +fun File.extractEffectiveName(ending: String): String { + val regex = numberedFileRegex(ending) + require(this.name.matches(regex)) { "Provided file name ${this.name} must match the expected numbered file pattern ${regex.pattern}." } + // 0. string is the entire match, 2. string is the second group + return regex.find(this.name)?.groups?.get(2)?.value ?: throw IllegalArgumentException("Could not extract effective name from ${this.name}") +} + +/** + * Retrieve numbered files with given ending, sorted by the leading number descending. + * @param ending desired end of file without dot. + */ +fun File.getFiles(ending: String): List { + require(this.isDirectory) { "Provided reference ${this.name} must be a folder, but it was not." } + val regex = numberedFileRegex(ending) + val files = this.listFiles(FileFilter { + it.isFile + && it.name.matches(regex) + })?.toList() ?: listOf() + return files.sortedBy { + // 0. string is the entire match, 1. string is the first group + regex.find(it.name)?.groups?.get(1)?.value?.toInt() ?: throw IllegalArgumentException("Could not extract file number from file name ${this.name}") + } +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FilenameBasedPayloadTypeAndRevisionProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FilenameBasedPayloadTypeAndRevisionProvider.kt new file mode 100644 index 0000000..d6e674b --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FilenameBasedPayloadTypeAndRevisionProvider.kt @@ -0,0 +1,25 @@ +package io.holixon.axon.testing.upcaster.payloadtype + +import io.holixon.axon.testing.upcaster.PayloadTypeAndRevisionProvider +import io.holixon.axon.testing.upcaster.file.extractEffectiveName +import java.io.File + +/** + * Detect payload type and revision based on filename of the event. + */ +class FilenameBasedPayloadTypeAndRevisionProvider : PayloadTypeAndRevisionProvider { + + companion object { + val REGEX = Regex("__") + } + + override fun getPayloadType(ending: String, file: File): String { + val name = file.extractEffectiveName(ending) + return name.split(REGEX)[0] + } + + override fun getRevision(ending: String, file: File): String? { + val name = file.extractEffectiveName(ending) + return name.split(REGEX).getOrNull(1) + } +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FixedPayloadTypeAndRevisionProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FixedPayloadTypeAndRevisionProvider.kt new file mode 100644 index 0000000..302ec1e --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/FixedPayloadTypeAndRevisionProvider.kt @@ -0,0 +1,20 @@ +package io.holixon.axon.testing.upcaster.payloadtype + +import io.holixon.axon.testing.upcaster.MessageEncoding +import io.holixon.axon.testing.upcaster.PayloadTypeAndRevisionProvider +import java.io.File + +/** + * PayloadTypeAndRevisionProvider returning fixed values. + */ +class FixedPayloadTypeAndRevisionProvider( + private val payloadTypeName: String, + private val payloadRevision: String? +) : PayloadTypeAndRevisionProvider { + override fun getPayloadType(ending: String, file: File): String = getPayloadType() + override fun getRevision(ending: String, file: File): String? = getRevision() + + + fun getPayloadType(): String = payloadTypeName + fun getRevision(): String? = payloadRevision +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/StaticTestInstancePayloadTypeAndRevisionProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/StaticTestInstancePayloadTypeAndRevisionProvider.kt new file mode 100644 index 0000000..ed6042a --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/payloadtype/StaticTestInstancePayloadTypeAndRevisionProvider.kt @@ -0,0 +1,8 @@ +package io.holixon.axon.testing.upcaster.payloadtype + +import io.holixon.axon.testing.upcaster.PayloadTypeAndRevisionProvider + +/** + * Marker implementation delegating to the provider retrieved from the instance variable of the test. + */ +class StaticTestInstancePayloadTypeAndRevisionProvider(impl: PayloadTypeAndRevisionProvider) : PayloadTypeAndRevisionProvider by impl diff --git a/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt index b4228a3..bfaa964 100644 --- a/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt +++ b/extension/upcaster/core/src/test/kotlin/io/holixon/axon/testing/upcaster/DummyUpcasterParametrizedTest.kt @@ -5,6 +5,7 @@ import com.thoughtworks.xstream.security.AnyTypePermission import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.initialEvent import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlDocumentUpcaster import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlTestEventData +import io.holixon.axon.testing.upcaster.payloadtype.FixedPayloadTypeAndRevisionProvider import org.assertj.core.api.Assertions.assertThat import org.axonframework.serialization.upcasting.event.EventUpcasterChain import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation @@ -37,8 +38,8 @@ class DummyUpcasterParametrizedTest { initialEvent( entry = xmlTestEventData( xml, - fixedPayloadTypeAndRevisionProvider.getPayloadType(xml), - fixedPayloadTypeAndRevisionProvider.getRevision(xml) + fixedPayloadTypeAndRevisionProvider.getPayloadType(), + fixedPayloadTypeAndRevisionProvider.getRevision() ), serializer = xmlSerializer ) diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index 50a25bf..4d41c86 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -24,6 +24,7 @@ ${junit5.version} + org.assertj assertj-core diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt new file mode 100644 index 0000000..6aa793a --- /dev/null +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt @@ -0,0 +1,116 @@ +package io.holixon.axon.testing.upcaster + +import io.holixon.axon.testing.upcaster.content.StaticTestInstanceMessageContentProvider +import io.holixon.axon.testing.upcaster.payloadtype.StaticTestInstancePayloadTypeAndRevisionProvider +import org.axonframework.serialization.Serializer +import org.axonframework.serialization.json.JacksonSerializer +import org.axonframework.serialization.xml.XStreamSerializer +import org.junit.jupiter.api.extension.ExtensionContext +import java.io.File +import java.lang.reflect.ParameterizedType +import java.nio.file.Files +import kotlin.io.path.Path +import kotlin.reflect.KClass +import kotlin.reflect.full.primaryConstructor + +/** + * Retrieves the test folder for this test context. + */ +fun ExtensionContext.getTestFolder(): File? { + val folderPathAsString = IntermediateRepresentationProvider::class.java.getResource("/" + getTestFolderName())?.path ?: return null + val path = Path(folderPathAsString) + return if (Files.exists(path) && path.toFile().isDirectory) { + path.toFile() + } else { + null + } +} + +/** + * Retrieves the test folder name for this test context. + */ +fun ExtensionContext.getTestFolderName(): String = + (this.requiredTestClass.canonicalName + "." + this.requiredTestMethod.name.replace(' ', '_')).replace('.', '/') + +/** + * Tries to detect the parameter type of the parametrized method. + */ +fun ExtensionContext.detectParameterType(): Class<*>? { + return if ( + this.requiredTestMethod.genericParameterTypes.isNotEmpty() + && this.requiredTestMethod.genericParameterTypes[0] is ParameterizedType + && (this.requiredTestMethod.genericParameterTypes[0] as ParameterizedType).actualTypeArguments.isNotEmpty() + && ((this.requiredTestMethod.genericParameterTypes[0] as ParameterizedType).actualTypeArguments[0] is Class<*>) + ) { + (this.requiredTestMethod.genericParameterTypes[0] as ParameterizedType).actualTypeArguments[0] as Class<*> + } else { + null + } +} + +/** + * Extracts the serializer from the test instance. + */ +fun ExtensionContext.getSerializer(encoding: MessageEncoding): Serializer? { + if (this.testClass.isEmpty) { + return null + } + val targetType: KClass = when (encoding) { + MessageEncoding.XSTREAM -> XStreamSerializer::class + MessageEncoding.JACKSON -> JacksonSerializer::class + else -> Serializer::class + } + return try { + this.testClass.get().getInstanceVariableValue(targetType, null, targetType) + } catch (e: Exception) { + null + } +} + +/** + * Extracts the PayloadTypeAndRevisionProvider from the tet instance. + */ +fun ExtensionContext.getPayloadTypeAndRevisionProvider(clazz: KClass): PayloadTypeAndRevisionProvider? { + if (this.testClass.isEmpty) { + return null + } + return if (clazz == StaticTestInstancePayloadTypeAndRevisionProvider::class) { + try { + this.testClass.get().getInstanceVariableValue(PayloadTypeAndRevisionProvider::class, null, PayloadTypeAndRevisionProvider::class) + } catch (e: Exception) { + this.publishReportEntry("ERROR}") + null + } + } else { + try { + return clazz.primaryConstructor?.call() + } catch (e: Exception) { + this.publishReportEntry("ERROR}") + null + } + } +} + +/** + * Extracts the MessageContentProvider from the instance or instantiates one. + */ +fun ExtensionContext.getMessageContentProvider(clazz: KClass): MessageContentProvider? { + if (this.testClass.isEmpty) { + return null + } + return if (clazz == StaticTestInstanceMessageContentProvider::class) { + try { + this.testClass.get().getInstanceVariableValue(MessageContentProvider::class, null, MessageContentProvider::class) + } catch (e: Exception) { + null + } + } else { + try { + return clazz.primaryConstructor?.call() + } catch (e: Exception) { + null + } + } +} + + diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt deleted file mode 100644 index 0025157..0000000 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/FileUtils.kt +++ /dev/null @@ -1,49 +0,0 @@ -package io.holixon.axon.testing.upcaster - -import org.junit.jupiter.api.extension.ExtensionContext -import java.io.File -import java.io.FileFilter -import java.nio.file.Files -import kotlin.io.path.Path - -/** - * Retrieves the test folder for this test context. - */ -fun ExtensionContext.getTestFolder(): File? { - val folderPathAsString = IntermediateRepresentationProvider::class.java.getResource("/" + getTestFolderName())?.path ?: return null - val path = Path(folderPathAsString) - return if (Files.exists(path) && path.toFile().isDirectory) { - path.toFile() - } else { - null - } -} - -/** - * Retrieves the test folder name for this test context. - */ -fun ExtensionContext.getTestFolderName(): String = - (this.requiredTestClass.canonicalName + "." + this.requiredTestMethod.name.replace(' ', '_')).replace('.', '/') - - -/** - * Retrieves a regex to match files with given ending. - * Will match files starting with digits having a name separated by a double underscore ("9234__my_file.txt") - * @param ending the desired ending without the leading dot. ("jpg") - */ -fun numberedFileRegex(ending: String) = Regex("^([0-9]+)_{2}(.*)(\\.$ending)$") - -/** - * Retrieve numbered files with given ending, sorted by the leading number descending. - * @param ending desired end of file without dot. - */ -fun File.getFiles(ending: String): List { - require(this.isDirectory) { "Provided reference ${this.name} must be a folder, but it was not." } - val regex = numberedFileRegex(ending) - val files = this.listFiles(FileFilter { - it.isFile - && it.name.matches(regex) - })?.toList() ?: listOf() - return files.sortedBy { regex.find(it.name)!!.groups[1]!!.value.toInt() } -} - diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt index 1007691..9d95250 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt @@ -1,18 +1,18 @@ package io.holixon.axon.testing.upcaster -import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.EMPTY_XML -import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.initialEvent -import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonTestEventData -import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlTestEventData -import org.axonframework.eventhandling.EventData -import org.dom4j.io.SAXReader +import io.holixon.axon.testing.upcaster.UpcasterTest.Companion.DEFAULT_FILE_ENDING +import io.holixon.axon.testing.upcaster.file.getFiles +import org.axonframework.serialization.upcasting.event.InitialEventRepresentation +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation import org.junit.jupiter.api.Named import org.junit.jupiter.api.extension.ExtensionContext import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.ArgumentsProvider import org.junit.jupiter.params.support.AnnotationConsumer +import org.junit.platform.commons.PreconditionViolationException +import org.junit.platform.commons.util.Preconditions.condition +import org.junit.platform.commons.util.Preconditions.notNull import java.io.File -import java.io.StringReader import java.util.stream.Stream import kotlin.reflect.KClass @@ -21,8 +21,10 @@ import kotlin.reflect.KClass */ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer { - private lateinit var payloadTypeAndRevisionProviderClazz: KClass - private lateinit var eventEncoding: UpcasterTest.EventEncoding + private lateinit var payloadTypeAndRevisionProviderClazz: KClass + private lateinit var contentProviderClazz: KClass + private lateinit var messageEncoding: MessageEncoding + private lateinit var messageFileEnding: String override fun provideArguments(context: ExtensionContext): Stream { // make sure provider is initialized correctly. @@ -30,109 +32,111 @@ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer // retrieve the test file folder val folderName = context.getTestFolderName() - val folder = requireNotNull(context.getTestFolder()) { "Could not access the test data folder $folderName, consider creating it in your resources folder." } + val folder = notNull( + context.getTestFolder(), + "Could not access the test data folder $folderName, consider creating it in your resources folder." + )!! // retrieve test files - val ending = this.eventEncoding.encodingEnding() + val ending = this.messageEncoding.defaultFileEnding() val testFiles = folder.getFiles(ending) - require(testFiles.isNotEmpty()) { "Could not load any test data files (*.$ending) from provided folder $folderName." } + condition( + testFiles.isNotEmpty(), + "Could not load any test data files (*.$ending) from provided folder $folderName." + ) // find payload type and revision provider val payloadTypeAndRevisionProvider = - requireNotNull(context.getPayloadTypeAndRevisionProvider(this.payloadTypeAndRevisionProviderClazz)) - - // FIXME: content provider - val contentProvider = ContentProvider() + notNull( + context.getPayloadTypeAndRevisionProvider(this.payloadTypeAndRevisionProviderClazz), + "Payload type and revision provider could not be initialized. You configured ${payloadTypeAndRevisionProviderClazz.simpleName}." + )!! + + // content provider + val contentProvider = + notNull( + context.getMessageContentProvider(this.contentProviderClazz), + "Message content provider could not be initialized. You configured ${contentProviderClazz.simpleName}." + )!! // find serializer - val serializer = - requireNotNull(context.getSerializer(this.eventEncoding)) { "Could not find serializer for $eventEncoding. Consider defining it as a member variable of the test." } - - // construct intermediate representation - return Stream.of( - Arguments.of( - NamedStream( + val serializer = notNull( + context.getSerializer(this.messageEncoding), + "Could not find serializer for $messageEncoding. Please provide is as a static member variable of the test." + )!! + + // guess the type + val parameterType = context.detectParameterType() ?: IntermediateEventRepresentation::class.java + + return when (parameterType) { + // events + IntermediateEventRepresentation::class.java -> { + NamedList( + name = "*.$ending events from $folderName", + payload = testFiles + .map { file -> + Payload( + payloadType = payloadTypeAndRevisionProvider.getPayloadType(ending, file), + revision = payloadTypeAndRevisionProvider.getRevision(ending, file), + content = contentProvider.getMessagePayload(file, this.messageEncoding), + metadata = contentProvider.getMessageMetadata(file, this.messageEncoding) + ) + }.map { + InitialEventRepresentation(it.constructEntry(this.messageEncoding), serializer) + } + ) + } + // files + File::class.java -> { + NamedList( name = "*.$ending files from $folderName", - stream = testFiles.map { file -> - Payload( - content = contentProvider.invoke(file), - payloadType = payloadTypeAndRevisionProvider.getPayloadType(file), - revision = payloadTypeAndRevisionProvider.getRevision(file), - metadata = null // FIXME -> support metadata - ) - }.map { - initialEvent( - entry = it.entry(this.eventEncoding), - serializer = serializer - ) - }.stream() + payload = testFiles ) - ) - ) - } - - @FunctionalInterface - class ContentProvider : (File) -> Any { - override fun invoke(file: File): Any { - return file.readText().trim() - } - } - - class Payload( - val content: Any, - val payloadType: String, - val revision: String? = null, - val metadata: Any? = null - ) { - fun entry(encoding: UpcasterTest.EventEncoding): EventData<*> { - return when (encoding) { - UpcasterTest.EventEncoding.XML -> - xmlTestEventData( - payloadDocument = SAXReader().read( - StringReader(this.content as String) - ), - payloadTypeName = this.payloadType, - metaDataDocument = metadata?.let { - SAXReader().read( - StringReader(metadata as String) - ) - } ?: EMPTY_XML, - revisionNumber = this.revision - ) - - UpcasterTest.EventEncoding.JSON -> jsonTestEventData( - payloadJson = this.content as String, - payloadTypeName = this.payloadType, - metaDataJson = metadata as? String ?: UpcasterTestSupport.EMPTY_JSON, - revisionNumber = this.revision + } + // file content + String::class.java -> { + NamedList( + name = "*.$ending file content from $folderName", + payload = testFiles.map { file -> + file.readText().trim() + } ) + } - else -> throw IllegalArgumentException("Not implemented for $encoding") + else -> { + throw PreconditionViolationException("Unsupported parameter type: $parameterType") } + }.let { + Stream.of(Arguments.of(it)) } - } + override fun accept(annotation: UpcasterTest) { - this.eventEncoding = annotation.eventEncoding + this.messageEncoding = annotation.messageEncoding this.payloadTypeAndRevisionProviderClazz = annotation.payloadTypeProvider + this.contentProviderClazz = annotation.messageContentProvider + this.messageFileEnding = if (annotation.messageFileEnding == DEFAULT_FILE_ENDING) { + this.messageEncoding.defaultFileEnding() + } else { + annotation.messageFileEnding + } } private fun sanitize() { - require(this::eventEncoding.isInitialized) { "Event encoding must be initialized to use this provider." } - require(this::payloadTypeAndRevisionProviderClazz.isInitialized) { "Payload Type and Revision provider must be initialized to use this provider." } + condition(this::messageEncoding.isInitialized, "Event encoding must be initialized.") + condition(this::payloadTypeAndRevisionProviderClazz.isInitialized, "Payload Type and Revision provider must be initialized."); + condition(this::contentProviderClazz.isInitialized, "Message content provider must be initialized."); + condition(this::messageFileEnding.isInitialized, "Message file ending must be initialized."); } - class NamedStream(private val name: String, private val stream: Stream) : Stream by stream, Named> { + + /** + * Named list. + */ + class NamedList(private val name: String, private val payload: List) : List by payload, Named> { override fun getName(): String = name - override fun getPayload(): Stream = stream + override fun getPayload(): List = payload } - - private fun UpcasterTest.EventEncoding.encodingEnding() = - when (this) { - io.holixon.axon.testing.upcaster.UpcasterTest.EventEncoding.XML -> "xml" - io.holixon.axon.testing.upcaster.UpcasterTest.EventEncoding.JSON -> "json" - io.holixon.axon.testing.upcaster.UpcasterTest.EventEncoding.AVRO -> "avro" - } - } + diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt deleted file mode 100644 index 2b3d759..0000000 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestInstanceReflectionUtils.kt +++ /dev/null @@ -1,19 +0,0 @@ -package io.holixon.axon.testing.upcaster - -import org.axonframework.serialization.Serializer -import org.junit.jupiter.api.extension.ExtensionContext -import kotlin.reflect.KClass - -/** - * Extracts the serializer from the test instance. - */ -fun ExtensionContext.getSerializer(encoding: UpcasterTest.EventEncoding): Serializer? { - TODO("implement me") -} - -/** - * Extracts the PayloadTypeAndRevisionProvider from the tet instance. - */ -fun ExtensionContext.getPayloadTypeAndRevisionProvider(clazz: KClass): PayloadTypeAndRevisionProvider? { - TODO("implement me") -} diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestReflectionUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestReflectionUtils.kt new file mode 100644 index 0000000..3961f95 --- /dev/null +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/TestReflectionUtils.kt @@ -0,0 +1,35 @@ +package io.holixon.axon.testing.upcaster + +import kotlin.reflect.KClass + +fun Class<*>.getInstanceVariableValue(variableType: KClass, instance: Any?, variableValueTypeHint: KClass): T { + val candidates = this.declaredFields.filter { + it.type == variableType.java + } + + + val values = candidates.mapNotNull { field -> + try { + field.isAccessible = true + val value = field.get(instance) + if (variableValueTypeHint.java.isAssignableFrom(value.javaClass)) { + @Suppress("UNCHECKED_CAST") + value as T + } else { + null + } + } catch (e: Exception) { + null + } + } + + require(values.size == 1) { + "Expecting to find exactly one instance variable of type ${variableType.simpleName}, but found ${candidates.size}: ${ + candidates.joinToString( + ", " + ) { candidate -> candidate.name } + }" + } + return values.first() +} + diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt index 2044308..b8a3cac 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt @@ -1,5 +1,7 @@ package io.holixon.axon.testing.upcaster +import io.holixon.axon.testing.upcaster.content.StaticTestInstanceMessageContentProvider +import io.holixon.axon.testing.upcaster.payloadtype.StaticTestInstancePayloadTypeAndRevisionProvider import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource import kotlin.reflect.KClass @@ -10,15 +12,12 @@ import kotlin.reflect.KClass @ParameterizedTest(name = "Using {arguments}") @ArgumentsSource(value = IntermediateRepresentationProvider::class) annotation class UpcasterTest( - val eventEncoding: EventEncoding = EventEncoding.JSON, - val payloadTypeProvider: KClass + val messageEncoding: MessageEncoding = MessageEncoding.JACKSON, + val payloadTypeProvider: KClass = StaticTestInstancePayloadTypeAndRevisionProvider::class, + val messageContentProvider: KClass = StaticTestInstanceMessageContentProvider::class, + val messageFileEnding: String = DEFAULT_FILE_ENDING ) { - /** - * Type of event - */ - enum class EventEncoding { - XML, - JSON, - AVRO + companion object { + const val DEFAULT_FILE_ENDING = "__DEFAULT" } } diff --git a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt index c97699e..e68851e 100644 --- a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt +++ b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/FileUtilsTest.kt @@ -1,5 +1,7 @@ package io.holixon.axon.testing.upcaster +import io.holixon.axon.testing.upcaster.file.getFiles +import io.holixon.axon.testing.upcaster.file.numberedFileRegex import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtensionContext diff --git a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt index 742a409..cf6004f 100644 --- a/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt +++ b/extension/upcaster/junit5/src/test/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest.kt @@ -1,32 +1,55 @@ package io.holixon.axon.testing.upcaster +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.thoughtworks.xstream.XStream import com.thoughtworks.xstream.security.AnyTypePermission +import io.holixon.axon.testing.upcaster.content.DefaultStringMessageContentProvider +import io.holixon.axon.testing.upcaster.payloadtype.FilenameBasedPayloadTypeAndRevisionProvider +import io.holixon.axon.testing.upcaster.payloadtype.FixedPayloadTypeAndRevisionProvider import org.assertj.core.api.Assertions.assertThat +import org.axonframework.serialization.json.JacksonSerializer +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation import org.axonframework.serialization.xml.XStreamSerializer -import java.util.stream.Stream -import kotlin.streams.toList class IntermediateRepresentationProviderTest { - private val xmlSerializer = XStreamSerializer - .builder() - .lenientDeserialization() - .xStream( - XStream() - .apply { addPermission(AnyTypePermission.ANY) } - ).build() + companion object { + val xmlSerializer = XStreamSerializer + .builder() + .lenientDeserialization() + .xStream( + XStream() + .apply { addPermission(AnyTypePermission.ANY) } + ).build() + val jsonValueSerializer = JacksonSerializer.builder().objectMapper(jacksonObjectMapper().findAndRegisterModules()).build() - @UpcasterTest(eventEncoding = UpcasterTest.EventEncoding.JSON) - fun `receives json files`(events: Stream) { - assertThat(events.toList()).containsExactly("""{ "json": 1 }""", """{ "json": 2 }""") + val messageContentProvider: MessageContentProvider = DefaultStringMessageContentProvider() + val payloadTypeAndRevisionProvider: PayloadTypeAndRevisionProvider = FixedPayloadTypeAndRevisionProvider("event", "1") } - @UpcasterTest(eventEncoding = UpcasterTest.EventEncoding.XML) - fun `receives xml files`(events: Stream) { - assertThat(events.toList()).containsExactly("""1""", """2""") + @UpcasterTest( + messageEncoding = MessageEncoding.JACKSON, + ) + fun `receives json files`(events: List) { + assertThat(events).containsExactly("""{ "json": 1 }""", """{ "json": 2 }""") + } + + @UpcasterTest( + messageEncoding = MessageEncoding.JACKSON, + ) + fun `receives json events`(events: List) { + assertThat(events).hasSize(2) + } + + @UpcasterTest( + messageEncoding = MessageEncoding.XSTREAM, + payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider::class, + messageContentProvider = DefaultStringMessageContentProvider::class + ) + fun `receives xml files`(events: List) { + assertThat(events).containsExactly("""1""", """2""") } } diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__some_event.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__some_event.json new file mode 100644 index 0000000..bdfa100 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__some_event.json @@ -0,0 +1 @@ +{ "json": 1 } diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__test.xml b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__test.xml new file mode 100644 index 0000000..936a4dc --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/1__test.xml @@ -0,0 +1 @@ +1 diff --git a/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/2__some_event__2.json b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/2__some_event__2.json new file mode 100644 index 0000000..03c2e70 --- /dev/null +++ b/extension/upcaster/junit5/src/test/resources/io/holixon/axon/testing/upcaster/IntermediateRepresentationProviderTest/receives_json_events/2__some_event__2.json @@ -0,0 +1 @@ +{ "json": 2 } diff --git a/lib/fixtures/bankaccount/pom.xml b/lib/fixtures/bankaccount/pom.xml index a43bdf0..f254323 100644 --- a/lib/fixtures/bankaccount/pom.xml +++ b/lib/fixtures/bankaccount/pom.xml @@ -11,5 +11,4 @@ io.holixon.axon.testing.lib axon-testing-fixtures-bankaccount - diff --git a/lib/fixtures/bankaccount/src/main/java/fixture/bankaccount/event/AccountCreatedEvent.java b/lib/fixtures/bankaccount/src/main/java/fixture/bankaccount/event/AccountCreatedEvent.java index 5a5fc61..c991955 100644 --- a/lib/fixtures/bankaccount/src/main/java/fixture/bankaccount/event/AccountCreatedEvent.java +++ b/lib/fixtures/bankaccount/src/main/java/fixture/bankaccount/event/AccountCreatedEvent.java @@ -3,11 +3,13 @@ import lombok.Builder; import lombok.NonNull; import lombok.Value; +import lombok.extern.jackson.Jacksonized; import org.axonframework.serialization.Revision; @Value @Builder(toBuilder = true) @Revision("1") +@Jacksonized public class AccountCreatedEvent { @NonNull diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index b1481b7..65acac5 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -35,6 +35,10 @@ org.axonframework axon-eventsourcing + + com.fasterxml.jackson.core + jackson-databind + org.projectlombok lombok diff --git a/pom.xml b/pom.xml index c6fb441..450fb1f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 Axon Testing - Parent A set of tools to write even more effective tests for systems built with Axon Framework. @@ -19,8 +19,6 @@ 11 - ${java.version} - ${java.version} 1.8.22 @@ -33,6 +31,7 @@ 4.13.2 5.9.1 2.1.4 + 1.2.0 3.24.2 @@ -108,6 +107,22 @@ + + + org.jetbrains.kotlin + kotlin-stdlib + + + org.jetbrains.kotlin + kotlin-stdlib-common + + + org.jetbrains.kotlin + kotlin-test + test + + + clean package @@ -123,36 +138,50 @@ org.jetbrains.kotlin kotlin-maven-plugin ${kotlin.version} + + ${java.version} + 1.8 + 1.8 + + -Xjsr305=strict + -Xjvm-default=all-compatibility + + + spring + all-open + + + + + compile + compile compile + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + test-compile + test-compile test-compile + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + - - 11 - 1.9 - 1.9 - - spring - all-open - - - - - - -Xjsr305=strict - -Xjvm-default=all-compatibility - - org.jetbrains.kotlin @@ -168,8 +197,9 @@ 3.11.0 ${project.build.sourceEncoding} - ${maven.compiler.source} - ${maven.compiler.target} + ${java.version} + ${java.version} + ${java.version} @@ -195,9 +225,6 @@ testCompile - - ${skipTests} - @@ -253,12 +280,21 @@ prepare-agent + + ${project.build.directory}/coverage-reports/jacoco-ut.exec + surefireArgLine + - report-unit-test + post-unit-test + test report + + ${project.build.directory}/coverage-reports/jacoco-ut.exec + ${project.reporting.outputDirectory}/jacoco-ut + @@ -277,8 +313,7 @@ **/*Test_*.java **/*Tests_*.java - -Djava.awt.headless=true ${argLine} -XX:+StartAttachListener -Xmx1024m -XX:MaxPermSize=256m - ${surefireArgLine} + -Djava.awt.headless=true ${surefireArgLine} -XX:+StartAttachListener -Xmx1024m 1.7.30 2.13.3 @@ -446,6 +481,26 @@ + + + org.codehaus.mojo + build-helper-maven-plugin + 3.4.0 + + + add-kotlin-source + generate-sources + + add-source + + + + ${project.basedir}/src/main/kotlin + + + + + @@ -461,15 +516,35 @@ org.jacoco jacoco-maven-plugin + + org.jetbrains.kotlin + kotlin-maven-plugin + - + + example + + + !skipExamples + + + + examples + lib + + + + + release @@ -482,6 +557,10 @@ org.apache.maven.plugins maven-source-plugin + + org.codehaus.mojo + build-helper-maven-plugin + org.jetbrains.dokka dokka-maven-plugin @@ -498,21 +577,6 @@ - - - example - - - !skipExamples - - - - examples - lib - - @@ -564,6 +628,9 @@ + 2021 From 660aae3ecd237d2d5282c50bd704bfce13044605 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 7 Jul 2023 01:37:22 +0200 Subject: [PATCH 34/70] fixed the build, kotlin is compiled again, implement upcaster test provider with tesst, fix #304 --- examples/bankaccount-upcaster-junit5/pom.xml | 65 ++++++++++ .../AccountCreatedEventUpcastingJavaTest.java | 112 ++++++++++++++++++ ...account.event.AccountCreatedEvent__12.json | 5 + ...nkaccount.event.AccountCreatedEvent__0.xml | 5 + .../holixon/axon/testing/upcaster/Payload.kt | 38 ++++++ 5 files changed, 225 insertions(+) create mode 100644 examples/bankaccount-upcaster-junit5/pom.xml create mode 100644 examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java create mode 100644 examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json create mode 100644 examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml create mode 100644 extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/Payload.kt diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml new file mode 100644 index 0000000..e918081 --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + + io.holixon.axon.testing._ + examples + 4.7.4.1-SNAPSHOT + + + io.holixon.axon.testing.examples + bankaccount-upcaster-junit5 + + + + io.holixon.axon.testing + axon-testing-upcaster-junit5 + test + + + + com.fasterxml.jackson.module + jackson-module-kotlin + test + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + test + + + + org.junit.jupiter + junit-jupiter + ${junit5.version} + test + + + + io.holixon.axon.testing.lib + axon-testing-fixtures-bankaccount + test + + + org.slf4j + slf4j-simple + 2.0.6 + test + + + org.assertj + assertj-core + 3.24.2 + test + + + org.projectlombok + lombok + 1.18.28 + test + + + + diff --git a/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java b/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java new file mode 100644 index 0000000..3ee408b --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java @@ -0,0 +1,112 @@ +package io.holixon.axon.testing.examples.upcaster.junit5.java; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.module.kotlin.KotlinModule; +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.security.AnyTypePermission; +import fixture.bankaccount.event.AccountCreatedEvent; +import io.holixon.axon.testing.upcaster.MessageEncoding; +import io.holixon.axon.testing.upcaster.UpcasterTest; +import io.holixon.axon.testing.upcaster.content.DefaultStringMessageContentProvider; +import io.holixon.axon.testing.upcaster.payloadtype.FilenameBasedPayloadTypeAndRevisionProvider; +import lombok.val; +import org.axonframework.serialization.json.JacksonSerializer; +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation; +import org.axonframework.serialization.xml.XStreamSerializer; +import org.dom4j.Document; +import org.dom4j.Element; + +import java.util.List; +import java.util.stream.Collectors; + +import static io.holixon.axon.testing.upcaster.UpcasterTestSupport.*; +import static org.assertj.core.api.Assertions.*; + +public class AccountCreatedEventUpcastingJavaTest { + private final static XStreamSerializer xmlSerializer = createXstreamSerializer(); + private final static JacksonSerializer jacksonSerializer = createJacksonSerializer(); + + @UpcasterTest( + messageEncoding = MessageEncoding.XSTREAM, + payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider.class, + messageContentProvider = DefaultStringMessageContentProvider.class) + public void upcasts_account_created_xstream(List events) { + + val payloadType = AccountCreatedEvent.class.getName(); + val upcaster = xmlDocumentUpcaster(payloadType, "0", "1", (document) -> { + document.selectNodes("//" + payloadType).forEach(node -> { + // replace bank account id with account id + Element accountId = ((Element) node).addElement("accountId"); + Element bankAccountId = ((Element) node).element("bankAccountId"); + accountId.addText(bankAccountId.getText()); + ((Element) node).remove(bankAccountId); + + // add max balance + Element maxBalance = ((Element) node).addElement("maximalBalance"); + maxBalance.addText("1000"); + }); + return document; + }); + + val upcastedStream = upcaster.upcast(events.stream()); + + val upcastedEvents = upcastedStream.map((ier) -> xmlSerializer.deserialize(ier.getData(Document.class))).collect(Collectors.toList()); + assertThat(upcastedEvents) + .hasSize(1) + .element(0) + .isEqualTo( + AccountCreatedEvent + .builder() + .accountId("4711") + .customerId("Customer1") + .initialBalance(100) + .maximalBalance(1000) + .build() + ); + } + + @UpcasterTest( + messageEncoding = MessageEncoding.JACKSON, + payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider.class, + messageContentProvider = DefaultStringMessageContentProvider.class) + public void upcasts_account_created_jackson(List events) { + + val payloadType = AccountCreatedEvent.class.getName(); + val upcaster = jsonNodeUpcaster(payloadType, "12", "13", (node) -> { + val root = (ObjectNode)node; + root.set("accountId", root.get("bankAccountId")); + root.remove("bankAccountId"); + root.put("maximalBalance", 1000); + return root; + }); + + val upcastedStream = upcaster.upcast(events.stream()); + + val upcastedEvents = upcastedStream.map((ier) -> jacksonSerializer.deserialize(ier.getData())).collect(Collectors.toList()); + + assertThat(upcastedEvents) + .hasSize(1) + .element(0) + .isEqualTo( + AccountCreatedEvent + .builder() + .accountId("4711") + .customerId("Customer1") + .initialBalance(100) + .maximalBalance(1000) + .build() + ); + } + + static XStreamSerializer createXstreamSerializer() { + val xstream = new XStream(); + xstream.addPermission(AnyTypePermission.ANY); + return XStreamSerializer.builder().lenientDeserialization().xStream(xstream).build(); + } + + static JacksonSerializer createJacksonSerializer() { + val objectMapper = new ObjectMapper().registerModule(new KotlinModule.Builder().build()); + return JacksonSerializer.builder().lenientDeserialization().objectMapper(objectMapper).build(); + } +} diff --git a/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json new file mode 100644 index 0000000..3ebe054 --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__12.json @@ -0,0 +1,5 @@ +{ + "bankAccountId": "4711", + "customerId": "Customer1", + "initialBalance": 100 +} diff --git a/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml new file mode 100644 index 0000000..4e2197a --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest/upcasts_account_created_xstream/1__fixture.bankaccount.event.AccountCreatedEvent__0.xml @@ -0,0 +1,5 @@ + + 4711 + Customer1 + 100 + diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/Payload.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/Payload.kt new file mode 100644 index 0000000..f990b50 --- /dev/null +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/Payload.kt @@ -0,0 +1,38 @@ +package io.holixon.axon.testing.upcaster + +import org.axonframework.eventhandling.EventData +import org.dom4j.Document + +data class Payload( + val payloadType: String, + val revision: String? = null, + val content: Any, + val metadata: Any +) { + fun constructEntry(encoding: MessageEncoding): EventData<*> { + return when (encoding) { + MessageEncoding.XSTREAM -> + UpcasterTestSupport.xmlTestEventData( + payloadDocument = content.let { + require(it is Document) { "Content for $encoding must be a dom4j document" } + it + }, + payloadTypeName = payloadType, + metaDataDocument = metadata.let { + require(it is Document) { "Metadata for $encoding must be a dom4j document" } + it + }, + revisionNumber = revision + ) + + MessageEncoding.JACKSON -> UpcasterTestSupport.jsonTestEventData( + payloadJson = content.toString(), + payloadTypeName = payloadType, + metaDataJson = metadata.toString(), + revisionNumber = revision + ) + + else -> throw IllegalArgumentException("Unsupported encoding $encoding") + } + } +} From 32f5b40e65c273979e710e2e234bcc9e18429356 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 7 Jul 2023 01:42:24 +0200 Subject: [PATCH 35/70] improve kotlin test --- .../AccountCreatedEventUpcastingKotlinTest.kt | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt index 7efebda..c130b63 100644 --- a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt +++ b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt @@ -24,16 +24,9 @@ class AccountCreatedEventUpcastingKotlinTest { private val xmlSerializer: XStreamSerializer = XStreamSerializer.builder().lenientDeserialization().xStream(XStream().apply { addPermission(AnyTypePermission.ANY) }).build() private val jacksonSerializer: JacksonSerializer = JacksonSerializer.builder().lenientDeserialization().objectMapper(jacksonObjectMapper()).build() - } - @UpcasterTest( - messageEncoding = MessageEncoding.XSTREAM, - payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider::class, - messageContentProvider = DefaultStringMessageContentProvider::class - ) - fun upcasts_account_created_xstream(events: List) { - val payloadType: String = AccountCreatedEvent::class.java.name - val upcaster: SingleEventUpcaster = xmlDocumentUpcaster(payloadType, "0", "1") { + private val payloadType: String = AccountCreatedEvent::class.java.name + private val xmlUpcaster = xmlDocumentUpcaster(payloadType, "0", "1") { it.apply { selectNodes("//$payloadType").forEach { node -> // replace bank account id with account id @@ -48,7 +41,35 @@ class AccountCreatedEventUpcastingKotlinTest { } } } - val upcastedStream: Stream = upcaster.upcast(events.stream()) + + private val jsonUpcaster = jsonNodeUpcaster(payloadType, "12", "13") { + (it as ObjectNode).apply { + put("accountId", get("bankAccountId").asText()) + remove("bankAccountId") + put("maximalBalance", 1000) + } + } + + private val accountEvent = AccountCreatedEvent + .builder() + .accountId("4711") + .customerId("Customer1") + .initialBalance(100) + .maximalBalance(1000) + .build() + } + + + @UpcasterTest( + messageEncoding = MessageEncoding.XSTREAM, + payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider::class, + messageContentProvider = DefaultStringMessageContentProvider::class + ) + fun upcasts_account_created_xstream(events: List) { + + val upcastedStream: Stream = xmlUpcaster.upcast(events.stream()) + + // FIXME: build assertions val upcastedEvents = upcastedStream.map { ier -> xmlSerializer.deserialize( ier.getData( @@ -59,15 +80,7 @@ class AccountCreatedEventUpcastingKotlinTest { assertThat(upcastedEvents) .hasSize(1) .element(0) - .isEqualTo( - AccountCreatedEvent - .builder() - .accountId("4711") - .customerId("Customer1") - .initialBalance(100) - .maximalBalance(1000) - .build() - ) + .isEqualTo(accountEvent) } @UpcasterTest( @@ -76,32 +89,20 @@ class AccountCreatedEventUpcastingKotlinTest { messageContentProvider = DefaultStringMessageContentProvider::class ) fun upcasts_account_created_jackson(events: List) { - val payloadType: String = AccountCreatedEvent::class.java.name - val upcaster: SingleEventUpcaster = jsonNodeUpcaster(payloadType, "12", "13") { - (it as ObjectNode).apply { - put("accountId", get("bankAccountId").asText()) - remove("bankAccountId") - put("maximalBalance", 1000) - } - } - val upcastedStream: Stream = upcaster.upcast(events.stream()) + + val upcastedStream: Stream = jsonUpcaster.upcast(events.stream()) + + // FIXME: build assertions val upcastedEvents = upcastedStream.map { ier -> val event: AccountCreatedEvent = jacksonSerializer.deserialize( ier.data ) event } + assertThat(upcastedEvents) .hasSize(1) .element(0) - .isEqualTo( - AccountCreatedEvent - .builder() - .accountId("4711") - .customerId("Customer1") - .initialBalance(100) - .maximalBalance(1000) - .build() - ) + .isEqualTo(accountEvent) } } From dcf5eb31365ed6370038532a1d1456ce4eb291e0 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 7 Jul 2023 14:02:34 +0200 Subject: [PATCH 36/70] implement result injection --- .../AccountCreatedEventUpcastingJavaTest.java | 68 ++++---- .../AccountCreatedEventUpcastingKotlinTest.kt | 41 ++--- ...event.AccountCreatedEvent__13__result.json | 6 + .../axon/testing/upcaster/MessageEncoding.kt | 6 +- ...dingAutoDetectingMessageContentProvider.kt | 8 + .../axon/testing/upcaster/file/FileUtils.kt | 13 +- .../testing/upcaster/ExtensionContextUtils.kt | 63 +++++-- .../IntermediateRepresentationProvider.kt | 158 +++++++++++------- .../axon/testing/upcaster/UpcasterTest.kt | 16 +- 9 files changed, 244 insertions(+), 135 deletions(-) create mode 100644 examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__13__result.json create mode 100644 extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/MessageEncodingAutoDetectingMessageContentProvider.kt diff --git a/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java b/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java index 3ee408b..5f8b118 100644 --- a/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java +++ b/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java @@ -8,11 +8,10 @@ import fixture.bankaccount.event.AccountCreatedEvent; import io.holixon.axon.testing.upcaster.MessageEncoding; import io.holixon.axon.testing.upcaster.UpcasterTest; -import io.holixon.axon.testing.upcaster.content.DefaultStringMessageContentProvider; -import io.holixon.axon.testing.upcaster.payloadtype.FilenameBasedPayloadTypeAndRevisionProvider; import lombok.val; import org.axonframework.serialization.json.JacksonSerializer; import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation; +import org.axonframework.serialization.upcasting.event.SingleEventUpcaster; import org.axonframework.serialization.xml.XStreamSerializer; import org.dom4j.Document; import org.dom4j.Element; @@ -26,31 +25,41 @@ public class AccountCreatedEventUpcastingJavaTest { private final static XStreamSerializer xmlSerializer = createXstreamSerializer(); private final static JacksonSerializer jacksonSerializer = createJacksonSerializer(); + private final static String payloadType = AccountCreatedEvent.class.getName(); + private final static SingleEventUpcaster xmlDocumentUpcaster = xmlDocumentUpcaster(payloadType, "0", "1", (document) -> { + document.selectNodes("//" + payloadType).forEach(node -> { + // replace bank account id with account id + Element accountId = ((Element) node).addElement("accountId"); + Element bankAccountId = ((Element) node).element("bankAccountId"); + accountId.addText(bankAccountId.getText()); + ((Element) node).remove(bankAccountId); + + // add max balance + Element maxBalance = ((Element) node).addElement("maximalBalance"); + maxBalance.addText("1000"); + }); + return document; + }); + + private final static SingleEventUpcaster jsonNodeUpcaster = jsonNodeUpcaster(payloadType, "12", "13", (node) -> { + val root = (ObjectNode)node; + root.set("accountId", root.get("bankAccountId")); + root.remove("bankAccountId"); + root.put("maximalBalance", 1000); + return root; + }); + + @UpcasterTest( - messageEncoding = MessageEncoding.XSTREAM, - payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider.class, - messageContentProvider = DefaultStringMessageContentProvider.class) + messageEncoding = MessageEncoding.XSTREAM + ) public void upcasts_account_created_xstream(List events) { - val payloadType = AccountCreatedEvent.class.getName(); - val upcaster = xmlDocumentUpcaster(payloadType, "0", "1", (document) -> { - document.selectNodes("//" + payloadType).forEach(node -> { - // replace bank account id with account id - Element accountId = ((Element) node).addElement("accountId"); - Element bankAccountId = ((Element) node).element("bankAccountId"); - accountId.addText(bankAccountId.getText()); - ((Element) node).remove(bankAccountId); - - // add max balance - Element maxBalance = ((Element) node).addElement("maximalBalance"); - maxBalance.addText("1000"); - }); - return document; - }); - val upcastedStream = upcaster.upcast(events.stream()); + val upcastedStream = xmlDocumentUpcaster.upcast(events.stream()); + // FIXME: build better assertions val upcastedEvents = upcastedStream.map((ier) -> xmlSerializer.deserialize(ier.getData(Document.class))).collect(Collectors.toList()); assertThat(upcastedEvents) .hasSize(1) @@ -67,22 +76,13 @@ public void upcasts_account_created_xstream(List events) { - val payloadType = AccountCreatedEvent.class.getName(); - val upcaster = jsonNodeUpcaster(payloadType, "12", "13", (node) -> { - val root = (ObjectNode)node; - root.set("accountId", root.get("bankAccountId")); - root.remove("bankAccountId"); - root.put("maximalBalance", 1000); - return root; - }); - - val upcastedStream = upcaster.upcast(events.stream()); + val upcastedStream = jsonNodeUpcaster.upcast(events.stream()); + // FIXME: build better assertions val upcastedEvents = upcastedStream.map((ier) -> jacksonSerializer.deserialize(ier.getData())).collect(Collectors.toList()); assertThat(upcastedEvents) diff --git a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt index c130b63..076d691 100644 --- a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt +++ b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt @@ -16,6 +16,9 @@ import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation import org.axonframework.serialization.upcasting.event.SingleEventUpcaster import org.axonframework.serialization.xml.XStreamSerializer +import org.dom4j.Document +import org.dom4j.Element +import java.util.stream.Collectors import java.util.stream.Stream class AccountCreatedEventUpcastingKotlinTest { @@ -30,13 +33,13 @@ class AccountCreatedEventUpcastingKotlinTest { it.apply { selectNodes("//$payloadType").forEach { node -> // replace bank account id with account id - val accountId = (node as org.dom4j.Element).addElement("accountId") + val accountId = (node as Element).addElement("accountId") val bankAccountId = node.element("bankAccountId") accountId.addText(bankAccountId.text) node.remove(bankAccountId) // add max balance - val maxBalance: org.dom4j.Element = node.addElement("maximalBalance") + val maxBalance: Element = node.addElement("maximalBalance") maxBalance.addText("1000") } } @@ -61,19 +64,17 @@ class AccountCreatedEventUpcastingKotlinTest { @UpcasterTest( - messageEncoding = MessageEncoding.XSTREAM, - payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider::class, - messageContentProvider = DefaultStringMessageContentProvider::class + messageEncoding = MessageEncoding.XSTREAM ) - fun upcasts_account_created_xstream(events: List) { + fun upcasts_account_created_xstream(events: List) { val upcastedStream: Stream = xmlUpcaster.upcast(events.stream()) - // FIXME: build assertions + // FIXME: build better assertions val upcastedEvents = upcastedStream.map { ier -> - xmlSerializer.deserialize( + xmlSerializer.deserialize( ier.getData( - org.dom4j.Document::class.java + Document::class.java ) ) } @@ -84,15 +85,13 @@ class AccountCreatedEventUpcastingKotlinTest { } @UpcasterTest( - messageEncoding = MessageEncoding.JACKSON, - payloadTypeProvider = FilenameBasedPayloadTypeAndRevisionProvider::class, - messageContentProvider = DefaultStringMessageContentProvider::class + messageEncoding = MessageEncoding.JACKSON ) - fun upcasts_account_created_jackson(events: List) { + fun `upcasts account created jackson`(events: List, result: List) { - val upcastedStream: Stream = jsonUpcaster.upcast(events.stream()) + val upcastedStream = jsonUpcaster.upcast(events.stream()).collect(Collectors.toList()) - // FIXME: build assertions + // FIXME: build better assertions val upcastedEvents = upcastedStream.map { ier -> val event: AccountCreatedEvent = jacksonSerializer.deserialize( ier.data @@ -100,9 +99,13 @@ class AccountCreatedEventUpcastingKotlinTest { event } - assertThat(upcastedEvents) - .hasSize(1) - .element(0) - .isEqualTo(accountEvent) + val deserializedResult = result.map { ier -> + val event: AccountCreatedEvent = jacksonSerializer.deserialize( + ier.data + ) + event + } + + assertThat(upcastedEvents).containsExactlyElementsOf(deserializedResult) } } diff --git a/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__13__result.json b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__13__result.json new file mode 100644 index 0000000..15d2133 --- /dev/null +++ b/examples/bankaccount-upcaster-junit5/src/test/resources/io/holixon/axon/testing/examples/upcaster/junit5/kotlin/AccountCreatedEventUpcastingKotlinTest/upcasts_account_created_jackson/1__fixture.bankaccount.event.AccountCreatedEvent__13__result.json @@ -0,0 +1,6 @@ +{ + "accountId": "4711", + "customerId": "Customer1", + "initialBalance": 100, + "maximalBalance": 1000 +} diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt index 8e17d34..969aa31 100644 --- a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/MessageEncoding.kt @@ -24,9 +24,9 @@ enum class MessageEncoding { */ fun defaultFileEnding() = when (this) { - XSTREAM -> "xml" - JACKSON -> "json" - AVRO_SINGLE_OBJECT -> "avro" // FIXME: what is the best ending here -> @jangalinski + XSTREAM -> ".xml" + JACKSON -> ".json" + AVRO_SINGLE_OBJECT -> ".avrosoe" // FIXME: what is the best ending here -> @jangalinski } } diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/MessageEncodingAutoDetectingMessageContentProvider.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/MessageEncodingAutoDetectingMessageContentProvider.kt new file mode 100644 index 0000000..09cf11e --- /dev/null +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/content/MessageEncodingAutoDetectingMessageContentProvider.kt @@ -0,0 +1,8 @@ +package io.holixon.axon.testing.upcaster.content + +import io.holixon.axon.testing.upcaster.MessageContentProvider + +/** + * Marker implementation auto-detecting the message content provider, based on message encoding. + */ +class MessageEncodingAutoDetectingMessageContentProvider(impl: MessageContentProvider) : MessageContentProvider by impl diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt index 84523bf..63baf7c 100644 --- a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/file/FileUtils.kt @@ -7,8 +7,13 @@ import java.io.FileFilter * Retrieves a regex to match files with given ending. * Will match files starting with digits having a name separated by a double underscore ("9234__my_file.txt") * @param ending the desired ending without the leading dot. ("jpg") + * @param resultSuffix */ -fun numberedFileRegex(ending: String) = Regex("^([0-9]+)_{2}(.*)(\\.$ending)$") +fun numberedFileRegex(ending: String, resultSuffix: String? = null) = if (resultSuffix != null) { + Regex("^([0-9]+)_{2}(.*)(? { +fun File.getFiles(ending: String, resultSuffix: String? = null): List { require(this.isDirectory) { "Provided reference ${this.name} must be a folder, but it was not." } - val regex = numberedFileRegex(ending) + val regex = numberedFileRegex(ending, resultSuffix) val files = this.listFiles(FileFilter { it.isFile && it.name.matches(regex) diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt index 6aa793a..5d332bf 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/ExtensionContextUtils.kt @@ -1,5 +1,7 @@ package io.holixon.axon.testing.upcaster +import io.holixon.axon.testing.upcaster.content.DefaultStringMessageContentProvider +import io.holixon.axon.testing.upcaster.content.MessageEncodingAutoDetectingMessageContentProvider import io.holixon.axon.testing.upcaster.content.StaticTestInstanceMessageContentProvider import io.holixon.axon.testing.upcaster.payloadtype.StaticTestInstancePayloadTypeAndRevisionProvider import org.axonframework.serialization.Serializer @@ -30,12 +32,20 @@ fun ExtensionContext.getTestFolder(): File? { * Retrieves the test folder name for this test context. */ fun ExtensionContext.getTestFolderName(): String = - (this.requiredTestClass.canonicalName + "." + this.requiredTestMethod.name.replace(' ', '_')).replace('.', '/') + (this.requiredTestClass.canonicalName + "." + this.requiredTestMethod.name.replace(' ', '_')) + .replace('.', '/') /** - * Tries to detect the parameter type of the parametrized method. + * We believe that any parametrized parameter is relevant for the provider. + * FIXME This is a bold assumption and should be revalidated later. */ -fun ExtensionContext.detectParameterType(): Class<*>? { +fun ExtensionContext.retrieveRelevantParameterCount() = + this.requiredTestMethod.genericParameterTypes.filterIsInstance().count() + +/** + * Tries to detect the first parameter type of the parametrized method. + */ +fun ExtensionContext.detectSourceParameterType(): Class<*>? { return if ( this.requiredTestMethod.genericParameterTypes.isNotEmpty() && this.requiredTestMethod.genericParameterTypes[0] is ParameterizedType @@ -48,6 +58,22 @@ fun ExtensionContext.detectParameterType(): Class<*>? { } } +/** + * Tries to detect the second parameter type of the parametrized method. + */ +fun ExtensionContext.detectTargetParameterType(): Class<*>? { + return if ( + this.requiredTestMethod.genericParameterTypes.size > 1 + && this.requiredTestMethod.genericParameterTypes[1] is ParameterizedType + && (this.requiredTestMethod.genericParameterTypes[1] as ParameterizedType).actualTypeArguments.isNotEmpty() + && ((this.requiredTestMethod.genericParameterTypes[1] as ParameterizedType).actualTypeArguments[0] is Class<*>) + ) { + (this.requiredTestMethod.genericParameterTypes[1] as ParameterizedType).actualTypeArguments[0] as Class<*> + } else { + null + } +} + /** * Extracts the serializer from the test instance. */ @@ -78,14 +104,12 @@ fun ExtensionContext.getPayloadTypeAndRevisionProvider(clazz: KClass): MessageContentProvider? { +fun ExtensionContext.getMessageContentProvider(clazz: KClass, messageEncoding: MessageEncoding): MessageContentProvider? { if (this.testClass.isEmpty) { return null } - return if (clazz == StaticTestInstanceMessageContentProvider::class) { - try { + return when (clazz) { + StaticTestInstanceMessageContentProvider::class -> try { this.testClass.get().getInstanceVariableValue(MessageContentProvider::class, null, MessageContentProvider::class) } catch (e: Exception) { null } - } else { - try { - return clazz.primaryConstructor?.call() - } catch (e: Exception) { - null + + MessageEncodingAutoDetectingMessageContentProvider::class -> { + when (messageEncoding) { + MessageEncoding.JACKSON, + MessageEncoding.XSTREAM -> DefaultStringMessageContentProvider() + + else -> null + } + } + + else -> { + try { + return clazz.primaryConstructor?.call() + } catch (e: Exception) { + null + } } } } diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt index 9d95250..b3e988e 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/IntermediateRepresentationProvider.kt @@ -2,6 +2,7 @@ package io.holixon.axon.testing.upcaster import io.holixon.axon.testing.upcaster.UpcasterTest.Companion.DEFAULT_FILE_ENDING import io.holixon.axon.testing.upcaster.file.getFiles +import org.axonframework.serialization.Serializer import org.axonframework.serialization.upcasting.event.InitialEventRepresentation import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation import org.junit.jupiter.api.Named @@ -21,93 +22,86 @@ import kotlin.reflect.KClass */ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer { + private lateinit var payloadTypeAndRevisionProviderClazz: KClass private lateinit var contentProviderClazz: KClass private lateinit var messageEncoding: MessageEncoding - private lateinit var messageFileEnding: String + private lateinit var sourceMessageFileEnding: String + private lateinit var resultMessageFileSuffix: String + + + private lateinit var payloadTypeAndRevisionProvider: PayloadTypeAndRevisionProvider + private lateinit var contentProvider: MessageContentProvider + private lateinit var serializer: Serializer override fun provideArguments(context: ExtensionContext): Stream { // make sure provider is initialized correctly. - sanitize() + sanitizeInitialization() // retrieve the test file folder val folderName = context.getTestFolderName() val folder = notNull( context.getTestFolder(), - "Could not access the test data folder $folderName, consider creating it in your resources folder." + "Could not access the test data folder '$folderName', please create it in your test resources folder." )!! - // retrieve test files - val ending = this.messageEncoding.defaultFileEnding() - val testFiles = folder.getFiles(ending) + val resultMessageFileEnding = resultMessageFileSuffix + sourceMessageFileEnding + // retrieve files + val testSourceFiles = folder.getFiles(sourceMessageFileEnding, resultMessageFileSuffix) + val testResultFiles = folder.getFiles(resultMessageFileEnding) condition( - testFiles.isNotEmpty(), - "Could not load any test data files (*.$ending) from provided folder $folderName." + testSourceFiles.isNotEmpty(), + "Could not load any test data files (*.$sourceMessageFileEnding) from provided folder $folderName." ) + // find payload type and revision provider - val payloadTypeAndRevisionProvider = + payloadTypeAndRevisionProvider = notNull( - context.getPayloadTypeAndRevisionProvider(this.payloadTypeAndRevisionProviderClazz), + context.getPayloadTypeAndRevisionProvider(payloadTypeAndRevisionProviderClazz), "Payload type and revision provider could not be initialized. You configured ${payloadTypeAndRevisionProviderClazz.simpleName}." )!! // content provider - val contentProvider = + contentProvider = notNull( - context.getMessageContentProvider(this.contentProviderClazz), - "Message content provider could not be initialized. You configured ${contentProviderClazz.simpleName}." + context.getMessageContentProvider(contentProviderClazz, messageEncoding), + "Message content provider could not be initialized. You configured ${contentProviderClazz.simpleName} and message encoding $messageEncoding." )!! // find serializer - val serializer = notNull( + serializer = notNull( context.getSerializer(this.messageEncoding), "Could not find serializer for $messageEncoding. Please provide is as a static member variable of the test." )!! + val relevantParameterCount = context.retrieveRelevantParameterCount() + condition( + relevantParameterCount > 0, + "At least one List<> parameter is required for method annotated with @UpcasterTest." + + "Currently, the provider supports List, List or List." + ) + // guess the type - val parameterType = context.detectParameterType() ?: IntermediateEventRepresentation::class.java - - return when (parameterType) { - // events - IntermediateEventRepresentation::class.java -> { - NamedList( - name = "*.$ending events from $folderName", - payload = testFiles - .map { file -> - Payload( - payloadType = payloadTypeAndRevisionProvider.getPayloadType(ending, file), - revision = payloadTypeAndRevisionProvider.getRevision(ending, file), - content = contentProvider.getMessagePayload(file, this.messageEncoding), - metadata = contentProvider.getMessageMetadata(file, this.messageEncoding) - ) - }.map { - InitialEventRepresentation(it.constructEntry(this.messageEncoding), serializer) - } - ) - } - // files - File::class.java -> { - NamedList( - name = "*.$ending files from $folderName", - payload = testFiles - ) - } - // file content - String::class.java -> { - NamedList( - name = "*.$ending file content from $folderName", - payload = testFiles.map { file -> - file.readText().trim() - } - ) - } - - else -> { - throw PreconditionViolationException("Unsupported parameter type: $parameterType") - } - }.let { - Stream.of(Arguments.of(it)) + val sourceParameterType = context.detectSourceParameterType() ?: IntermediateEventRepresentation::class.java + val resultParameterType = if (relevantParameterCount > 1) { + context.detectTargetParameterType() ?: IntermediateEventRepresentation::class.java + } else { + null + } + + val sources = generateOutput(folderName, sourceMessageFileEnding, sourceParameterType, testSourceFiles) + ?: throw PreconditionViolationException("Unsupported parameter type: $sourceParameterType") + val results = generateOutput(folderName, resultMessageFileEnding, resultParameterType, testResultFiles) + // sanity + if (resultParameterType == null && testResultFiles.isNotEmpty()) { + context.publishReportEntry("Warning: detected ${testSourceFiles.size} result files, but could not detect a type of second method parameter to provide it to the test method.") + } + + return if (relevantParameterCount > 1) { + Stream.of(Arguments.of(sources, results)) + } else { + Stream.of(Arguments.of(sources)) } } @@ -116,23 +110,67 @@ class IntermediateRepresentationProvider : ArgumentsProvider, AnnotationConsumer this.messageEncoding = annotation.messageEncoding this.payloadTypeAndRevisionProviderClazz = annotation.payloadTypeProvider this.contentProviderClazz = annotation.messageContentProvider - this.messageFileEnding = if (annotation.messageFileEnding == DEFAULT_FILE_ENDING) { + this.sourceMessageFileEnding = if (annotation.messageFileEnding == DEFAULT_FILE_ENDING) { this.messageEncoding.defaultFileEnding() } else { annotation.messageFileEnding } + this.resultMessageFileSuffix = annotation.resultMessageFileSuffix } - private fun sanitize() { + private fun sanitizeInitialization() { condition(this::messageEncoding.isInitialized, "Event encoding must be initialized.") condition(this::payloadTypeAndRevisionProviderClazz.isInitialized, "Payload Type and Revision provider must be initialized."); condition(this::contentProviderClazz.isInitialized, "Message content provider must be initialized."); - condition(this::messageFileEnding.isInitialized, "Message file ending must be initialized."); + condition(this::sourceMessageFileEnding.isInitialized, "Message file ending must be initialized."); + condition(this::resultMessageFileSuffix.isInitialized, "Result message file suffix must be initialized."); + } + + private fun generateOutput( + folderName: String, + fileEnding: String, + parameterType: Class?, + files: List, + ) = when (parameterType) { + // events + IntermediateEventRepresentation::class.java -> { + NamedList( + name = "*.$fileEnding events from $folderName", + payload = files + .map { file -> + Payload( + payloadType = payloadTypeAndRevisionProvider.getPayloadType(fileEnding, file), + revision = payloadTypeAndRevisionProvider.getRevision(fileEnding, file), + content = contentProvider.getMessagePayload(file, messageEncoding), + metadata = contentProvider.getMessageMetadata(file, messageEncoding) + ) + }.map { + InitialEventRepresentation(it.constructEntry(messageEncoding), serializer) + } + ) + } + // files + File::class.java -> { + NamedList( + name = "*.$fileEnding files from $folderName", + payload = files + ) + } + // file content + String::class.java -> { + NamedList( + name = "*.$fileEnding file content from $folderName", + payload = files.map { file -> + file.readText().trim() + } + ) + } + else -> null } /** - * Named list. + * Named list used for nicer display. */ class NamedList(private val name: String, private val payload: List) : List by payload, Named> { override fun getName(): String = name diff --git a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt index b8a3cac..38e197e 100644 --- a/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt +++ b/extension/upcaster/junit5/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTest.kt @@ -1,6 +1,8 @@ package io.holixon.axon.testing.upcaster +import io.holixon.axon.testing.upcaster.content.MessageEncodingAutoDetectingMessageContentProvider import io.holixon.axon.testing.upcaster.content.StaticTestInstanceMessageContentProvider +import io.holixon.axon.testing.upcaster.payloadtype.FilenameBasedPayloadTypeAndRevisionProvider import io.holixon.axon.testing.upcaster.payloadtype.StaticTestInstancePayloadTypeAndRevisionProvider import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ArgumentsSource @@ -13,11 +15,19 @@ import kotlin.reflect.KClass @ArgumentsSource(value = IntermediateRepresentationProvider::class) annotation class UpcasterTest( val messageEncoding: MessageEncoding = MessageEncoding.JACKSON, - val payloadTypeProvider: KClass = StaticTestInstancePayloadTypeAndRevisionProvider::class, - val messageContentProvider: KClass = StaticTestInstanceMessageContentProvider::class, - val messageFileEnding: String = DEFAULT_FILE_ENDING + val payloadTypeProvider: KClass = FilenameBasedPayloadTypeAndRevisionProvider::class, + val messageContentProvider: KClass = MessageEncodingAutoDetectingMessageContentProvider::class, + val messageFileEnding: String = DEFAULT_FILE_ENDING, + val resultMessageFileSuffix: String = DEFAULT_RESULT_FILE_SUFFIX ) { companion object { const val DEFAULT_FILE_ENDING = "__DEFAULT" + + /** + * The suffix expected to be appended to the file name to indicate that the file is a result. + * For a file '112__my.package.MyType__87.encoding' it will result in + * '6__my.package.MyType__89__result.encoding' + */ + const val DEFAULT_RESULT_FILE_SUFFIX = "__result" } } From 6a2e365185c3e5b049f988530a3df4ed18e18a95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 12:10:03 +0000 Subject: [PATCH 37/70] chore(deps): bump kotlin.version from 1.8.22 to 1.9.0 Bumps `kotlin.version` from 1.8.22 to 1.9.0. Updates `kotlin-bom` from 1.8.22 to 1.9.0 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.8.22...v1.9.0) Updates `kotlin-maven-allopen` from 1.8.22 to 1.9.0 Updates `kotlin-maven-plugin` from 1.8.22 to 1.9.0 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0395c03..65d1475 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 11 - 1.8.22 + 1.9.0 4.8.0 From 0e06cd88d1468e3a3af5234386b52e649a88540e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 17:41:50 +0000 Subject: [PATCH 38/70] chore(deps): bump jaxen from 1.2.0 to 2.0.0 Bumps [jaxen](https://github.com/jaxen-xpath/jaxen) from 1.2.0 to 2.0.0. - [Release notes](https://github.com/jaxen-xpath/jaxen/releases) - [Commits](https://github.com/jaxen-xpath/jaxen/compare/v1.2.0...v2.0.0) --- updated-dependencies: - dependency-name: jaxen:jaxen dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0395c03..af29abe 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ 4.13.2 5.9.3 2.1.4 - 1.2.0 + 2.0.0 3.24.2 From 822acabff479d6c140aaa16ac76d088e86da8a06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 17:41:53 +0000 Subject: [PATCH 39/70] chore(deps): bump slf4j-simple from 2.0.6 to 2.0.7 Bumps [slf4j-simple](https://github.com/qos-ch/slf4j) from 2.0.6 to 2.0.7. - [Commits](https://github.com/qos-ch/slf4j/compare/v_2.0.6...v_2.0.7) --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index e918081..8133f00 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -45,7 +45,7 @@ org.slf4j slf4j-simple - 2.0.6 + 2.0.7 test From d92bee1c74ae6d48903dd1c47e91c431fba067c1 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 7 Jul 2023 23:36:41 +0200 Subject: [PATCH 40/70] additional helper methods, README, fix #310 --- README.md | 117 +++++++++++++++++- .../AccountCreatedEventUpcastingJavaTest.java | 3 +- .../AccountCreatedEventUpcastingKotlinTest.kt | 32 ++--- .../testing/upcaster/UpcasterTestSupport.kt | 24 +++- 4 files changed, 148 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index e65d334..ded0342 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,123 @@ For both kind of tests, we propose to use a JVM Framework for BDD testing called ### Axon Upcaster Testing -Writing event upcasters is sometimes difficult. Testing of them require even more effort. The library helps to create easy upcaster tests. +Writing event upcasters is sometimes difficult. Testing of them require even more effort. The library helps to create +easy upcaster JUnit 5 tests. + +Imagine you need to test an upcaster for the `fixture.bankaccount.event.AccountCreatedEvent` in an application using +Jackson serializer. The old event revision was `12` and the new revision is `13`. There are only few steps needed to +implement such a test. + +Please put the following dependency on your project classpath: + +```xml + + io.holixon.axon.testing + axon-testing-upcaster-junit5 + 4.x.x.x + test + +``` + +Now create a JUnit 5 test for your upcaster: + +```java +// the package is important to put event data in correct folder inside the tst resources +package io.holixon.axon.testing.examples.upcaster.junit5.java; + +// intentionally left out some trivial imports + +import io.holixon.axon.testing.upcaster.MessageEncoding; +import io.holixon.axon.testing.upcaster.UpcasterTest; + +import static io.holixon.axon.testing.upcaster.UpcasterTestSupport.*; + +// the class name is important +public class AccountCreatedEventUpcastingJavaTest { + + // must be defined as a static field of type matching the MessageEncoding + // the initialization is extracted to a separate method for simplicity + private final static JacksonSerializer jacksonSerializer = createJacksonSerializer(); + + // special annotation in use at least specifying the encoding type + @UpcasterTest(messageEncoding = MessageEncoding.JACKSON) + // important method name as the last folder + public void upcasts_account_created_jackson( + // will contain ordered sequence of source events, see explanation below + List sourceEvents, + // will contain ordered sequence of result events, see explanation below + List expectedSerializedEvents) { + + AccountCreatedEventUpcaster upcaster = new AccountCreatedEventUpcaster(); + + Stream upcastedStream = upcaster.upcast(sourceEvents.stream()); + List upcastedEvents = deserializeEvents(upcastedStream, jacksonSerializer).collect( + Collectors.toList()); + + // asserts + List expectedEvents = deserializeEvents(expectedSerializedEvents, jacksonSerializer); + assertThat(upcastedEvents).containExactlyElementsOf(expectedEvents); + } +} +``` +This looks like a miracle that the source events are passed in to the test, can be directly passed to the upcaster under the test +and the result can be asserted using the collection of expected events. Indeed, the library makes use of JUnit 5 parameterized test +functionality, by defining a custom argument provider reading events out of files from the file system. We believe this is a good +practice for upcaster and upcaster chain testing, where several representations of different versions of the same event exist and must +be managed and set-up for the test. In also helps in situations where comparison with the expected event as an object in Java is +not feasible because only one version of a class may be available (probably the latest one). + +Back to the test class implementation, please pay attention to the `static` `JacksonSerializer` defined in the test class and on +the full-qualified name of the test class and the test method name. + +The content of the `src/test/resources` folder is as following: + +``` +└── io + └── holixon + └── axon + └── testing + └── examples + └── upcaster + └── junit5 + └── java + └── AccountCreatedEventUpcastingJavaTest + └── upcasts_account_created_jackson + ├── 1__fixture.bankaccount.event.AccountCreatedEvent__12.json + ├── 2__fixture.bankaccount.event.AccountCreatedEvent__12.json + ├── 1__fixture.bankaccount.event.AccountCreatedEvent__13__result.json + └── 2__fixture.bankaccount.event.AccountCreatedEvent__13__result.json +``` + +The full-qualified class name and the test method name are mapped to the directory structure. Inside the test data directory, +there are four files. Those two of them without the `__result` suffix are read in and considered to be JSON representations +of source events. The source events are passed to the test method annotated by the `@UpcasterTest` as a first parameter `sourceEvents`. +The other two with the `__result` suffix are considered to be JSON representations of the expected events, received after the +upcaster run. Those will be passed to the test method as the second parameter `expectedSerializedEvents`. + +The ordering of the files (in each group) is determined based on the first numbers until the first `__` separator. The next part of +the file name is considered as the type name of the stored event. Finally, the last number is representing the revision of the event. + +You may want to use only parts of the functionality above. A good starting point for this are our examples. Please consider to look at the +`io.holixon.axon.testing.upcaster.UpcasterTestSupport` class for helpful methods. In addition, you might want to use the `@UpcasterTest` +functionality in a slightly different way. The method signature of the test method may have one or two parameters (expected events must not be read +from the filesystem) of different types: `List` to get intermediate representation, `List` to get +the file content of the read-in files or just `List` to get the files matching criteria. There are some additional options on +the `@UpcasterTest` annotation to tune the behaviour of the parameterized test argument provider. You can specify different strategy to +resolve the payload type and revision and a different content retrieval strategy. ## Changelog * Beginning with release `4.7.4.0` we changed to a semantic versioning model where the first 3 digits refer to the axon framework version this lib is supposed to work withm the last digit is the build version of this lib against the framework. + + +## License + +This library is developed under + +[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](/LICENSE) + +## Sponsors and Customers + +[![sponsored](https://img.shields.io/badge/sponsoredBy-Holisticon-red.svg)](https://holisticon.de/) + diff --git a/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java b/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java index 5f8b118..f3a0333 100644 --- a/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java +++ b/examples/bankaccount-upcaster-junit5/src/test/java/io/holixon/axon/testing/examples/upcaster/junit5/java/AccountCreatedEventUpcastingJavaTest.java @@ -82,8 +82,9 @@ public void upcasts_account_created_jackson(List jacksonSerializer.deserialize(ier.getData())).collect(Collectors.toList()); assertThat(upcastedEvents) .hasSize(1) diff --git a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt index 076d691..0fc0926 100644 --- a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt +++ b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt @@ -7,14 +7,12 @@ import com.thoughtworks.xstream.security.AnyTypePermission import fixture.bankaccount.event.AccountCreatedEvent import io.holixon.axon.testing.upcaster.MessageEncoding import io.holixon.axon.testing.upcaster.UpcasterTest +import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.deserializeEvents import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonNodeUpcaster import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlDocumentUpcaster -import io.holixon.axon.testing.upcaster.content.DefaultStringMessageContentProvider -import io.holixon.axon.testing.upcaster.payloadtype.FilenameBasedPayloadTypeAndRevisionProvider import org.assertj.core.api.Assertions.assertThat import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation -import org.axonframework.serialization.upcasting.event.SingleEventUpcaster import org.axonframework.serialization.xml.XStreamSerializer import org.dom4j.Document import org.dom4j.Element @@ -68,16 +66,11 @@ class AccountCreatedEventUpcastingKotlinTest { ) fun upcasts_account_created_xstream(events: List) { - val upcastedStream: Stream = xmlUpcaster.upcast(events.stream()) + val upcastedStream = xmlUpcaster.upcast(events.stream()) + val upcastedEvents = deserializeEvents(upcastedStream, xmlSerializer) // FIXME: build better assertions - val upcastedEvents = upcastedStream.map { ier -> - xmlSerializer.deserialize( - ier.getData( - Document::class.java - ) - ) - } + assertThat(upcastedEvents) .hasSize(1) .element(0) @@ -89,22 +82,11 @@ class AccountCreatedEventUpcastingKotlinTest { ) fun `upcasts account created jackson`(events: List, result: List) { - val upcastedStream = jsonUpcaster.upcast(events.stream()).collect(Collectors.toList()) + val upcastedStream = jsonUpcaster.upcast(events.stream()) // FIXME: build better assertions - val upcastedEvents = upcastedStream.map { ier -> - val event: AccountCreatedEvent = jacksonSerializer.deserialize( - ier.data - ) - event - } - - val deserializedResult = result.map { ier -> - val event: AccountCreatedEvent = jacksonSerializer.deserialize( - ier.data - ) - event - } + val upcastedEvents = deserializeEvents(stream = upcastedStream, serializer = jacksonSerializer).collect(Collectors.toList()) + val deserializedResult = deserializeEvents(list = result, serializer = jacksonSerializer) assertThat(upcastedEvents).containsExactlyElementsOf(deserializedResult) } diff --git a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTestSupport.kt b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTestSupport.kt index aee8619..7d884c5 100644 --- a/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTestSupport.kt +++ b/extension/upcaster/core/src/main/kotlin/io/holixon/axon/testing/upcaster/UpcasterTestSupport.kt @@ -42,6 +42,28 @@ class UpcasterTestSupport { Stream.of(InitialEventRepresentation(entry, serializer)) + /** + * Deserializes events from `IntermediateEventRepresentation` stream. + * @param stream stream of intermediate representation + * @param serializer serializer + * @param T type of event + * @return stream of events + */ + @JvmStatic + fun deserializeEvents(stream: Stream, serializer: Serializer): Stream = + stream.map { ier -> serializer.deserialize(ier.data) } + + /** + * Deserializes events from `IntermediateEventRepresentation` list. + * @param list list of intermediate representation + * @param serializer serializer + * @param T type of event + * @return list of events + */ + @JvmStatic + fun deserializeEvents(list: List, serializer: Serializer): List = + list.map { ier -> serializer.deserialize(ier.data) } + /** * Creates an event data object serialized as JSON. * @param payloadJson JSON payload as string. @@ -196,5 +218,5 @@ class UpcasterTestSupport { upcastFunction = upcastFunction ) } - } + From 84e134c52df5a3e97fa20388cdbb22e3f51120ee Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 7 Jul 2023 23:46:03 +0200 Subject: [PATCH 41/70] typos --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ded0342..cd340f4 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Please put the following dependency on your project classpath: Now create a JUnit 5 test for your upcaster: ```java -// the package is important to put event data in correct folder inside the tst resources +// the package is important to put event data in correct folder inside the test resources package io.holixon.axon.testing.examples.upcaster.junit5.java; // intentionally left out some trivial imports @@ -80,7 +80,9 @@ public class AccountCreatedEventUpcastingJavaTest { ``` This looks like a miracle that the source events are passed in to the test, can be directly passed to the upcaster under the test and the result can be asserted using the collection of expected events. Indeed, the library makes use of JUnit 5 parameterized test -functionality, by defining a custom argument provider reading events out of files from the file system. We believe this is a good +functionality, by defining a custom argument provider reading events from the file system. + +We believe this is a good practice for upcaster and upcaster chain testing, where several representations of different versions of the same event exist and must be managed and set-up for the test. In also helps in situations where comparison with the expected event as an object in Java is not feasible because only one version of a class may be available (probably the latest one). @@ -113,7 +115,7 @@ of source events. The source events are passed to the test method annotated by t The other two with the `__result` suffix are considered to be JSON representations of the expected events, received after the upcaster run. Those will be passed to the test method as the second parameter `expectedSerializedEvents`. -The ordering of the files (in each group) is determined based on the first numbers until the first `__` separator. The next part of +The ordering of the files (in each group) is determined based on the first numbers before the first `__` separator. The next part of the file name is considered as the type name of the stored event. Finally, the last number is representing the revision of the event. You may want to use only parts of the functionality above. A good starting point for this are our examples. Please consider to look at the From 3970984edb315efea4ecdbae8b1d8188bbfa8c7d Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 11 Jul 2023 17:16:52 +0200 Subject: [PATCH 42/70] init axon assert --- extension/extension-assert/pom.xml | 28 +++ .../src/main/kotlin/AxonAssertions.kt | 28 +++ .../IntermediateEventRepresentationAssert.kt | 162 ++++++++++++++++++ ...rmediateEventRepresentationStreamAssert.kt | 44 +++++ extension/pom.xml | 1 + 5 files changed, 263 insertions(+) create mode 100644 extension/extension-assert/pom.xml create mode 100644 extension/extension-assert/src/main/kotlin/AxonAssertions.kt create mode 100644 extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt create mode 100644 extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt diff --git a/extension/extension-assert/pom.xml b/extension/extension-assert/pom.xml new file mode 100644 index 0000000..90774fb --- /dev/null +++ b/extension/extension-assert/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + io.holixon.axon.testing._ + extension + 4.7.4.1-SNAPSHOT + + + extension-assert + + + + + + + org.assertj + assertj-core + ${assertj.version} + + + org.axonframework + axon-messaging + + + diff --git a/extension/extension-assert/src/main/kotlin/AxonAssertions.kt b/extension/extension-assert/src/main/kotlin/AxonAssertions.kt new file mode 100644 index 0000000..97c5c45 --- /dev/null +++ b/extension/extension-assert/src/main/kotlin/AxonAssertions.kt @@ -0,0 +1,28 @@ +package io.holixon.axon.testing.assert + +import org.axonframework.serialization.Serializer +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation +import java.util.stream.Stream + +class AxonAssertions private constructor() { + companion object { + /** + * Creates the assert for given intermediate representation serialized using given serializer. + * @param actual current intermediate representation. + * @param serializer serializer in use. + * @return the asserting anchor for checks. + */ + @JvmStatic + fun assertThat(actual: IntermediateEventRepresentation, serializer: Serializer) = IntermediateEventRepresentationAssert.assertThat(actual, serializer) + + /** + * Creates the assert for given stream of intermediate representations serialized using given serializer. + * @param actual current intermediate representation. + * @param serializer serializer in use. + * @return the asserting anchor for checks. + */ + @JvmStatic + fun assertThat(actual: Stream, serializer: Serializer) = + IntermediateEventRepresentationStreamAssert.assertThat(actual, serializer) + } +} diff --git a/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt b/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt new file mode 100644 index 0000000..2fb18fa --- /dev/null +++ b/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt @@ -0,0 +1,162 @@ +package io.holixon.axon.testing.assert + +import org.assertj.core.api.AbstractAssert +import org.assertj.core.api.ObjectAssert +import org.axonframework.serialization.SerializedObject +import org.axonframework.serialization.SerializedType +import org.axonframework.serialization.Serializer +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation + +/** + * Asserts intermediate representation. + */ +class IntermediateEventRepresentationAssert(actual: IntermediateEventRepresentation, private val serializer: Serializer) : + AbstractAssert(actual, IntermediateEventRepresentationAssert::class.java) { + + + companion object { + /** + * Creates the assert for given intermediate representation serialized using given serializer. + * @param actual current intermediate representation. + * @param serializer serializer in use. + * @return the asserting anchor for checks. + */ + @JvmStatic + fun assertThat(actual: IntermediateEventRepresentation, serializer: Serializer) = IntermediateEventRepresentationAssert(actual, serializer) + } + + /** + * Asserts that the de-serialized data is equals to the given. + * @param expected expected data. + * @param T type of the data. + * @return object assert. + */ + fun hasDeserializedData(expected: T): ObjectAssert { + isNotNull + val event: T = serializer.deserialize(actual.data) + if (event != expected) { + failWithMessage("Expected the event to be <%s> but it was <%s>", expected, event) + } + return ObjectAssert(event) + } + + /** + * Asserts that the serialized data is equals to the given. + * @param expected expected data. + * @return object assert. + */ + fun hasData(expected: SerializedObject<*>): ObjectAssert> { + isNotNull + val so: SerializedObject<*> = actual.data + if (so != expected) { + failWithMessage("Expected the serialized object to be <%s> but it was <%s>", expected, so) + } + return ObjectAssert(so) + } + + /** + * Asserts that the aggregate identifier is equals to the given. + * @param expected aggregate identifier. + */ + fun hasAggregateIdentifier(expected: String): IntermediateEventRepresentationAssert { + isNotNull + val aggregateIdentifier = actual.aggregateIdentifier.orElse(null) + if (aggregateIdentifier != expected) { + failWithMessage("Expected the aggregate identifier to be <%s> but it was <%s>", expected, aggregateIdentifier) + } + return this + } + + /** + * Asserts that the message identifier is equals to the given. + * @param expected message identifier. + */ + fun hasMessageIdentifier(expected: String): IntermediateEventRepresentationAssert { + isNotNull + val messageIdentifier = actual.messageIdentifier + if (messageIdentifier != expected) { + failWithMessage("Expected the message identifier to be <%s> but it was <%s>", expected, messageIdentifier) + } + return this + } + + /** + * Asserts that the aggregate type is equals to the given. + * @param expected aggregate type. + */ + fun hasAggregateType(expected: String): IntermediateEventRepresentationAssert { + isNotNull + val aggregateType = actual.aggregateType.orElseGet(null) + if (aggregateType != expected) { + failWithMessage("Expected the aggregate type to be <%s> but it was <%s>", expected, aggregateType) + } + return this + } + + /** + * Asserts that the content type is equals to the given. + * @param expected content type. + */ + fun hasAggregateType(expected: Class<*>): IntermediateEventRepresentationAssert { + isNotNull + val contentType = actual.contentType + if (contentType != expected) { + failWithMessage("Expected the content type to be <%s> but it was <%s>", expected, contentType) + } + return this + } + + /** + * Asserts that the type is equals to the given. + * @param expected type. + */ + fun hasType(expected: SerializedType): IntermediateEventRepresentationAssert { + isNotNull + val type = actual.type + if (type != expected) { + failWithMessage("Expected the content type to be <%s> but it was <%s>", expected, type) + } + return this + } + + /** + * Asserts that the type name is equals to the given. + * @param expected type. + */ + fun hasTypeName(expected: String): IntermediateEventRepresentationAssert { + isNotNull + val typeName = actual.type.name + if (typeName != expected) { + failWithMessage("Expected the content type name to be <%s> but it was <%s>", expected, typeName) + } + return this + } + + /** + * Asserts that the type name is equals to the given. + * @param expected type. + */ + fun hasTypeRevision(expected: String?): IntermediateEventRepresentationAssert { + isNotNull + val typeName = actual.type.revision + if (typeName != expected) { + failWithMessage("Expected the content type name to be <%s> but it was <%s>", expected, typeName) + } + return this + } + + /** + * Asserts that the deserialized version of data is equals to deserialized version of given. + * @param expected intermediate representation. + * @param T type of the payload. + */ + fun isEqualsTo(expected: IntermediateEventRepresentation): IntermediateEventRepresentationAssert { + isNotNull + val deserialized: T = serializer.deserialize(actual.data) + val deserializedExpected: T = serializer.deserialize(actual.data) + if (deserialized != deserializedExpected) { + failWithMessage("Expected the content type name to be <%s> but it was <%s>", deserializedExpected, deserialized) + } + return this + } +} diff --git a/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt b/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt new file mode 100644 index 0000000..058cce3 --- /dev/null +++ b/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt @@ -0,0 +1,44 @@ +package io.holixon.axon.testing.assert + +import org.assertj.core.api.AbstractAssert +import org.axonframework.serialization.Serializer +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation +import java.util.stream.Collectors +import java.util.stream.Stream + +/** + * Asserts intermediate representation. + */ +class IntermediateEventRepresentationStreamAssert(actual: Stream, private val serializer: Serializer) : + AbstractAssert>( + actual, + IntermediateEventRepresentationStreamAssert::class.java + ) { + + + companion object { + /** + * Creates the assert for given stream of intermediate representations serialized using given serializer. + * @param actual current intermediate representation. + * @param serializer serializer in use. + * @return the asserting anchor for checks. + */ + @JvmStatic + fun assertThat(actual: Stream, serializer: Serializer) = IntermediateEventRepresentationStreamAssert(actual, serializer) + } + + /** + * Asserts that the deserialized version of data is element-wise equal to deserialized version of given. + * @param expected intermediate representation. + * @param T type of the payload. + */ + fun isContainsExactlyElementsOf(expected: Stream): IntermediateEventRepresentationStreamAssert { + isNotNull + val deserialized: List = actual.collect(Collectors.toList()).map { ier -> serializer.deserialize(ier.data) } + val deserializedExpected: List = expected.collect(Collectors.toList()).map { ier -> serializer.deserialize(ier.data) } + if (deserialized != deserializedExpected) { + failWithMessage("Expected the deserialized data to be <%s> but it was <%s>", deserializedExpected, deserialized) + } + return this + } +} diff --git a/extension/pom.xml b/extension/pom.xml index 1cdaf1c..75e918f 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -15,6 +15,7 @@ jgiven upcaster + extension-assert From 098fdf57c70956a0ade74dc602d95ae8f1688c16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 21:48:53 +0200 Subject: [PATCH 43/70] chore(deps): bump junit5.version from 5.9.3 to 5.10.0 (#313) Bumps `junit5.version` from 5.9.3 to 5.10.0. Updates `org.junit.jupiter:junit-jupiter` from 5.9.3 to 5.10.0 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.0) Updates `org.junit.jupiter:junit-jupiter-params` from 5.9.3 to 5.10.0 - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.3...r5.10.0) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.junit.jupiter:junit-jupiter-params dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 47f4466..8dae6f1 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 2.15.2 4.13.2 - 5.9.3 + 5.10.0 2.1.4 2.0.0 3.24.2 From 4bb006bce0de83882e39e4f6c4fc49b7fdac1f15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 19:32:08 +0200 Subject: [PATCH 44/70] chore(deps): bump org.axonframework:axon-bom from 4.8.0 to 4.8.1 (#314) Bumps [org.axonframework:axon-bom](https://github.com/AxonFramework/axon-bom) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/AxonFramework/axon-bom/releases) - [Commits](https://github.com/AxonFramework/axon-bom/compare/axon-4.8.0...axon-4.8.1) --- updated-dependencies: - dependency-name: org.axonframework:axon-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8dae6f1..4cbd795 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.9.0 - 4.8.0 + 4.8.1 1.2.5 1.2.5.0 From 7a8fe982a598a81d02c62f7f2e2383f3656b75e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:13:14 +0000 Subject: [PATCH 45/70] chore(deps): bump com.google.guava:guava from 32.1.1-jre to 32.1.2-jre Bumps [com.google.guava:guava](https://github.com/google/guava) from 32.1.1-jre to 32.1.2-jre. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/commits) --- updated-dependencies: - dependency-name: com.google.guava:guava dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- lib/fixtures/giftcard/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index eeefd16..5aab8d8 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -20,7 +20,7 @@ com.google.guava guava - 32.1.1-jre + 32.1.2-jre From f03aa42f66942c49750166dff2161767ba3327ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:21:49 +0200 Subject: [PATCH 46/70] chore(deps): bump ch.qos.logback:logback-classic from 1.4.8 to 1.4.9 (#316) Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.4.8 to 1.4.9. - [Commits](https://github.com/qos-ch/logback/compare/v_1.4.8...v_1.4.9) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index e17f539..55b7198 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -66,7 +66,7 @@ ch.qos.logback logback-classic - 1.4.8 + 1.4.9 test diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index a405810..cc5a5e1 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -40,7 +40,7 @@ ch.qos.logback logback-classic - 1.4.8 + 1.4.9 test diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index aa5fccb..9a8c733 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -74,7 +74,7 @@ ch.qos.logback logback-classic - 1.4.8 + 1.4.9 test diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index 4d41c86..180fe5a 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -44,7 +44,7 @@ ch.qos.logback logback-classic - 1.4.8 + 1.4.9 test From 09a3f22a3601e165a480439c2c75de3c9e39de30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:46:40 +0200 Subject: [PATCH 47/70] chore(deps): bump ch.qos.logback:logback-classic from 1.4.9 to 1.4.10 (#317) Bumps [ch.qos.logback:logback-classic](https://github.com/qos-ch/logback) from 1.4.9 to 1.4.10. - [Commits](https://github.com/qos-ch/logback/compare/v_1.4.9...v_1.4.10) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-classic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index 55b7198..5cac54e 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -66,7 +66,7 @@ ch.qos.logback logback-classic - 1.4.9 + 1.4.10 test diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index cc5a5e1..8d02bf2 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -40,7 +40,7 @@ ch.qos.logback logback-classic - 1.4.9 + 1.4.10 test diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index 9a8c733..162460e 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -74,7 +74,7 @@ ch.qos.logback logback-classic - 1.4.9 + 1.4.10 test diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index 180fe5a..fd00d99 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -44,7 +44,7 @@ ch.qos.logback logback-classic - 1.4.9 + 1.4.10 test From 229ca4d24eb004a7370b601167490ea409f4e65e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 23:25:29 +0200 Subject: [PATCH 48/70] chore(deps): bump ch.qos.logback:logback-classic from 1.4.10 to 1.4.11 (#318) --- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index 5cac54e..73e803e 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -66,7 +66,7 @@ ch.qos.logback logback-classic - 1.4.10 + 1.4.11 test diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index 8d02bf2..a95ed5b 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -40,7 +40,7 @@ ch.qos.logback logback-classic - 1.4.10 + 1.4.11 test diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index 162460e..4c7634b 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -74,7 +74,7 @@ ch.qos.logback logback-classic - 1.4.10 + 1.4.11 test diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index fd00d99..f4d7e6a 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -44,7 +44,7 @@ ch.qos.logback logback-classic - 1.4.10 + 1.4.11 test From 11a7170284deb725cfbf90ecb68d9a05d6fa7d2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 20:14:19 +0200 Subject: [PATCH 49/70] chore(deps-dev): bump org.mockito:mockito-core from 5.4.0 to 5.5.0 (#320) Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.4.0 to 5.5.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.4.0...v5.5.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index 0f45af6..ef0dad4 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -50,7 +50,7 @@ org.mockito mockito-core - 5.4.0 + 5.5.0 test From b99772b20526d5ab6143683ff078e9b150704eef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 10:39:40 +0200 Subject: [PATCH 50/70] chore(deps): bump org.apache.maven.plugins:maven-enforcer-plugin (#322) Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.3.0...enforcer-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4cbd795..d9cb2a1 100644 --- a/pom.xml +++ b/pom.xml @@ -385,7 +385,7 @@ maven-enforcer-plugin - 3.3.0 + 3.4.0 enforce-java From d5ade39227144feacca9e156b2e40e03ebd9a086 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 14:10:06 +0200 Subject: [PATCH 51/70] chore(deps): bump kotlin.version from 1.9.0 to 1.9.10 (#321) Bumps `kotlin.version` from 1.9.0 to 1.9.10. Updates `org.jetbrains.kotlin:kotlin-bom` from 1.9.0 to 1.9.10 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/v1.9.10/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.0...v1.9.10) Updates `org.jetbrains.kotlin:kotlin-maven-allopen` from 1.9.0 to 1.9.10 Updates `org.jetbrains.kotlin:kotlin-maven-plugin` from 1.9.0 to 1.9.10 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-bom dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d9cb2a1..495c9a3 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 11 - 1.9.0 + 1.9.10 4.8.1 From 49fed5cecf0489274c30925d369bb3dadcb0d5d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 14:10:23 +0200 Subject: [PATCH 52/70] chore(deps): bump org.axonframework:axon-bom from 4.8.1 to 4.8.2 (#319) Bumps [org.axonframework:axon-bom](https://github.com/AxonFramework/axon-bom) from 4.8.1 to 4.8.2. - [Release notes](https://github.com/AxonFramework/axon-bom/releases) - [Commits](https://github.com/AxonFramework/axon-bom/compare/axon-4.8.1...axon-4.8.2) --- updated-dependencies: - dependency-name: org.axonframework:axon-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 495c9a3..ac254a0 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.9.10 - 4.8.1 + 4.8.2 1.2.5 1.2.5.0 From 3bb3fbf099aed410de3ef018d149040567e5e816 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 09:27:04 +0200 Subject: [PATCH 53/70] chore(deps): bump org.jetbrains.dokka:dokka-maven-plugin (#323) Bumps [org.jetbrains.dokka:dokka-maven-plugin](https://github.com/Kotlin/dokka) from 1.8.20 to 1.9.0. - [Release notes](https://github.com/Kotlin/dokka/releases) - [Commits](https://github.com/Kotlin/dokka/compare/v1.8.20...v1.9.0) --- updated-dependencies: - dependency-name: org.jetbrains.dokka:dokka-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ac254a0..6bfbb60 100644 --- a/pom.xml +++ b/pom.xml @@ -332,7 +332,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.8.20 + 1.9.0 ${dokka.skip} From b2fa141fcf4c6f287b5a582710a431333779060a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 20:08:52 +0200 Subject: [PATCH 54/70] chore(deps): bump org.slf4j:slf4j-simple from 2.0.7 to 2.0.9 (#324) Bumps org.slf4j:slf4j-simple from 2.0.7 to 2.0.9. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-simple dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index ef0dad4..a2df095 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -38,7 +38,7 @@ org.slf4j slf4j-simple - 2.0.7 + 2.0.9 test diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 4b95cc9..5301a05 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -40,7 +40,7 @@ org.slf4j slf4j-simple - 2.0.7 + 2.0.9 test diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index 8133f00..eaa812f 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -45,7 +45,7 @@ org.slf4j slf4j-simple - 2.0.7 + 2.0.9 test From 557fcc229c10e290378c267328b32e34c006fdd1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:42:17 +0200 Subject: [PATCH 55/70] chore(deps): bump io.toolisticon.testing:jgiven-kotlin (#330) Bumps [io.toolisticon.testing:jgiven-kotlin](https://github.com/toolisticon/jgiven-kotlin) from 1.2.5.0 to 1.3.0.0. - [Release notes](https://github.com/toolisticon/jgiven-kotlin/releases) - [Commits](https://github.com/toolisticon/jgiven-kotlin/compare/1.2.5.0...1.3.0.0) --- updated-dependencies: - dependency-name: io.toolisticon.testing:jgiven-kotlin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index a2df095..a4931f9 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -27,7 +27,7 @@ io.toolisticon.testing jgiven-kotlin - 1.2.5.0 + 1.3.0.0 test diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 5301a05..941e073 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -29,7 +29,7 @@ io.toolisticon.testing jgiven-kotlin - 1.2.5.0 + 1.3.0.0 test diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index a95ed5b..d38a6de 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -27,7 +27,7 @@ io.toolisticon.testing jgiven-kotlin - 1.2.5.0 + 1.3.0.0 test diff --git a/pom.xml b/pom.xml index 6bfbb60..0930e9d 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 4.8.2 1.2.5 - 1.2.5.0 + 1.3.0.0 2.15.2 From 6c4ebd54f759a4bbedd2c1b2ae4e2b0da0e19aeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:43:36 +0200 Subject: [PATCH 56/70] chore(deps): bump org.apache.maven.plugins:maven-enforcer-plugin (#329) Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.4.0...enforcer-3.4.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0930e9d..42e4125 100644 --- a/pom.xml +++ b/pom.xml @@ -385,7 +385,7 @@ maven-enforcer-plugin - 3.4.0 + 3.4.1 enforce-java From aa05df05e54237f90ff000bb356a1f1351ba4a40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:44:20 +0200 Subject: [PATCH 57/70] chore(deps): bump org.axonframework:axon-bom from 4.8.2 to 4.8.3 (#325) Bumps [org.axonframework:axon-bom](https://github.com/AxonFramework/axon-bom) from 4.8.2 to 4.8.3. - [Release notes](https://github.com/AxonFramework/axon-bom/releases) - [Commits](https://github.com/AxonFramework/axon-bom/compare/axon-4.8.2...axon-4.8.3) --- updated-dependencies: - dependency-name: org.axonframework:axon-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 42e4125..2789859 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.9.10 - 4.8.2 + 4.8.3 1.2.5 1.3.0.0 From ca5563cb70ec949385d71ac9ba03bc7179610e45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 21:27:42 +0200 Subject: [PATCH 58/70] chore(deps): bump jgiven.version from 1.2.5 to 1.3.0 (#326) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2789859..1f358a3 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 4.8.3 - 1.2.5 + 1.3.0 1.3.0.0 From 4a5366c15fe0f42bf29ba729fa03622cc0f2be59 Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Mon, 11 Sep 2023 21:45:55 +0200 Subject: [PATCH 59/70] set semver to latest axon version 4.8.3.x --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- examples/pom.xml | 2 +- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/jgiven/pom.xml | 2 +- extension/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- extension/upcaster/pom.xml | 2 +- lib/fixtures/bankaccount/pom.xml | 2 +- lib/fixtures/giftcard/pom.xml | 2 +- lib/fixtures/pom.xml | 2 +- lib/pom.xml | 2 +- pom.xml | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index a4931f9..dd7f6cb 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 941e073..ad8475b 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index eaa812f..9c6a420 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/pom.xml b/examples/pom.xml index 576ffa2..caf0373 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT examples diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index 73e803e..357243c 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/junit/pom.xml b/extension/jgiven/junit/pom.xml index 3a7c815..e9463d9 100644 --- a/extension/jgiven/junit/pom.xml +++ b/extension/jgiven/junit/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index d38a6de..bae6815 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/pom.xml b/extension/jgiven/pom.xml index 8c5efe8..6ae1e64 100644 --- a/extension/jgiven/pom.xml +++ b/extension/jgiven/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT extension-jgiven diff --git a/extension/pom.xml b/extension/pom.xml index 1cdaf1c..6df3c0b 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT extension diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index 4c7634b..f133f28 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index f4d7e6a..64992a3 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/upcaster/pom.xml b/extension/upcaster/pom.xml index f4b910a..e384e1d 100644 --- a/extension/upcaster/pom.xml +++ b/extension/upcaster/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT extension-upcaster diff --git a/lib/fixtures/bankaccount/pom.xml b/lib/fixtures/bankaccount/pom.xml index f254323..787e85c 100644 --- a/lib/fixtures/bankaccount/pom.xml +++ b/lib/fixtures/bankaccount/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index 5aab8d8..866b1a9 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index 65acac5..93bb265 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ lib - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT fixtures diff --git a/lib/pom.xml b/lib/pom.xml index ffdafa6..bb53127 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT lib diff --git a/pom.xml b/pom.xml index 1f358a3..583d158 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.8.3.0-SNAPSHOT pom From e906ab0e3ec5feb865cdbe0615a9c5a216a1660a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:42:52 +0200 Subject: [PATCH 60/70] chore(deps-dev): bump org.projectlombok:lombok from 1.18.28 to 1.18.30 (#332) Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.28 to 1.18.30. - [Release notes](https://github.com/projectlombok/lombok/releases) - [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown) - [Commits](https://github.com/projectlombok/lombok/compare/v1.18.28...v1.18.30) --- updated-dependencies: - dependency-name: org.projectlombok:lombok dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- lib/fixtures/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index eaa812f..ba5cf6c 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -57,7 +57,7 @@ org.projectlombok lombok - 1.18.28 + 1.18.30 test diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index 65acac5..7af5b98 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -42,7 +42,7 @@ org.projectlombok lombok - 1.18.28 + 1.18.30 provided From 2658045898114b9c89e48429ee39e5f59a3138fd Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Thu, 21 Sep 2023 23:05:00 +0200 Subject: [PATCH 61/70] implemented asserts for element, list and stream --- examples/bankaccount-upcaster-junit5/pom.xml | 5 +++ .../AccountCreatedEventUpcastingKotlinTest.kt | 31 +++++++++---------- .../{extension-assert => assert}/pom.xml | 13 +++++++- .../src/main/kotlin/AxonAssertions.kt | 11 +++++++ .../IntermediateEventRepresentationAssert.kt | 29 ++++++++++++++--- ...rmediateEventRepresentationStreamAssert.kt | 4 ++- extension/pom.xml | 2 +- pom.xml | 6 +++- 8 files changed, 76 insertions(+), 25 deletions(-) rename extension/{extension-assert => assert}/pom.xml (66%) rename extension/{extension-assert => assert}/src/main/kotlin/AxonAssertions.kt (71%) rename extension/{extension-assert => assert}/src/main/kotlin/IntermediateEventRepresentationAssert.kt (80%) rename extension/{extension-assert => assert}/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt (91%) diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index 8133f00..e3ca6b3 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -18,6 +18,11 @@ axon-testing-upcaster-junit5 test + + io.holixon.axon.testing + axon-testing-assert + test + com.fasterxml.jackson.module diff --git a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt index 0fc0926..3a20b3b 100644 --- a/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt +++ b/examples/bankaccount-upcaster-junit5/src/test/kotlin/AccountCreatedEventUpcastingKotlinTest.kt @@ -5,19 +5,16 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import com.thoughtworks.xstream.XStream import com.thoughtworks.xstream.security.AnyTypePermission import fixture.bankaccount.event.AccountCreatedEvent +import io.holixon.axon.testing.assert.AxonAssertions import io.holixon.axon.testing.upcaster.MessageEncoding import io.holixon.axon.testing.upcaster.UpcasterTest -import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.deserializeEvents import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.jsonNodeUpcaster import io.holixon.axon.testing.upcaster.UpcasterTestSupport.Companion.xmlDocumentUpcaster -import org.assertj.core.api.Assertions.assertThat import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation import org.axonframework.serialization.xml.XStreamSerializer -import org.dom4j.Document import org.dom4j.Element import java.util.stream.Collectors -import java.util.stream.Stream class AccountCreatedEventUpcastingKotlinTest { @@ -61,33 +58,35 @@ class AccountCreatedEventUpcastingKotlinTest { } + /** + * This method demonstrates usage of input events provided to the test method, + * usage of the list assert and element assert for intermediate representation. + */ @UpcasterTest( messageEncoding = MessageEncoding.XSTREAM ) fun upcasts_account_created_xstream(events: List) { val upcastedStream = xmlUpcaster.upcast(events.stream()) - val upcastedEvents = deserializeEvents(upcastedStream, xmlSerializer) - // FIXME: build better assertions - - assertThat(upcastedEvents) + AxonAssertions + .assertThat(upcastedStream.collect(Collectors.toList()), xmlSerializer) .hasSize(1) .element(0) - .isEqualTo(accountEvent) + .hasDeserializedData(accountEvent) } + /** + * This method demonstrates usage of input events and resulting provided to the test method, + * and usage of the stream assert. + */ @UpcasterTest( messageEncoding = MessageEncoding.JACKSON ) fun `upcasts account created jackson`(events: List, result: List) { - val upcastedStream = jsonUpcaster.upcast(events.stream()) - - // FIXME: build better assertions - val upcastedEvents = deserializeEvents(stream = upcastedStream, serializer = jacksonSerializer).collect(Collectors.toList()) - val deserializedResult = deserializeEvents(list = result, serializer = jacksonSerializer) - - assertThat(upcastedEvents).containsExactlyElementsOf(deserializedResult) + AxonAssertions.assertThat(upcastedStream, jacksonSerializer) + .containsExactlyDeserializedElementsOf(result.stream(), AccountCreatedEvent::class.java) } } + diff --git a/extension/extension-assert/pom.xml b/extension/assert/pom.xml similarity index 66% rename from extension/extension-assert/pom.xml rename to extension/assert/pom.xml index 90774fb..9764cf9 100644 --- a/extension/extension-assert/pom.xml +++ b/extension/assert/pom.xml @@ -9,12 +9,23 @@ 4.7.4.1-SNAPSHOT - extension-assert + io.holixon.axon.testing + axon-testing-assert + Axon Testing - Assert + + com.fasterxml.jackson.core + jackson-databind + + + org.dom4j + dom4j + ${dom4j.version} + org.assertj assertj-core diff --git a/extension/extension-assert/src/main/kotlin/AxonAssertions.kt b/extension/assert/src/main/kotlin/AxonAssertions.kt similarity index 71% rename from extension/extension-assert/src/main/kotlin/AxonAssertions.kt rename to extension/assert/src/main/kotlin/AxonAssertions.kt index 97c5c45..d00bd2b 100644 --- a/extension/extension-assert/src/main/kotlin/AxonAssertions.kt +++ b/extension/assert/src/main/kotlin/AxonAssertions.kt @@ -24,5 +24,16 @@ class AxonAssertions private constructor() { @JvmStatic fun assertThat(actual: Stream, serializer: Serializer) = IntermediateEventRepresentationStreamAssert.assertThat(actual, serializer) + + /** + * Creates the assert for given list of intermediate representation serialized using given serializer. + * @param actual list of current intermediate representations. + * @param serializer serializer in use. + * @return the asserting anchor for checks. + */ + @JvmStatic + fun assertThat(actual: List, serializer: Serializer) = + IntermediateEventRepresentationListAssert.assertThat(actual, serializer) + } } diff --git a/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt b/extension/assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt similarity index 80% rename from extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt rename to extension/assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt index 2fb18fa..f0f22ed 100644 --- a/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt +++ b/extension/assert/src/main/kotlin/IntermediateEventRepresentationAssert.kt @@ -1,17 +1,32 @@ package io.holixon.axon.testing.assert +import com.fasterxml.jackson.databind.JsonNode import org.assertj.core.api.AbstractAssert import org.assertj.core.api.ObjectAssert import org.axonframework.serialization.SerializedObject import org.axonframework.serialization.SerializedType import org.axonframework.serialization.Serializer +import org.axonframework.serialization.json.JacksonSerializer import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation +import org.axonframework.serialization.xml.XStreamSerializer +import org.dom4j.Document + /** * Asserts intermediate representation. */ -class IntermediateEventRepresentationAssert(actual: IntermediateEventRepresentation, private val serializer: Serializer) : - AbstractAssert(actual, IntermediateEventRepresentationAssert::class.java) { +class IntermediateEventRepresentationAssert( + actual: IntermediateEventRepresentation, + private val serializer: Serializer, + private val intermediateRepresentationTypeResolver: (serializer: Serializer) -> Class<*> = + { + when (it) { + is XStreamSerializer -> Document::class.java + is JacksonSerializer -> JsonNode::class.java + else -> throw IllegalArgumentException("Unknown serializer type ${serializer::class.java}") + } + } +) : AbstractAssert(actual, IntermediateEventRepresentationAssert::class.java) { companion object { @@ -33,7 +48,9 @@ class IntermediateEventRepresentationAssert(actual: IntermediateEventRepresentat */ fun hasDeserializedData(expected: T): ObjectAssert { isNotNull - val event: T = serializer.deserialize(actual.data) + val intermediateRepresentationType = intermediateRepresentationTypeResolver.invoke(serializer) + val data = actual.getData(intermediateRepresentationType) + val event: T = serializer.deserialize(data) if (event != expected) { failWithMessage("Expected the event to be <%s> but it was <%s>", expected, event) } @@ -150,13 +167,15 @@ class IntermediateEventRepresentationAssert(actual: IntermediateEventRepresentat * @param expected intermediate representation. * @param T type of the payload. */ - fun isEqualsTo(expected: IntermediateEventRepresentation): IntermediateEventRepresentationAssert { + fun isEqualDeserializedTo(expected: IntermediateEventRepresentation): IntermediateEventRepresentationAssert { isNotNull val deserialized: T = serializer.deserialize(actual.data) - val deserializedExpected: T = serializer.deserialize(actual.data) + val deserializedExpected: T = serializer.deserialize(expected.data) if (deserialized != deserializedExpected) { failWithMessage("Expected the content type name to be <%s> but it was <%s>", deserializedExpected, deserialized) } return this } + + } diff --git a/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt b/extension/assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt similarity index 91% rename from extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt rename to extension/assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt index 058cce3..3ff3482 100644 --- a/extension/extension-assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt +++ b/extension/assert/src/main/kotlin/IntermediateEventRepresentationStreamAssert.kt @@ -32,7 +32,7 @@ class IntermediateEventRepresentationStreamAssert(actual: Stream isContainsExactlyElementsOf(expected: Stream): IntermediateEventRepresentationStreamAssert { + fun containsExactlyDeserializedElementsOf(expected: Stream, clazz: Class): IntermediateEventRepresentationStreamAssert { isNotNull val deserialized: List = actual.collect(Collectors.toList()).map { ier -> serializer.deserialize(ier.data) } val deserializedExpected: List = expected.collect(Collectors.toList()).map { ier -> serializer.deserialize(ier.data) } @@ -41,4 +41,6 @@ class IntermediateEventRepresentationStreamAssert(actual: Stream jgiven upcaster - extension-assert + assert diff --git a/pom.xml b/pom.xml index af29abe..a8df0c4 100644 --- a/pom.xml +++ b/pom.xml @@ -103,7 +103,11 @@ axon-testing-upcaster-junit5 ${project.version} - + + io.holixon.axon.testing + axon-testing-assert + ${project.version} + From 6fa9fbfea72983882c0a20b418d6de900b483172 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Thu, 21 Sep 2023 23:05:10 +0200 Subject: [PATCH 62/70] implemented asserts for element, list and stream --- ...termediateEventRepresentationListAssert.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 extension/assert/src/main/kotlin/IntermediateEventRepresentationListAssert.kt diff --git a/extension/assert/src/main/kotlin/IntermediateEventRepresentationListAssert.kt b/extension/assert/src/main/kotlin/IntermediateEventRepresentationListAssert.kt new file mode 100644 index 0000000..a5ef61a --- /dev/null +++ b/extension/assert/src/main/kotlin/IntermediateEventRepresentationListAssert.kt @@ -0,0 +1,26 @@ +package io.holixon.axon.testing.assert + +import org.assertj.core.api.AbstractListAssert +import org.axonframework.serialization.Serializer +import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation + +class IntermediateEventRepresentationListAssert( + actual: List, + private val serializer: Serializer +) : AbstractListAssert +, IntermediateEventRepresentation, IntermediateEventRepresentationAssert>( + actual, IntermediateEventRepresentationListAssert::class.java +) { + companion object { + fun assertThat(actual: List, serializer: Serializer): IntermediateEventRepresentationListAssert = + IntermediateEventRepresentationListAssert(actual, serializer) + } + + override fun toAssert(value: IntermediateEventRepresentation, description: String): IntermediateEventRepresentationAssert = + IntermediateEventRepresentationAssert(value, serializer).`as`(description) + + + override fun newAbstractIterableAssert(iterable: MutableIterable): IntermediateEventRepresentationListAssert = + IntermediateEventRepresentationListAssert(iterable.toList(), serializer) + +} From 8d347f4d8247727847ec1030a01fd82e6c822cc3 Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Thu, 21 Sep 2023 23:45:16 +0200 Subject: [PATCH 63/70] drop junit 4 modules, fixes #335 --- examples/bankaccount-jgiven-junit4/pom.xml | 66 ---- .../BankAccountAggregateJgivenJavaTest.java | 281 ------------------ .../java/MoneyTransferSagaJgivenJavaTest.java | 45 --- .../BankAccountAggregateJgivenKotlinTest.kt | 55 ---- .../MoneyTransferSagaJgivenKotlinTest.kt | 47 --- examples/pom.xml | 1 - extension/jgiven/junit/pom.xml | 27 -- .../kotlin/AggregateFixtureScenarioTest.kt | 12 - .../main/kotlin/SagaFixtureScenarioTest.kt | 12 - extension/jgiven/pom.xml | 1 - 10 files changed, 547 deletions(-) delete mode 100644 examples/bankaccount-jgiven-junit4/pom.xml delete mode 100644 examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/BankAccountAggregateJgivenJavaTest.java delete mode 100644 examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/MoneyTransferSagaJgivenJavaTest.java delete mode 100644 examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt delete mode 100644 examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt delete mode 100644 extension/jgiven/junit/pom.xml delete mode 100644 extension/jgiven/junit/src/main/kotlin/AggregateFixtureScenarioTest.kt delete mode 100644 extension/jgiven/junit/src/main/kotlin/SagaFixtureScenarioTest.kt diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml deleted file mode 100644 index dd7f6cb..0000000 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - 4.0.0 - - - io.holixon.axon.testing._ - examples - 4.8.3.0-SNAPSHOT - - - io.holixon.axon.testing.examples - bankaccount-jgiven-junit4 - - - - junit - junit - ${junit.version} - test - - - io.holixon.axon.testing - axon-testing-jgiven-junit - test - - - io.toolisticon.testing - jgiven-kotlin - 1.3.0.0 - test - - - io.holixon.axon.testing.lib - axon-testing-fixtures-bankaccount - test - - - org.slf4j - slf4j-simple - 2.0.9 - test - - - org.assertj - assertj-core - 3.24.2 - test - - - org.mockito - mockito-core - 5.5.0 - test - - - - - - - - - - - - diff --git a/examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/BankAccountAggregateJgivenJavaTest.java b/examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/BankAccountAggregateJgivenJavaTest.java deleted file mode 100644 index e51d7bd..0000000 --- a/examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/BankAccountAggregateJgivenJavaTest.java +++ /dev/null @@ -1,281 +0,0 @@ -package io.holixon.axon.testing.examples.jgiven.junit4.java; - -import com.tngtech.jgiven.annotation.ProvidedScenarioState; -import fixture.bankaccount.BankAccountAggregate; -import fixture.bankaccount.command.DepositMoneyCommand; -import fixture.bankaccount.command.InitializeMoneyTransferCommand; -import fixture.bankaccount.command.WithdrawMoneyCommand; -import fixture.bankaccount.event.BalanceChangedEvent; -import fixture.bankaccount.event.MoneyDepositedEvent; -import fixture.bankaccount.event.MoneyTransferInitializedEvent; -import fixture.bankaccount.event.MoneyWithdrawnEvent; -import fixture.bankaccount.exception.InsufficientBalanceException; -import fixture.bankaccount.exception.MaximalBalanceExceededException; -import fixture.bankaccount.exception.MaximumActiveMoneyTransfersReachedException; -import io.holixon.axon.testing.jgiven.junit.AggregateFixtureScenarioTest; -import org.axonframework.test.aggregate.AggregateTestFixture; -import org.junit.Test; - -import java.util.UUID; - -import static fixture.bankaccount.AccountAggregateTestHelper.ACCOUNT_ID_1; -import static fixture.bankaccount.AccountAggregateTestHelper.ACCOUNT_ID_2; -import static fixture.bankaccount.AccountAggregateTestHelper.CUSTOMER_ID_1; -import static fixture.bankaccount.AccountAggregateTestHelper.accountAggregate; -import static fixture.bankaccount.AccountAggregateTestHelper.accountCreatedEvent; -import static fixture.bankaccount.AccountAggregateTestHelper.createAccountCommand; -import static fixture.bankaccount.BankAccountAggregate.Configuration.DEFAULT_INITIAL_BALANCE; -import static fixture.bankaccount.BankAccountAggregate.Configuration.DEFAULT_MAXIMAL_BALANCE; -import static io.holixon.axon.testing.jgiven.AxonJGivenJava.aggregateTestFixtureBuilder; -import static org.mockito.Mockito.mock; - -public class BankAccountAggregateJgivenJavaTest extends AggregateFixtureScenarioTest { - - private interface MyService { - } - - @ProvidedScenarioState - private final AggregateTestFixture fixture = aggregateTestFixtureBuilder(BankAccountAggregate.class) - .registerInjectableResource(mock(MyService.class)) - .build(); - - @Test - public void create_account() { - given() - .noPriorActivity() - ; - - when() - .command(createAccountCommand(ACCOUNT_ID_1, CUSTOMER_ID_1)) - ; - - then() - .expectEvent( - accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1) - ) - .and() - .expectState(BankAccountAggregate.builder() - .accountId(ACCOUNT_ID_1) - .maximalBalance(DEFAULT_MAXIMAL_BALANCE) - .currentBalance(DEFAULT_INITIAL_BALANCE) - .build() - ) - ; - } - - @Test - public void withdraw_amount() { - given() - .event(accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(200) - .build() - ) - ; - - when() - .command(WithdrawMoneyCommand.builder().accountId(ACCOUNT_ID_1).amount(50).build()) - ; - - then() - .expectEvents( - MoneyWithdrawnEvent.builder().accountId(ACCOUNT_ID_1).amount(50).build(), - BalanceChangedEvent.builder().accountId(ACCOUNT_ID_1).newBalance(150).build() - ) - .and() - .expectState( - accountAggregate(ACCOUNT_ID_1, 150, DEFAULT_MAXIMAL_BALANCE) - ) - ; - } - - @Test - public void withdraw_amount_insufficientBalance() { - given() - .event(accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(100) - .build() - ) - ; - - when() - .command(WithdrawMoneyCommand.builder().accountId(ACCOUNT_ID_1).amount(200).build()) - ; - - then() - .expectException( - InsufficientBalanceException.class - ) - .expectExceptionMessage( - "Insufficient balance, was:100, required:200" - ) - ; - } - - - @Test - public void deposit_money() { - given() - .event(accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1)) - ; - when() - .command(DepositMoneyCommand.builder().accountId(ACCOUNT_ID_1).amount(100).build()) - ; - then() - .expectEvents( - MoneyDepositedEvent.builder().accountId(ACCOUNT_ID_1).amount(100).build(), - BalanceChangedEvent.builder().accountId(ACCOUNT_ID_1).newBalance(100).build() - ) - .and() - .expectState( - accountAggregate(ACCOUNT_ID_1, 100, DEFAULT_MAXIMAL_BALANCE) - ) - ; - } - - @Test - public void we_must_not_deposit_more_than_maximalBalance() { - given() - .event(accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1) - .toBuilder().maximalBalance(100).build() - ) - ; - - when().command(DepositMoneyCommand.builder() - .accountId(ACCOUNT_ID_1) - .amount(101) - .build() - ); - - then() - .expectException( - MaximalBalanceExceededException.class - ) - .and() - .expectExceptionMessage( - "MaximalBalance exceeded: currentBalance=0, amount=101, maximalBalance=100" - ) - ; - - } - - @Test - public void cannot_have_more_than_one_active_transfer() { - String transactionId = UUID.randomUUID().toString(); - - given() - .events(accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(1000).build(), - MoneyTransferInitializedEvent.builder() - .transactionId(transactionId) - .targetAccountId(ACCOUNT_ID_2) - .sourceAccountId(ACCOUNT_ID_1) - .amount(100) - .build() - ) - ; - - when() - .command( - InitializeMoneyTransferCommand.builder() - .sourceAccountId(ACCOUNT_ID_1) - .targetAccountId(ACCOUNT_ID_2) - .amount(100) - .build() - ) - ; - - then() - .expectException(MaximumActiveMoneyTransfersReachedException.class) - ; - } - - @Test - public void cannot_initialize_moneyTransfer_on_insufficient_balance() { - String transactionId = UUID.randomUUID().toString(); - - given() - .event( - accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(100).build() - ) - ; - - when() - .command( - InitializeMoneyTransferCommand.builder() - .sourceAccountId(ACCOUNT_ID_1) - .targetAccountId(ACCOUNT_ID_2) - .transactionId(transactionId) - .amount(200) - .build() - ) - ; - - then() - .expectException(InsufficientBalanceException.class) - ; - } - - @Test - public void initialize_moneyTransfer() { - String transactionId = UUID.randomUUID().toString(); - - given() - .event( - accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(100).build() - ) - ; - - when() - .command( - InitializeMoneyTransferCommand.builder() - .sourceAccountId(ACCOUNT_ID_1) - .targetAccountId(ACCOUNT_ID_2) - .transactionId(transactionId) - .amount(50) - .build() - ); - - then() - .expectEvents( - MoneyTransferInitializedEvent.builder() - .sourceAccountId(ACCOUNT_ID_1) - .targetAccountId(ACCOUNT_ID_2) - .transactionId(transactionId) - .amount(50) - .build() - ) - .and() - // FIXME: expectState consumer -// .expectState(a -> assertThat(a.getActiveMoneyTransfer()) -// .isEqualTo(BankAccountAggregate.ActiveMoneyTransfer.builder() -// .amount(50) -// .transactionId(transactionId) -// .build()) -// ) - ; - } - - @Test - public void cannot_withdraw_if_amount_reserved_for_active_tranfer() { - String transactionId = UUID.randomUUID().toString(); - - given() - .events( - accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(100).build(), - MoneyTransferInitializedEvent.builder().sourceAccountId(ACCOUNT_ID_1).targetAccountId(ACCOUNT_ID_2).transactionId(transactionId) - .amount(50).build() - ) - ; - - when() - .command(WithdrawMoneyCommand.builder().accountId(ACCOUNT_ID_1).amount(100).build()) - ; - - then() - .expectException(InsufficientBalanceException.class) - ; - } -} diff --git a/examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/MoneyTransferSagaJgivenJavaTest.java b/examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/MoneyTransferSagaJgivenJavaTest.java deleted file mode 100644 index 8964d45..0000000 --- a/examples/bankaccount-jgiven-junit4/src/test/java/io/holixon/axon/testing/examples/jgiven/junit4/java/MoneyTransferSagaJgivenJavaTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package io.holixon.axon.testing.examples.jgiven.junit4.java; - -import com.tngtech.jgiven.annotation.ProvidedScenarioState; -import fixture.bankaccount.MoneyTransferSaga; -import fixture.bankaccount.event.MoneyTransferInitializedEvent; -import io.holixon.axon.testing.jgiven.junit.SagaFixtureScenarioTest; -import org.axonframework.test.saga.SagaTestFixture; -import org.junit.Test; - -import static fixture.bankaccount.AccountAggregateTestHelper.*; -import static io.holixon.axon.testing.jgiven.AxonJGivenJava.sagaTestFixtureBuilder; - -public class MoneyTransferSagaJgivenJavaTest extends SagaFixtureScenarioTest { - - @ProvidedScenarioState - private final SagaTestFixture fixture = sagaTestFixtureBuilder(MoneyTransferSaga.class) - .registerStartRecordingCallback(() -> { - }) - .build(); - - @Test - public void initialize_transfer_money() { - given() - .aggregatePublishedEvent(ACCOUNT_ID_1, accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(2000).build() - ) - .and() - .aggregatePublishedEvent(ACCOUNT_ID_2, accountCreatedEvent(ACCOUNT_ID_2, CUSTOMER_ID_2)) - ; - - when() - .aggregatePublishes(ACCOUNT_ID_1, MoneyTransferInitializedEvent.builder() - .sourceAccountId(ACCOUNT_ID_1) - .targetAccountId(ACCOUNT_ID_2) - .transactionId("1") - .amount(100) - .build()) - ; - - then() - .expectActiveSagas(1) - ; - - } -} diff --git a/examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt b/examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt deleted file mode 100644 index d7146e8..0000000 --- a/examples/bankaccount-jgiven-junit4/src/test/kotlin/BankAccountAggregateJgivenKotlinTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.holixon.axon.testing.examples.jgiven.junit4.kotlin - -import com.tngtech.jgiven.annotation.ProvidedScenarioState -import fixture.bankaccount.BankAccountAggregate -import fixture.bankaccount.BankAccountAggregate.Configuration.DEFAULT_MAXIMAL_BALANCE -import fixture.bankaccount.command.CreateAccountCommand -import fixture.bankaccount.event.AccountCreatedEvent -import io.holixon.axon.testing.jgiven.AxonJGiven -import io.holixon.axon.testing.jgiven.AxonJGiven.aggregateTestFixtureBuilder -import io.holixon.axon.testing.jgiven.junit.AggregateFixtureScenarioTest -import io.toolisticon.testing.jgiven.AND -import io.toolisticon.testing.jgiven.GIVEN -import io.toolisticon.testing.jgiven.THEN -import io.toolisticon.testing.jgiven.WHEN -import org.axonframework.test.aggregate.AggregateTestFixture -import org.junit.Test - -class BankAccountAggregateJgivenKotlinTest : AggregateFixtureScenarioTest() { - - @ProvidedScenarioState - private val fixture = aggregateTestFixtureBuilder().build() - - @Test - fun `create account`() { - GIVEN - .noPriorActivity() - - WHEN - .command( - CreateAccountCommand.builder() - .accountId("1") - .customerId("1") - .initialBalance(100) - .build() - ) - - THEN - .expectEvent( - AccountCreatedEvent.builder() - .accountId("1") - .customerId("1") - .initialBalance(100) - .maximalBalance(DEFAULT_MAXIMAL_BALANCE) - .build() - ) - .AND - .expectState( - BankAccountAggregate.builder() - .accountId("1") - .currentBalance(100) - .maximalBalance(DEFAULT_MAXIMAL_BALANCE) - .build() - ) - } -} diff --git a/examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt b/examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt deleted file mode 100644 index 91902a9..0000000 --- a/examples/bankaccount-jgiven-junit4/src/test/kotlin/MoneyTransferSagaJgivenKotlinTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -package io.holixon.axon.testing.examples.jgiven.junit4.kotlin - -import com.tngtech.jgiven.annotation.ProvidedScenarioState -import fixture.bankaccount.AccountAggregateTestHelper.* -import fixture.bankaccount.MoneyTransferSaga -import fixture.bankaccount.event.MoneyTransferInitializedEvent -import io.holixon.axon.testing.jgiven.AxonJGiven -import io.holixon.axon.testing.jgiven.AxonJGiven.sagaTestFixtureBuilder -import io.holixon.axon.testing.jgiven.junit.SagaFixtureScenarioTest -import io.toolisticon.testing.jgiven.GIVEN -import io.toolisticon.testing.jgiven.THEN -import io.toolisticon.testing.jgiven.WHEN -import org.junit.Test - -class MoneyTransferSagaJgivenKotlinTest : SagaFixtureScenarioTest() { - - @ProvidedScenarioState - private val fixture = sagaTestFixtureBuilder() - .registerStartRecordingCallback({}) - .build() - - @Test - internal fun `initialize money transfer`() { - GIVEN - .aggregatePublishedEvent( - ACCOUNT_ID_1, accountCreatedEvent(ACCOUNT_ID_1, CUSTOMER_ID_1).toBuilder() - .initialBalance(2000).build() - ) - .and() - .aggregatePublishedEvent(ACCOUNT_ID_2, accountCreatedEvent(ACCOUNT_ID_2, CUSTOMER_ID_2)) - ; - - WHEN - .aggregatePublishes( - ACCOUNT_ID_1, MoneyTransferInitializedEvent.builder() - .sourceAccountId(ACCOUNT_ID_1) - .targetAccountId(ACCOUNT_ID_2) - .transactionId("1") - .amount(100) - .build() - ) - - THEN - .expectActiveSagas(1) - - } -} diff --git a/examples/pom.xml b/examples/pom.xml index caf0373..90d77af 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -18,7 +18,6 @@ - bankaccount-jgiven-junit4 bankaccount-jgiven-junit5 bankaccount-upcaster-junit5 diff --git a/extension/jgiven/junit/pom.xml b/extension/jgiven/junit/pom.xml deleted file mode 100644 index e9463d9..0000000 --- a/extension/jgiven/junit/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - Axon Testing - JGiven Support for JUnit4 - - - io.holixon.axon.testing._ - extension-jgiven - 4.8.3.0-SNAPSHOT - - - io.holixon.axon.testing - axon-testing-jgiven-junit - - - - ${project.groupId} - axon-testing-jgiven-core - - - com.tngtech.jgiven - jgiven-junit - ${jgiven.version} - - - diff --git a/extension/jgiven/junit/src/main/kotlin/AggregateFixtureScenarioTest.kt b/extension/jgiven/junit/src/main/kotlin/AggregateFixtureScenarioTest.kt deleted file mode 100644 index 44615c2..0000000 --- a/extension/jgiven/junit/src/main/kotlin/AggregateFixtureScenarioTest.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.holixon.axon.testing.jgiven.junit - -import com.tngtech.jgiven.junit.ScenarioTest -import io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureGiven -import io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureThen -import io.holixon.axon.testing.jgiven.aggregate.AggregateFixtureWhen - -/** - * Aggregate fixture scenario test. - * @param T aggregate type. - */ -abstract class AggregateFixtureScenarioTest : ScenarioTest, AggregateFixtureWhen, AggregateFixtureThen>() diff --git a/extension/jgiven/junit/src/main/kotlin/SagaFixtureScenarioTest.kt b/extension/jgiven/junit/src/main/kotlin/SagaFixtureScenarioTest.kt deleted file mode 100644 index bedfa92..0000000 --- a/extension/jgiven/junit/src/main/kotlin/SagaFixtureScenarioTest.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.holixon.axon.testing.jgiven.junit - -import com.tngtech.jgiven.junit.ScenarioTest -import io.holixon.axon.testing.jgiven.saga.SagaFixtureGiven -import io.holixon.axon.testing.jgiven.saga.SagaFixtureThen -import io.holixon.axon.testing.jgiven.saga.SagaFixtureWhen - -/** - * Saga fixture scenario test. - * @param T saga type. - */ -abstract class SagaFixtureScenarioTest : ScenarioTest, SagaFixtureWhen, SagaFixtureThen>() diff --git a/extension/jgiven/pom.xml b/extension/jgiven/pom.xml index 6ae1e64..3646118 100644 --- a/extension/jgiven/pom.xml +++ b/extension/jgiven/pom.xml @@ -22,7 +22,6 @@ core - junit junit5 From 9ae925b510e81fb32d9091d73e75487c012f3f0f Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 22 Sep 2023 00:56:02 +0200 Subject: [PATCH 64/70] bugfix: remove quotes for commands and events allowing vargs to work in reporting, fix #334 --- .../core/src/main/kotlin/AxonJGivenStage.kt | 4 +++- .../kotlin/aggregate/AggregateFixtureGiven.kt | 23 ++++++++++++++----- .../kotlin/aggregate/AggregateFixtureThen.kt | 15 +++++------- .../kotlin/aggregate/AggregateFixtureWhen.kt | 4 ++-- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/extension/jgiven/core/src/main/kotlin/AxonJGivenStage.kt b/extension/jgiven/core/src/main/kotlin/AxonJGivenStage.kt index aba64ea..117d957 100644 --- a/extension/jgiven/core/src/main/kotlin/AxonJGivenStage.kt +++ b/extension/jgiven/core/src/main/kotlin/AxonJGivenStage.kt @@ -1,11 +1,13 @@ package io.holixon.axon.testing.jgiven import com.tngtech.jgiven.Stage -import org.axonframework.test.aggregate.ResultValidator /** * Marker annotation to identify Axon JGiven Stages. */ annotation class AxonJGivenStage +/** + * Step function to create JGiven stage steps easily. + */ internal inline fun > Stage.step(block: X.() -> Unit) = self().apply(block) diff --git a/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureGiven.kt b/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureGiven.kt index 9f8045e..57f801a 100644 --- a/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureGiven.kt +++ b/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureGiven.kt @@ -40,21 +40,25 @@ class AggregateFixtureGiven : Stage>() { * @param command dispatched command. */ @As("command:") - fun command(@Quoted command: Any): AggregateFixtureGiven = this.commands(command) + fun command(command: Any): AggregateFixtureGiven = this.commandsInternal(listOf(command)) /** * One or several commands has been dispatched. * @param commands dispatched commands. */ @As("commands:") - fun commands(@Quoted vararg commands: Any): AggregateFixtureGiven = this.commands(commands.toList()) + fun commands(vararg commands: Any): AggregateFixtureGiven = this.commandsInternal(commands.toList()) /** * One or several commands has been dispatched. * @param commands dispatched commands. */ @As("commands:") - fun commands(@Quoted commands: List): AggregateFixtureGiven = execute { + fun commands(commands: List): AggregateFixtureGiven = this.commandsInternal(commands) + + + private fun commandsInternal(commands: List): AggregateFixtureGiven = execute { + if (context.isFirstGiven) { context.isFirstGiven = false context.fixture!!.givenCommands(commands) @@ -68,21 +72,27 @@ class AggregateFixtureGiven : Stage>() { * @param event published event. */ @As("event:") - fun event(@Quoted event: Any): AggregateFixtureGiven = this.events(event) + fun event(event: Any): AggregateFixtureGiven = this.eventsInternal(listOf(event)) /** * One or several events has been published. * @param events published events. */ @As("events:") - fun events(@Quoted vararg events: Any): AggregateFixtureGiven = this.events(events.toList()) + fun events(vararg events: Any): AggregateFixtureGiven = this.eventsInternal(events.toList()) /** * One or several events has been published. * @param events published events. */ @As("events:") - fun events(@Quoted events: List): AggregateFixtureGiven = execute { + fun events(events: List): AggregateFixtureGiven = this.eventsInternal(events) + + + /* + * Private method to avoid duplications in report. + */ + private fun eventsInternal(events: List) = execute { if (context.isFirstGiven) { context.isFirstGiven = false context.fixture!!.given(events) @@ -91,6 +101,7 @@ class AggregateFixtureGiven : Stage>() { } } + /** * Sets the time. * @param instant new time. diff --git a/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureThen.kt b/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureThen.kt index 481ab63..269e3a4 100644 --- a/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureThen.kt +++ b/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureThen.kt @@ -3,10 +3,7 @@ package io.holixon.axon.testing.jgiven.aggregate import com.tngtech.jgiven.Stage -import com.tngtech.jgiven.annotation.As -import com.tngtech.jgiven.annotation.Hidden -import com.tngtech.jgiven.annotation.ProvidedScenarioState -import com.tngtech.jgiven.annotation.Quoted +import com.tngtech.jgiven.annotation.* import io.holixon.axon.testing.jgiven.AxonJGivenStage import io.holixon.axon.testing.jgiven.step import org.axonframework.commandhandling.CommandResultMessage @@ -35,14 +32,14 @@ class AggregateFixtureThen : Stage>() { * @param event expected event. */ @As("expect event:") - fun expectEvent(@Quoted event: Any) = this.expectEvents(event) + fun expectEvent(event: Any) = this.expectEvents(event) /** * Expect a series of events. * @param events events to expect. */ @As("expect events:") - fun expectEvents(@Quoted vararg events: Any) = execute { + fun expectEvents(vararg events: Any) = execute { expectEvents(*events) } @@ -51,7 +48,7 @@ class AggregateFixtureThen : Stage>() { * @param events events to expect. */ @As("expect events:") - fun expectEvents(@Quoted vararg events: EventMessage<*>) = execute { + fun expectEvents(vararg events: EventMessage<*>) = execute { expectEvents(*events) } @@ -121,7 +118,7 @@ class AggregateFixtureThen : Stage>() { } /** - * Expects an exception of provided type to be thrown. + * Expects an exception of the provided type to be thrown. * @param clazz type of exception. */ @As("expect exception: $") @@ -130,7 +127,7 @@ class AggregateFixtureThen : Stage>() { } /** - * Expects an exception of provided type to be thrown. + * Expects an exception of the provided type to be thrown. * @param clazz type of exception. */ @As("expect exception: $") diff --git a/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureWhen.kt b/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureWhen.kt index 301328c..d488cda 100644 --- a/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureWhen.kt +++ b/extension/jgiven/core/src/main/kotlin/aggregate/AggregateFixtureWhen.kt @@ -29,7 +29,7 @@ class AggregateFixtureWhen : Stage>() { * @param cmd command to dispatch. */ @As("command: \$cmd") - fun command(@Quoted cmd: Any): AggregateFixtureWhen = command(cmd, MetaData.emptyInstance()) + fun command(cmd: Any): AggregateFixtureWhen = command(cmd, MetaData.emptyInstance()) /** * Dispatches a command. @@ -37,7 +37,7 @@ class AggregateFixtureWhen : Stage>() { * @param metadata metadata to include into command message. */ @As("command: \$cmd, metadata: \$metadata") - fun command(@Quoted cmd: Any, metadata: Map): AggregateFixtureWhen = execute { context.testExecutor!!.`when`(cmd, metadata) } + fun command(cmd: Any, metadata: Map): AggregateFixtureWhen = execute { context.testExecutor!!.`when`(cmd, metadata) } /** * Moves time to new value. From ffbee041eb4899cbc13a21d8ae80e6575c664153 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 22 Sep 2023 00:56:44 +0200 Subject: [PATCH 65/70] chore: update axon version to 4.7.6, kotlin to 1.9.10 --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- examples/pom.xml | 11 ++++++- extension/assert/pom.xml | 2 +- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/jgiven/pom.xml | 2 +- extension/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- extension/upcaster/pom.xml | 2 +- lib/fixtures/bankaccount/pom.xml | 2 +- lib/fixtures/giftcard/pom.xml | 2 +- lib/fixtures/pom.xml | 2 +- lib/pom.xml | 2 +- pom.xml | 30 +++++++++++++++----- 18 files changed, 49 insertions(+), 24 deletions(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index 0f45af6..4d53cc9 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing.examples diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 4b95cc9..102e479 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing.examples diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index e3ca6b3..77fae30 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing.examples diff --git a/examples/pom.xml b/examples/pom.xml index 576ffa2..b6d7ccd 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.7.6.0 examples @@ -33,4 +33,13 @@ + + + + com.tngtech.jgiven + jgiven-maven-plugin + + + + diff --git a/extension/assert/pom.xml b/extension/assert/pom.xml index 9764cf9..49d56ab 100644 --- a/extension/assert/pom.xml +++ b/extension/assert/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index e17f539..c20def6 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing diff --git a/extension/jgiven/junit/pom.xml b/extension/jgiven/junit/pom.xml index 3a7c815..5386567 100644 --- a/extension/jgiven/junit/pom.xml +++ b/extension/jgiven/junit/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index a405810..2509ee2 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing diff --git a/extension/jgiven/pom.xml b/extension/jgiven/pom.xml index 8c5efe8..0ee7578 100644 --- a/extension/jgiven/pom.xml +++ b/extension/jgiven/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.4.1-SNAPSHOT + 4.7.6.0 extension-jgiven diff --git a/extension/pom.xml b/extension/pom.xml index 7119945..39a9ba7 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.7.6.0 extension diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index aa5fccb..5f48b63 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index 4d41c86..c0ac5a9 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing diff --git a/extension/upcaster/pom.xml b/extension/upcaster/pom.xml index f4b910a..87b4faa 100644 --- a/extension/upcaster/pom.xml +++ b/extension/upcaster/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.4.1-SNAPSHOT + 4.7.6.0 extension-upcaster diff --git a/lib/fixtures/bankaccount/pom.xml b/lib/fixtures/bankaccount/pom.xml index f254323..23a065c 100644 --- a/lib/fixtures/bankaccount/pom.xml +++ b/lib/fixtures/bankaccount/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing.lib diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index eeefd16..7ca1506 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.4.1-SNAPSHOT + 4.7.6.0 io.holixon.axon.testing.lib diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index 65acac5..2e4ef65 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ lib - 4.7.4.1-SNAPSHOT + 4.7.6.0 fixtures diff --git a/lib/pom.xml b/lib/pom.xml index ffdafa6..e6cdec2 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.7.6.0 lib diff --git a/pom.xml b/pom.xml index a8df0c4..32eabe6 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.4.1-SNAPSHOT + 4.7.6.0 pom @@ -19,10 +19,10 @@ 11 - 1.8.22 + 1.9.10 - 4.8.0 + 4.7.4 1.2.5 1.2.5.0 @@ -325,6 +325,22 @@ + + com.tngtech.jgiven + jgiven-maven-plugin + ${jgiven.version} + + + + report + + + + + html + + + org.apache.maven.plugins @@ -336,7 +352,7 @@ org.jetbrains.dokka dokka-maven-plugin - 1.8.20 + 1.9.10 ${dokka.skip} @@ -632,9 +648,9 @@ - + 2021 From e4d53aa399c5a53dced7e020fae6542a4c555d59 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 22 Sep 2023 01:09:04 +0200 Subject: [PATCH 66/70] chore: corrected version of the artifact --- examples/bankaccount-jgiven-junit4/pom.xml | 2 +- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- examples/pom.xml | 2 +- extension/assert/pom.xml | 2 +- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/jgiven/pom.xml | 2 +- extension/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- extension/upcaster/pom.xml | 2 +- lib/fixtures/bankaccount/pom.xml | 2 +- lib/fixtures/giftcard/pom.xml | 2 +- lib/fixtures/pom.xml | 2 +- lib/pom.xml | 2 +- pom.xml | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/bankaccount-jgiven-junit4/pom.xml b/examples/bankaccount-jgiven-junit4/pom.xml index cf5603b..73fe6f7 100644 --- a/examples/bankaccount-jgiven-junit4/pom.xml +++ b/examples/bankaccount-jgiven-junit4/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 49811c3..d69ccc2 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index 74269e1..54cb8dc 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/pom.xml b/examples/pom.xml index b6d7ccd..94ee9d8 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0 + 4.7.6.0-SNAPSHOT examples diff --git a/extension/assert/pom.xml b/extension/assert/pom.xml index 49d56ab..1c7d76a 100644 --- a/extension/assert/pom.xml +++ b/extension/assert/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index 7220f95..3515161 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/junit/pom.xml b/extension/jgiven/junit/pom.xml index 5386567..6149da0 100644 --- a/extension/jgiven/junit/pom.xml +++ b/extension/jgiven/junit/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index 55cd241..7e045a9 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/pom.xml b/extension/jgiven/pom.xml index 0ee7578..3809362 100644 --- a/extension/jgiven/pom.xml +++ b/extension/jgiven/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.6.0 + 4.7.6.0-SNAPSHOT extension-jgiven diff --git a/extension/pom.xml b/extension/pom.xml index 39a9ba7..26a0543 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0 + 4.7.6.0-SNAPSHOT extension diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index 49ea9c2..7a4123c 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index a738a93..8d5442d 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/upcaster/pom.xml b/extension/upcaster/pom.xml index 87b4faa..a87469c 100644 --- a/extension/upcaster/pom.xml +++ b/extension/upcaster/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.6.0 + 4.7.6.0-SNAPSHOT extension-upcaster diff --git a/lib/fixtures/bankaccount/pom.xml b/lib/fixtures/bankaccount/pom.xml index 23a065c..87f3fb0 100644 --- a/lib/fixtures/bankaccount/pom.xml +++ b/lib/fixtures/bankaccount/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index cb716b9..f3d3faf 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.6.0 + 4.7.6.0-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index 8d413e8..95e432c 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ lib - 4.7.6.0 + 4.7.6.0-SNAPSHOT fixtures diff --git a/lib/pom.xml b/lib/pom.xml index e6cdec2..d5ab558 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0 + 4.7.6.0-SNAPSHOT lib diff --git a/pom.xml b/pom.xml index 82abc9a..0cd2ed9 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0 + 4.7.6.0-SNAPSHOT pom From aac244b160cf3a9e0ef8f970b3523816fae73701 Mon Sep 17 00:00:00 2001 From: Jan Galinski Date: Fri, 22 Sep 2023 01:10:41 +0200 Subject: [PATCH 67/70] allow state assertions on sagas fixes #333 --- .../src/test/kotlin/SagaStateAssertionTest.kt | 110 ++++++++++++++++++ .../src/main/kotlin/saga/SagaFixtureGiven.kt | 16 ++- .../src/main/kotlin/saga/SagaFixtureThen.kt | 33 +++++- .../src/main/kotlin/saga/SagaFixtureWhen.kt | 2 +- .../core/src/main/kotlin/saga/_reflection.kt | 31 +++++ 5 files changed, 185 insertions(+), 7 deletions(-) create mode 100644 examples/bankaccount-jgiven-junit5/src/test/kotlin/SagaStateAssertionTest.kt create mode 100644 extension/jgiven/core/src/main/kotlin/saga/_reflection.kt diff --git a/examples/bankaccount-jgiven-junit5/src/test/kotlin/SagaStateAssertionTest.kt b/examples/bankaccount-jgiven-junit5/src/test/kotlin/SagaStateAssertionTest.kt new file mode 100644 index 0000000..b81e031 --- /dev/null +++ b/examples/bankaccount-jgiven-junit5/src/test/kotlin/SagaStateAssertionTest.kt @@ -0,0 +1,110 @@ +package io.holixon.axon.testing.examples.jgiven.junit5.kotlin + +import com.tngtech.jgiven.annotation.ProvidedScenarioState +import io.holixon.axon.testing.examples.jgiven.junit5.kotlin.SagaStateAssertionTest.StatefulSaga +import io.holixon.axon.testing.examples.jgiven.junit5.kotlin.SagaStateAssertionTest.StatefulSaga.Companion.associationProperty +import io.holixon.axon.testing.jgiven.AxonJGiven +import io.holixon.axon.testing.jgiven.junit5.SagaFixtureScenarioTest +import io.toolisticon.testing.jgiven.AND +import io.toolisticon.testing.jgiven.GIVEN +import io.toolisticon.testing.jgiven.THEN +import io.toolisticon.testing.jgiven.WHEN +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.modelling.saga.AssociationValue +import org.axonframework.modelling.saga.EndSaga +import org.axonframework.modelling.saga.SagaEventHandler +import org.axonframework.modelling.saga.StartSaga +import org.junit.jupiter.api.Test + +internal class SagaStateAssertionTest : SagaFixtureScenarioTest() { + + data class StartSagaEvent(val key: String) + data class IncrementSagaEvent(val key: String, val add: Int) + data class EndSagaEvent(val key: String) + + class StatefulSaga { + companion object { + const val ASSOCIATION_PROPERTY = "key" + + fun associationProperty(key: String) = AssociationValue(ASSOCIATION_PROPERTY, key) + } + + lateinit var key: String + var state: Int = 0 + + @SagaEventHandler(associationProperty = ASSOCIATION_PROPERTY) + @StartSaga + fun on(evt: StartSagaEvent) { + this.key = evt.key + } + + @SagaEventHandler(associationProperty = ASSOCIATION_PROPERTY) + fun on(evt: IncrementSagaEvent) { + this.state += evt.add + } + + @SagaEventHandler(associationProperty = ASSOCIATION_PROPERTY) + @EndSaga + fun on(evt: EndSagaEvent) { + this.key = evt.key + } + + override fun toString(): String { + return "StatefulSaga(key='$key', state=$state)" + } + } + + @ProvidedScenarioState + private val fixture = AxonJGiven.sagaTestFixtureBuilder().build() + + @Test + fun `a fresh saga has state 0`() { + val key = "123" + + GIVEN.noPriorActivity() + + WHEN + .publishing(StartSagaEvent(key)) + + THEN + .expectActiveSagas(1) + .AND + .expectSagaState(associationProperty(key), "state is zero") { + assertThat(it.state).isEqualTo(0) + } + } + + + @Test + fun `saga state can be increased`() { + val key = "234" + + GIVEN.aggregatePublishedEvent(key, StartSagaEvent(key)) + + WHEN + .publishing(IncrementSagaEvent(key, 2)) + + THEN + .expectActiveSagas(1) + .AND + .expectSagaState(associationProperty(key), "state is two") { + assertThat(it.state).isEqualTo(2) + } + } + + @Test + fun `saga can be ended`() { + val key = "234" + + GIVEN + .aggregatePublishedEvent(key, StartSagaEvent(key)) + .AND + .aggregatePublishedEvent(key, IncrementSagaEvent(key, 2)) + + WHEN + .publishing(EndSagaEvent(key)) + + THEN + .expectActiveSagas(0) + } +} diff --git a/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureGiven.kt b/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureGiven.kt index d6bdb47..e50ac14 100644 --- a/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureGiven.kt +++ b/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureGiven.kt @@ -5,7 +5,9 @@ package io.holixon.axon.testing.jgiven.saga import com.tngtech.jgiven.Stage import com.tngtech.jgiven.annotation.* import io.holixon.axon.testing.jgiven.AxonJGivenStage +import org.axonframework.modelling.saga.repository.inmemory.InMemorySagaStore import org.axonframework.test.saga.FixtureExecutionResult +import org.axonframework.test.saga.FixtureExecutionResultImpl import org.axonframework.test.saga.SagaTestFixture import org.axonframework.test.saga.WhenState @@ -25,12 +27,18 @@ class SagaFixtureGiven : Stage>() { @ProvidedScenarioState private lateinit var thenState: FixtureExecutionResult + @ProvidedScenarioState + private lateinit var sagaStore: InMemorySagaStore + + @ProvidedScenarioState + private lateinit var sagaType: Class + + @BeforeStage internal fun init() { - with(SagaTestFixture::class.java.getDeclaredField("fixtureExecutionResult")) { - isAccessible = true - thenState = get(fixture) as FixtureExecutionResult - } + thenState = fixture.fixtureExecutionResult + sagaStore = fixture.sagaStore + sagaType = fixture.sagaType } /** diff --git a/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureThen.kt b/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureThen.kt index 0751d59..741d33b 100644 --- a/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureThen.kt +++ b/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureThen.kt @@ -5,21 +5,29 @@ package io.holixon.axon.testing.jgiven.saga import com.tngtech.jgiven.Stage import com.tngtech.jgiven.annotation.As import com.tngtech.jgiven.annotation.ExpectedScenarioState +import com.tngtech.jgiven.annotation.Hidden import io.holixon.axon.testing.jgiven.AxonJGivenStage import io.holixon.axon.testing.jgiven.step import org.axonframework.deadline.DeadlineMessage import org.axonframework.eventhandling.EventMessage +import org.axonframework.modelling.saga.AssociationValue +import org.axonframework.modelling.saga.repository.inmemory.InMemorySagaStore import org.axonframework.test.saga.FixtureExecutionResult import org.hamcrest.Matcher import java.time.Duration import java.time.Instant - @AxonJGivenStage class SagaFixtureThen : Stage>() { @ExpectedScenarioState(required = true) - lateinit var thenState: FixtureExecutionResult + private lateinit var thenState: FixtureExecutionResult + + @ExpectedScenarioState(required = true) + private lateinit var sagaStore: InMemorySagaStore + + @ExpectedScenarioState(required = true) + private lateinit var sagaType: Class /** * Expect the given number of Sagas to be active (i.e. ready to respond to incoming events. @@ -296,4 +304,25 @@ class SagaFixtureThen : Stage>() { fun expectDeadlinesMet(vararg expected: Any): SagaFixtureThen = step { thenState.expectTriggeredDeadlines(*expected) } + + + @As("expect saga state: \$description") + fun expectSagaState( + @Hidden associationValue: AssociationValue, + description: String, + @Hidden assertion: (T) -> Unit + ): SagaFixtureThen = step { + assertion(loadSaga(associationValue)) + } + + private fun loadSaga(associationValue: AssociationValue): T { + val sagas: List = sagaStore.findSagas(sagaType, associationValue) + .map { sagaKey -> + sagaStore.loadSaga(sagaType, sagaKey) + }.map { entry -> entry.saga() } + + check(sagas.size == 1) { "Expected exactly one saga for associationProperty=${associationValue.key}, value=${associationValue.value}, but found: ${sagas.size}." } + + return sagas.single() + } } diff --git a/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureWhen.kt b/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureWhen.kt index 9547e0a..32fd114 100644 --- a/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureWhen.kt +++ b/extension/jgiven/core/src/main/kotlin/saga/SagaFixtureWhen.kt @@ -1,4 +1,5 @@ @file:Suppress("unused") + package io.holixon.axon.testing.jgiven.saga import com.tngtech.jgiven.Stage @@ -12,7 +13,6 @@ import org.axonframework.test.saga.WhenState import java.time.Duration import java.time.Instant - /** * When stage for saga fixture. * @param T aggregate type. diff --git a/extension/jgiven/core/src/main/kotlin/saga/_reflection.kt b/extension/jgiven/core/src/main/kotlin/saga/_reflection.kt new file mode 100644 index 0000000..f304112 --- /dev/null +++ b/extension/jgiven/core/src/main/kotlin/saga/_reflection.kt @@ -0,0 +1,31 @@ +package io.holixon.axon.testing.jgiven.saga + +import io.holixon.axon.testing.jgiven.saga.SagaTestFixtureFields.fieldFixtureFixtureExecutionResult +import io.holixon.axon.testing.jgiven.saga.SagaTestFixtureFields.fieldSagaStore +import io.holixon.axon.testing.jgiven.saga.SagaTestFixtureFields.fieldSagaType +import org.axonframework.modelling.saga.repository.inmemory.InMemorySagaStore +import org.axonframework.test.saga.FixtureExecutionResult +import org.axonframework.test.saga.SagaTestFixture +import java.lang.reflect.Field + +/** + * Handles access to private final fields in axon-test. + * Might become obsolete when fields are configurable in core. + */ +object SagaTestFixtureFields { + private val CLASS = SagaTestFixture::class.java + + private fun Class<*>.getDeclaredAccessibleField(fieldName: String): Field = getDeclaredField(fieldName) + .apply { + isAccessible = true + } + + val fieldSagaStore: Field = CLASS.getDeclaredAccessibleField("sagaStore") + val fieldFixtureFixtureExecutionResult: Field = CLASS.getDeclaredAccessibleField("fixtureExecutionResult") + val fieldSagaType: Field = CLASS.getDeclaredAccessibleField("sagaType") +} + +@Suppress("UNCHECKED_CAST") +val SagaTestFixture.sagaType: Class get() = fieldSagaType.get(this) as Class +val SagaTestFixture.fixtureExecutionResult: FixtureExecutionResult get() = fieldFixtureFixtureExecutionResult.get(this) as FixtureExecutionResult +val SagaTestFixture.sagaStore: InMemorySagaStore get() = fieldSagaStore.get(this) as InMemorySagaStore From ced87de26f54b06d22cd619ecb29e310e75ddb10 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 22 Sep 2023 09:17:18 +0200 Subject: [PATCH 68/70] pull dependecy up, change axon bom version to 4.7.4 --- extension/jgiven/core/pom.xml | 1 - extension/jgiven/junit5/pom.xml | 1 - extension/upcaster/core/pom.xml | 1 - extension/upcaster/junit5/pom.xml | 1 - pom.xml | 8 +++++++- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index 3515161..f2a3fdc 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -66,7 +66,6 @@ ch.qos.logback logback-classic - 1.4.11 test diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index 7e045a9..9aaba63 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -40,7 +40,6 @@ ch.qos.logback logback-classic - 1.4.11 test diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index 7a4123c..cfbd11d 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -74,7 +74,6 @@ ch.qos.logback logback-classic - 1.4.11 test diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index 8d5442d..7f65de4 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -44,7 +44,6 @@ ch.qos.logback logback-classic - 1.4.11 test diff --git a/pom.xml b/pom.xml index 0cd2ed9..115cbb9 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.9.10 - 4.8.0 + 4.7.4 1.3.0 1.3.0.0 @@ -108,6 +108,12 @@ axon-testing-assert ${project.version} + + ch.qos.logback + logback-classic + 1.4.11 + test + From fc4d929c90caf99bc47bb010f17f27f88e49b3be Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 22 Sep 2023 13:35:35 +0200 Subject: [PATCH 69/70] Update versions for release --- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- examples/pom.xml | 2 +- extension/assert/pom.xml | 2 +- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/jgiven/pom.xml | 2 +- extension/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- extension/upcaster/pom.xml | 2 +- lib/fixtures/bankaccount/pom.xml | 2 +- lib/fixtures/giftcard/pom.xml | 2 +- lib/fixtures/pom.xml | 2 +- lib/pom.xml | 2 +- pom.xml | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index d69ccc2..4dcea40 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index 54cb8dc..08a5fdf 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing.examples diff --git a/examples/pom.xml b/examples/pom.xml index 0dcade8..eb15e1a 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT examples diff --git a/extension/assert/pom.xml b/extension/assert/pom.xml index 1c7d76a..662884c 100644 --- a/extension/assert/pom.xml +++ b/extension/assert/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index f2a3fdc..20594f7 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index 9aaba63..f22b4ae 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/jgiven/pom.xml b/extension/jgiven/pom.xml index 118f15c..6cac6f3 100644 --- a/extension/jgiven/pom.xml +++ b/extension/jgiven/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT extension-jgiven diff --git a/extension/pom.xml b/extension/pom.xml index 26a0543..679d159 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT extension diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index cfbd11d..caa3cd7 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index 7f65de4..5246c40 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing diff --git a/extension/upcaster/pom.xml b/extension/upcaster/pom.xml index a87469c..8496817 100644 --- a/extension/upcaster/pom.xml +++ b/extension/upcaster/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT extension-upcaster diff --git a/lib/fixtures/bankaccount/pom.xml b/lib/fixtures/bankaccount/pom.xml index 87f3fb0..6d5ebdb 100644 --- a/lib/fixtures/bankaccount/pom.xml +++ b/lib/fixtures/bankaccount/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index f3d3faf..263a3fc 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT io.holixon.axon.testing.lib diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index 95e432c..df032de 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ lib - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT fixtures diff --git a/lib/pom.xml b/lib/pom.xml index d5ab558..669182c 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT lib diff --git a/pom.xml b/pom.xml index 115cbb9..8c343cb 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.7.6.0-SNAPSHOT + 4.8.0.0-SNAPSHOT pom From 728aa44304ff06e088504cdcdf949343b8abe32f Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Fri, 22 Sep 2023 13:37:09 +0200 Subject: [PATCH 70/70] Update for next development version --- examples/bankaccount-jgiven-junit5/pom.xml | 2 +- examples/bankaccount-upcaster-junit5/pom.xml | 2 +- examples/pom.xml | 2 +- extension/assert/pom.xml | 2 +- extension/jgiven/core/pom.xml | 2 +- extension/jgiven/junit5/pom.xml | 2 +- extension/jgiven/pom.xml | 2 +- extension/pom.xml | 2 +- extension/upcaster/core/pom.xml | 2 +- extension/upcaster/junit5/pom.xml | 2 +- extension/upcaster/pom.xml | 2 +- lib/fixtures/bankaccount/pom.xml | 2 +- lib/fixtures/giftcard/pom.xml | 2 +- lib/fixtures/pom.xml | 2 +- lib/pom.xml | 2 +- pom.xml | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/bankaccount-jgiven-junit5/pom.xml b/examples/bankaccount-jgiven-junit5/pom.xml index 4dcea40..af6727e 100644 --- a/examples/bankaccount-jgiven-junit5/pom.xml +++ b/examples/bankaccount-jgiven-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing.examples diff --git a/examples/bankaccount-upcaster-junit5/pom.xml b/examples/bankaccount-upcaster-junit5/pom.xml index 08a5fdf..6160607 100644 --- a/examples/bankaccount-upcaster-junit5/pom.xml +++ b/examples/bankaccount-upcaster-junit5/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ examples - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing.examples diff --git a/examples/pom.xml b/examples/pom.xml index eb15e1a..86091aa 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.8.0.0-SNAPSHOT + 4.8.0.0 examples diff --git a/extension/assert/pom.xml b/extension/assert/pom.xml index 662884c..2e31ba3 100644 --- a/extension/assert/pom.xml +++ b/extension/assert/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing diff --git a/extension/jgiven/core/pom.xml b/extension/jgiven/core/pom.xml index 20594f7..92869a4 100644 --- a/extension/jgiven/core/pom.xml +++ b/extension/jgiven/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing diff --git a/extension/jgiven/junit5/pom.xml b/extension/jgiven/junit5/pom.xml index f22b4ae..40eec5e 100644 --- a/extension/jgiven/junit5/pom.xml +++ b/extension/jgiven/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-jgiven - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing diff --git a/extension/jgiven/pom.xml b/extension/jgiven/pom.xml index 6cac6f3..2781b5f 100644 --- a/extension/jgiven/pom.xml +++ b/extension/jgiven/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.8.0.0-SNAPSHOT + 4.8.0.0 extension-jgiven diff --git a/extension/pom.xml b/extension/pom.xml index 679d159..01236b8 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.8.0.0-SNAPSHOT + 4.8.0.0 extension diff --git a/extension/upcaster/core/pom.xml b/extension/upcaster/core/pom.xml index caa3cd7..ed54627 100644 --- a/extension/upcaster/core/pom.xml +++ b/extension/upcaster/core/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing diff --git a/extension/upcaster/junit5/pom.xml b/extension/upcaster/junit5/pom.xml index 5246c40..37b3cc9 100644 --- a/extension/upcaster/junit5/pom.xml +++ b/extension/upcaster/junit5/pom.xml @@ -7,7 +7,7 @@ io.holixon.axon.testing._ extension-upcaster - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing diff --git a/extension/upcaster/pom.xml b/extension/upcaster/pom.xml index 8496817..67375f7 100644 --- a/extension/upcaster/pom.xml +++ b/extension/upcaster/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ extension - 4.8.0.0-SNAPSHOT + 4.8.0.0 extension-upcaster diff --git a/lib/fixtures/bankaccount/pom.xml b/lib/fixtures/bankaccount/pom.xml index 6d5ebdb..72f15a7 100644 --- a/lib/fixtures/bankaccount/pom.xml +++ b/lib/fixtures/bankaccount/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing.lib diff --git a/lib/fixtures/giftcard/pom.xml b/lib/fixtures/giftcard/pom.xml index 263a3fc..a03adc0 100644 --- a/lib/fixtures/giftcard/pom.xml +++ b/lib/fixtures/giftcard/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ fixtures - 4.8.0.0-SNAPSHOT + 4.8.0.0 io.holixon.axon.testing.lib diff --git a/lib/fixtures/pom.xml b/lib/fixtures/pom.xml index df032de..b1eddc3 100644 --- a/lib/fixtures/pom.xml +++ b/lib/fixtures/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ lib - 4.8.0.0-SNAPSHOT + 4.8.0.0 fixtures diff --git a/lib/pom.xml b/lib/pom.xml index 669182c..cfe2036 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -6,7 +6,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.8.0.0-SNAPSHOT + 4.8.0.0 lib diff --git a/pom.xml b/pom.xml index 8c343cb..ad88fdf 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ io.holixon.axon.testing._ axon-testing_ - 4.8.0.0-SNAPSHOT + 4.8.0.0 pom