From 3b5a817adab777e7bddcffc70e09a8fa106c33c8 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 22 Nov 2022 17:25:31 +0100 Subject: [PATCH 1/6] Update for next development version --- bom/datapool-dependencies/pom.xml | 2 +- bom/parent/pom.xml | 2 +- bom/taskpool-dependencies/pom.xml | 2 +- core/bus-jackson/pom.xml | 2 +- core/datapool/datapool-api/pom.xml | 2 +- core/datapool/datapool-core/pom.xml | 2 +- core/datapool/datapool-event/pom.xml | 2 +- core/datapool/pom.xml | 2 +- core/taskpool/pom.xml | 2 +- core/taskpool/taskpool-api/pom.xml | 2 +- core/taskpool/taskpool-core/pom.xml | 2 +- core/taskpool/taskpool-event/pom.xml | 2 +- integration/camunda-bpm/engine-client/pom.xml | 2 +- integration/camunda-bpm/pom.xml | 2 +- integration/camunda-bpm/springboot-autoconfigure/pom.xml | 2 +- integration/camunda-bpm/springboot-starter/pom.xml | 2 +- integration/camunda-bpm/taskpool-collector/pom.xml | 2 +- integration/common/datapool-sender/pom.xml | 2 +- integration/common/pom.xml | 2 +- integration/common/tasklist-url-resolver/pom.xml | 2 +- integration/common/taskpool-sender/pom.xml | 2 +- integration/common/variable-serializer/pom.xml | 2 +- pom.xml | 2 +- view/form-url-resolver/pom.xml | 2 +- view/jpa/pom.xml | 2 +- view/mongo/pom.xml | 2 +- view/pom.xml | 2 +- view/simple/pom.xml | 2 +- view/view-api-client/pom.xml | 2 +- view/view-api/pom.xml | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/bom/datapool-dependencies/pom.xml b/bom/datapool-dependencies/pom.xml index 8be51fa95..4dd34792b 100644 --- a/bom/datapool-dependencies/pom.xml +++ b/bom/datapool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../parent/pom.xml diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 74c3c6063..704dfedbb 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-root - 3.4.1 + 3.4.2-SNAPSHOT ../../pom.xml diff --git a/bom/taskpool-dependencies/pom.xml b/bom/taskpool-dependencies/pom.xml index 7c4e22ba6..ff82a98ff 100644 --- a/bom/taskpool-dependencies/pom.xml +++ b/bom/taskpool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../parent/pom.xml diff --git a/core/bus-jackson/pom.xml b/core/bus-jackson/pom.xml index c8aad97a9..6737c1163 100755 --- a/core/bus-jackson/pom.xml +++ b/core/bus-jackson/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/datapool/datapool-api/pom.xml b/core/datapool/datapool-api/pom.xml index 7cc181c80..5a1bceb30 100755 --- a/core/datapool/datapool-api/pom.xml +++ b/core/datapool/datapool-api/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-datapool-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-datapool-api diff --git a/core/datapool/datapool-core/pom.xml b/core/datapool/datapool-core/pom.xml index 33e29f699..fea32f082 100755 --- a/core/datapool/datapool-core/pom.xml +++ b/core/datapool/datapool-core/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-datapool-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-datapool-core diff --git a/core/datapool/datapool-event/pom.xml b/core/datapool/datapool-event/pom.xml index aeb1bca7a..57b7978ea 100755 --- a/core/datapool/datapool-event/pom.xml +++ b/core/datapool/datapool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-datapool-event diff --git a/core/datapool/pom.xml b/core/datapool/pom.xml index b2dbfbdd1..2c9686066 100755 --- a/core/datapool/pom.xml +++ b/core/datapool/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/taskpool/pom.xml b/core/taskpool/pom.xml index baaa14251..4c72c2857 100755 --- a/core/taskpool/pom.xml +++ b/core/taskpool/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../../bom/parent/pom.xml diff --git a/core/taskpool/taskpool-api/pom.xml b/core/taskpool/taskpool-api/pom.xml index 15d58ce67..9b5ac652d 100755 --- a/core/taskpool/taskpool-api/pom.xml +++ b/core/taskpool/taskpool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-taskpool-api diff --git a/core/taskpool/taskpool-core/pom.xml b/core/taskpool/taskpool-core/pom.xml index 340bafb5f..7d03843c5 100755 --- a/core/taskpool/taskpool-core/pom.xml +++ b/core/taskpool/taskpool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-taskpool-core diff --git a/core/taskpool/taskpool-event/pom.xml b/core/taskpool/taskpool-event/pom.xml index d6b6f26a4..0b396a00e 100755 --- a/core/taskpool/taskpool-event/pom.xml +++ b/core/taskpool/taskpool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-taskpool-event diff --git a/integration/camunda-bpm/engine-client/pom.xml b/integration/camunda-bpm/engine-client/pom.xml index bef857e08..a64355663 100644 --- a/integration/camunda-bpm/engine-client/pom.xml +++ b/integration/camunda-bpm/engine-client/pom.xml @@ -4,7 +4,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-camunda-bpm-engine-client diff --git a/integration/camunda-bpm/pom.xml b/integration/camunda-bpm/pom.xml index 00367afe0..f8e913ea8 100644 --- a/integration/camunda-bpm/pom.xml +++ b/integration/camunda-bpm/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../../bom/parent/pom.xml diff --git a/integration/camunda-bpm/springboot-autoconfigure/pom.xml b/integration/camunda-bpm/springboot-autoconfigure/pom.xml index 3b7df0e7f..f850a5258 100755 --- a/integration/camunda-bpm/springboot-autoconfigure/pom.xml +++ b/integration/camunda-bpm/springboot-autoconfigure/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-camunda-bpm-springboot-autoconfigure diff --git a/integration/camunda-bpm/springboot-starter/pom.xml b/integration/camunda-bpm/springboot-starter/pom.xml index d31d59e31..a7d84f51a 100755 --- a/integration/camunda-bpm/springboot-starter/pom.xml +++ b/integration/camunda-bpm/springboot-starter/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-camunda-bpm-springboot-starter diff --git a/integration/camunda-bpm/taskpool-collector/pom.xml b/integration/camunda-bpm/taskpool-collector/pom.xml index d5b578030..25bca78b1 100755 --- a/integration/camunda-bpm/taskpool-collector/pom.xml +++ b/integration/camunda-bpm/taskpool-collector/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-camunda-bpm-taskpool-collector diff --git a/integration/common/datapool-sender/pom.xml b/integration/common/datapool-sender/pom.xml index 3ff2f90be..f4926883f 100755 --- a/integration/common/datapool-sender/pom.xml +++ b/integration/common/datapool-sender/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-datapool-sender diff --git a/integration/common/pom.xml b/integration/common/pom.xml index 58d07ab9e..190d1eddd 100755 --- a/integration/common/pom.xml +++ b/integration/common/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../../bom/parent/pom.xml diff --git a/integration/common/tasklist-url-resolver/pom.xml b/integration/common/tasklist-url-resolver/pom.xml index 53f7c54fb..37e31b66a 100644 --- a/integration/common/tasklist-url-resolver/pom.xml +++ b/integration/common/tasklist-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-tasklist-url-resolver diff --git a/integration/common/taskpool-sender/pom.xml b/integration/common/taskpool-sender/pom.xml index 19525b939..58d5b93da 100755 --- a/integration/common/taskpool-sender/pom.xml +++ b/integration/common/taskpool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-taskpool-sender diff --git a/integration/common/variable-serializer/pom.xml b/integration/common/variable-serializer/pom.xml index e192ffe6f..24aee67a8 100755 --- a/integration/common/variable-serializer/pom.xml +++ b/integration/common/variable-serializer/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-variable-serializer diff --git a/pom.xml b/pom.xml index 21bb698e4..525e99a08 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-root - 3.4.1 + 3.4.2-SNAPSHOT pom POM: ${project.artifactId} diff --git a/view/form-url-resolver/pom.xml b/view/form-url-resolver/pom.xml index 817e06e85..052e6b1a7 100644 --- a/view/form-url-resolver/pom.xml +++ b/view/form-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-form-url-resolver diff --git a/view/jpa/pom.xml b/view/jpa/pom.xml index df534e6db..303d7f458 100644 --- a/view/jpa/pom.xml +++ b/view/jpa/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-view-jpa diff --git a/view/mongo/pom.xml b/view/mongo/pom.xml index 8411ea709..c9ce42c35 100755 --- a/view/mongo/pom.xml +++ b/view/mongo/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-view-mongo diff --git a/view/pom.xml b/view/pom.xml index 736beb724..ca67b9660 100644 --- a/view/pom.xml +++ b/view/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.1 + 3.4.2-SNAPSHOT ../bom/parent/pom.xml diff --git a/view/simple/pom.xml b/view/simple/pom.xml index 755efedcc..4d714b2ba 100755 --- a/view/simple/pom.xml +++ b/view/simple/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-view-simple diff --git a/view/view-api-client/pom.xml b/view/view-api-client/pom.xml index e4d2c4525..7637b043b 100755 --- a/view/view-api-client/pom.xml +++ b/view/view-api-client/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-view-api-client diff --git a/view/view-api/pom.xml b/view/view-api/pom.xml index ae6847366..d4019b2b0 100755 --- a/view/view-api/pom.xml +++ b/view/view-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.1 + 3.4.2-SNAPSHOT polyflow-view-api From 297c709818931b580804b45d9aa8f1d34c638fd5 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Tue, 22 Nov 2022 22:54:54 +0100 Subject: [PATCH 2/6] implemented more tests --- bom/parent/pom.xml | 6 ++ core/bus-jackson/pom.xml | 23 ++++- core/datapool/datapool-api/pom.xml | 4 - .../taskpool/api/business/DataEntryChange.kt | 4 +- .../api/business/ProcessingTypeTest.kt | 17 ++++ core/datapool/datapool-core/pom.xml | 5 - .../taskpool/api/business/MappersTest.kt | 93 +++++++++++++++++++ core/taskpool/taskpool-api/pom.xml | 9 -- core/taskpool/taskpool-core/pom.xml | 5 - core/taskpool/taskpool-event/pom.xml | 5 - .../taskpool/upcast/AnnotatedEventUpcaster.kt | 26 ++++++ .../AnnotationBasedSingleEventUpcaster.kt | 74 +++++---------- .../upcast/RepresentationContentType.kt | 8 ++ .../ProcessDefinitionEventUpcasters.kt | 8 +- ...AttributeUpdatedEngineEvent4To5Upcaster.kt | 8 +- ...tEventUpcasterForPatchingSourceRefernce.kt | 4 +- .../springboot-autoconfigure/pom.xml | 44 ++++++++- ...TaskpoolEngineSupportConfigurationITest.kt | 42 +++++++++ .../src/test/resources/logback.xml | 11 +++ .../camunda-bpm/springboot-starter/pom.xml | 42 +++++++++ .../src/test/kotlin/TaskpoolStarterITest.kt | 35 +++++++ integration/common/datapool-sender/pom.xml | 5 - .../common/tasklist-url-resolver/pom.xml | 5 - view/form-url-resolver/pom.xml | 9 +- view/jpa/pom.xml | 1 - view/view-api-client/pom.xml | 17 +++- view/view-api/pom.xml | 7 +- 27 files changed, 398 insertions(+), 119 deletions(-) create mode 100644 core/datapool/datapool-api/src/test/kotlin/io/holunda/camunda/taskpool/api/business/ProcessingTypeTest.kt create mode 100644 core/datapool/datapool-event/src/test/kotlin/io/holunda/camunda/taskpool/api/business/MappersTest.kt create mode 100644 core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotatedEventUpcaster.kt create mode 100644 core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/RepresentationContentType.kt create mode 100644 integration/camunda-bpm/springboot-autoconfigure/src/test/kotlin/io/holunda/polyflow/taskpool/TaskpoolEngineSupportConfigurationITest.kt create mode 100644 integration/camunda-bpm/springboot-autoconfigure/src/test/resources/logback.xml create mode 100644 integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index 704dfedbb..ac19f12df 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -268,6 +268,11 @@ junit-jupiter test + + org.assertj + assertj-core + test + @@ -532,6 +537,7 @@ false random + true ${pattern.class.itest} ${pattern.package.itest} diff --git a/core/bus-jackson/pom.xml b/core/bus-jackson/pom.xml index 6737c1163..e20436c6f 100755 --- a/core/bus-jackson/pom.xml +++ b/core/bus-jackson/pom.xml @@ -14,6 +14,7 @@ core/bus/${project.artifactId} + io.holunda.polyflow polyflow-datapool-api @@ -29,6 +30,8 @@ polyflow-view-api ${project.version} + + com.fasterxml.jackson.core jackson-databind @@ -44,11 +47,25 @@ jackson-module-kotlin provided + + - org.assertj - assertj-core - test + org.springframework + spring-beans + provided + + org.springframework + spring-context + provided + + + org.springframework.boot + spring-boot-autoconfigure + provided + + + com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/core/datapool/datapool-api/pom.xml b/core/datapool/datapool-api/pom.xml index 5a1bceb30..0430f83a2 100755 --- a/core/datapool/datapool-api/pom.xml +++ b/core/datapool/datapool-api/pom.xml @@ -16,10 +16,6 @@ org.axonframework axon-modelling - - org.springframework.boot - spring-boot-starter - org.camunda.commons camunda-commons-typed-values diff --git a/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryChange.kt b/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryChange.kt index 101436dfc..6b53d6d2a 100644 --- a/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryChange.kt +++ b/core/datapool/datapool-api/src/main/kotlin/io/holunda/camunda/taskpool/api/business/DataEntryChange.kt @@ -16,7 +16,7 @@ data class DataEntryChange( */ val entryId: EntryId, /** - * Human readable type e.g. "purchase order" + * Human-readable type e.g. "purchase order" */ val type: String, /** @@ -24,7 +24,7 @@ data class DataEntryChange( */ val applicationName: String, /** - * Human readable identifier or name, e.g. "BANF-4711 - TV for meeting room" + * Human-readable identifier or name, e.g. "BANF-4711 - TV for meeting room" */ val name: String, /** diff --git a/core/datapool/datapool-api/src/test/kotlin/io/holunda/camunda/taskpool/api/business/ProcessingTypeTest.kt b/core/datapool/datapool-api/src/test/kotlin/io/holunda/camunda/taskpool/api/business/ProcessingTypeTest.kt new file mode 100644 index 000000000..1362a467d --- /dev/null +++ b/core/datapool/datapool-api/src/test/kotlin/io/holunda/camunda/taskpool/api/business/ProcessingTypeTest.kt @@ -0,0 +1,17 @@ +package io.holunda.camunda.taskpool.api.business + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProcessingTypeTest { + + @Test + fun `creates processing type`() { + assertThat(ProcessingType.PRELIMINARY.of("draft")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.PRELIMINARY, state = "draft")) + assertThat(ProcessingType.IN_PROGRESS.of("doing")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.IN_PROGRESS, state = "doing")) + assertThat(ProcessingType.COMPLETED.of("done")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.COMPLETED, state = "done")) + assertThat(ProcessingType.DELETED.of("thrashed")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.DELETED, state = "thrashed")) + assertThat(ProcessingType.CANCELLED.of("rejected")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.CANCELLED, state = "rejected")) + assertThat(ProcessingType.UNDEFINED.of("custom")).isEqualTo(DataEntryStateImpl(processingType = ProcessingType.UNDEFINED, state = "custom")) + } +} \ No newline at end of file diff --git a/core/datapool/datapool-core/pom.xml b/core/datapool/datapool-core/pom.xml index fea32f082..b76b8ae42 100755 --- a/core/datapool/datapool-core/pom.xml +++ b/core/datapool/datapool-core/pom.xml @@ -55,11 +55,6 @@ axon-test test - - org.assertj - assertj-core - test - org.mockito mockito-core diff --git a/core/datapool/datapool-event/src/test/kotlin/io/holunda/camunda/taskpool/api/business/MappersTest.kt b/core/datapool/datapool-event/src/test/kotlin/io/holunda/camunda/taskpool/api/business/MappersTest.kt new file mode 100644 index 000000000..390b78af2 --- /dev/null +++ b/core/datapool/datapool-event/src/test/kotlin/io/holunda/camunda/taskpool/api/business/MappersTest.kt @@ -0,0 +1,93 @@ +package io.holunda.camunda.taskpool.api.business + +import org.assertj.core.api.Assertions.assertThat +import org.camunda.bpm.engine.variable.Variables.createVariables +import org.junit.jupiter.api.Test + + +internal class MappersTest { + + + @Test + fun `maps create command to event `() { + val command = CreateDataEntryCommand( + dataEntryChange = DataEntryChange( + entryType = "TestType", + entryId = "4711", + type = "Test Type", + applicationName = "business-app", + name = "Test Item", + correlations = newCorrelations().putValue("PurchaseOrder", "4712"), + payload = createVariables().putValue("Key", "Value"), + description = "Test Type described carefully", + state = ProcessingType.IN_PROGRESS.of("doing"), + modification = Modification.now().copy(username = "user", log = "log", logNotes = "logNotes"), + authorizationChanges = listOf(AuthorizationChange.addUser("user")), + formKey = "form" + ) + ) + + val event = command.createdEvent() + assertThat(event.entryId).isEqualTo(command.dataEntryChange.entryId) + assertThat(event.entryType).isEqualTo(command.dataEntryChange.entryType) + assertThat(event.type).isEqualTo(command.dataEntryChange.type) + assertThat(event.applicationName).isEqualTo(command.dataEntryChange.applicationName) + assertThat(event.name).isEqualTo(command.dataEntryChange.name) + assertThat(event.correlations).isEqualTo(command.dataEntryChange.correlations) + assertThat(event.payload).isEqualTo(command.dataEntryChange.payload) + assertThat(event.state).isEqualTo(command.dataEntryChange.state) + assertThat(event.createModification).isEqualTo(command.dataEntryChange.modification) + assertThat(event.authorizations).isEqualTo(command.dataEntryChange.authorizationChanges) + assertThat(event.formKey).isEqualTo(command.dataEntryChange.formKey) + } + + @Test + fun `maps update command to event `() { + val command = UpdateDataEntryCommand( + dataEntryChange = DataEntryChange( + entryType = "TestType", + entryId = "4711", + type = "Test Type", + applicationName = "business-app", + name = "Test Item", + correlations = newCorrelations().putValue("PurchaseOrder", "4712"), + payload = createVariables().putValue("Key", "Value"), + description = "Test Type described carefully", + state = ProcessingType.IN_PROGRESS.of("doing"), + modification = Modification.now().copy(username = "user", log = "log", logNotes = "logNotes"), + authorizationChanges = listOf(AuthorizationChange.addUser("user")), + formKey = "form" + ) + ) + + val event = command.updatedEvent() + assertThat(event.entryId).isEqualTo(command.dataEntryChange.entryId) + assertThat(event.entryType).isEqualTo(command.dataEntryChange.entryType) + assertThat(event.type).isEqualTo(command.dataEntryChange.type) + assertThat(event.applicationName).isEqualTo(command.dataEntryChange.applicationName) + assertThat(event.name).isEqualTo(command.dataEntryChange.name) + assertThat(event.correlations).isEqualTo(command.dataEntryChange.correlations) + assertThat(event.payload).isEqualTo(command.dataEntryChange.payload) + assertThat(event.state).isEqualTo(command.dataEntryChange.state) + assertThat(event.updateModification).isEqualTo(command.dataEntryChange.modification) + assertThat(event.authorizations).isEqualTo(command.dataEntryChange.authorizationChanges) + assertThat(event.formKey).isEqualTo(command.dataEntryChange.formKey) + } + + @Test + fun `maps delete command to event `() { + val command = DeleteDataEntryCommand( + entryType = "TestType", + entryId = "4711", + modification = Modification.now().copy(username = "user", log = "log", logNotes = "logNotes"), + state = ProcessingType.IN_PROGRESS.of("doing") + ) + val event = command.deletedEvent() + assertThat(event.entryId).isEqualTo(command.entryId) + assertThat(event.entryType).isEqualTo(command.entryType) + assertThat(event.state).isEqualTo(command.state) + assertThat(event.deleteModification).isEqualTo(command.modification) + + } + +} \ No newline at end of file diff --git a/core/taskpool/taskpool-api/pom.xml b/core/taskpool/taskpool-api/pom.xml index 9b5ac652d..6c706138f 100755 --- a/core/taskpool/taskpool-api/pom.xml +++ b/core/taskpool/taskpool-api/pom.xml @@ -21,18 +21,9 @@ org.axonframework axon-messaging - - org.springframework.boot - spring-boot-starter - org.camunda.commons camunda-commons-typed-values - - org.assertj - assertj-core - test - diff --git a/core/taskpool/taskpool-core/pom.xml b/core/taskpool/taskpool-core/pom.xml index 7d03843c5..e5f1299f9 100755 --- a/core/taskpool/taskpool-core/pom.xml +++ b/core/taskpool/taskpool-core/pom.xml @@ -50,11 +50,6 @@ mockito-core test - - org.assertj - assertj-core - test - org.springframework.boot spring-boot-starter-test diff --git a/core/taskpool/taskpool-event/pom.xml b/core/taskpool/taskpool-event/pom.xml index 0b396a00e..3d04f98b1 100755 --- a/core/taskpool/taskpool-event/pom.xml +++ b/core/taskpool/taskpool-event/pom.xml @@ -35,11 +35,6 @@ jaxen jaxen - - org.assertj - assertj-core - test - com.fasterxml.jackson.core jackson-core diff --git a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotatedEventUpcaster.kt b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotatedEventUpcaster.kt new file mode 100644 index 000000000..e9a368818 --- /dev/null +++ b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotatedEventUpcaster.kt @@ -0,0 +1,26 @@ +package io.holunda.camunda.taskpool.upcast + +/** + * Marks a single event upcaster. + */ +@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE) +@MustBeDocumented +annotation class AnnotatedEventUpcaster( + /** + * Target class type name. + */ + val targetClassTypeName: String, + /** + * Target revision, defaults to reserved value [NULL_VALUE] to indicate null. + */ + val revision: String = NULL_VALUE, + + /** + * Representation content type. + */ + val representationContentType: RepresentationContentType = RepresentationContentType.XML +) { + companion object { + const val NULL_VALUE = "SINGLE_EVENT_UPCASTER_NULL_VALUE" + } +} \ No newline at end of file diff --git a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotationBasedSingleEventUpcaster.kt b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotationBasedSingleEventUpcaster.kt index 871b6a9b3..665f931dd 100644 --- a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotationBasedSingleEventUpcaster.kt +++ b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/AnnotationBasedSingleEventUpcaster.kt @@ -1,11 +1,10 @@ -package io.holunda.camunda.taskpool.upcast.definition +package io.holunda.camunda.taskpool.upcast -import io.holunda.camunda.taskpool.upcast.definition.AnnotatedEventUpcaster.Companion.NULL_VALUE +import io.holunda.camunda.taskpool.upcast.AnnotatedEventUpcaster.Companion.NULL_VALUE import org.axonframework.serialization.SimpleSerializedType import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation import org.axonframework.serialization.upcasting.event.SingleEventUpcaster import org.dom4j.Document -import org.springframework.stereotype.Component import kotlin.reflect.full.findAnnotation /** @@ -30,62 +29,33 @@ abstract class AnnotationBasedSingleEventUpcaster : SingleEventUpcaster() { private fun annotation() = this::class.findAnnotation() ?: throw IllegalStateException("Sub-classes of ${AnnotationBasedSingleEventUpcaster::class.simpleName} must be annotated with ${AnnotatedEventUpcaster::class.simpleName}") -} - -/** - * Marks a single event upcaster. - */ -@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE) -@MustBeDocumented -@Component -annotation class AnnotatedEventUpcaster( - /** - * Target class type name. - */ - val targetClassTypeName: String, - /** - * Target revision, defaults to reserved value [NULL_VALUE] to indicate null. - */ - val revision: String = NULL_VALUE, /** - * Representation content type. + * Determines the content type based on the class of content type. */ - val representationContentType: RepresentationContentType = RepresentationContentType.XML -) { - companion object { - const val NULL_VALUE = "SINGLE_EVENT_UPCASTER_NULL_VALUE" - } -} - -/** - * Determines the content type based on the class of content type. - */ -fun IntermediateEventRepresentation.contentType(): RepresentationContentType { - when (this.data.data) { - is Document -> { - return RepresentationContentType.XML - } - is String -> { - return RepresentationContentType.JSON - } - is ByteArray -> { - // TODO: this seems expensive, maybe a check for the first byte is faster? - // what about encoding? - val asString = String(this.data.data as ByteArray) - if (asString.startsWith("<")) { + private fun IntermediateEventRepresentation.contentType(): RepresentationContentType { + when (this.data.data) { + is Document -> { return RepresentationContentType.XML - } else if (asString.startsWith("{")) { + } + + is String -> { return RepresentationContentType.JSON } + + is ByteArray -> { + // TODO: this seems expensive, maybe a check for the first byte is faster? + // what about encoding? + val asString = String(this.data.data as ByteArray) + if (asString.startsWith("<")) { + return RepresentationContentType.XML + } else if (asString.startsWith("{")) { + return RepresentationContentType.JSON + } + } } + throw IllegalStateException("Unknown content type of ${this.data.data}") } - throw IllegalStateException("Unknown content type of ${this.data.data}") } -/** - * Supported content typess for this upcaster. - */ -enum class RepresentationContentType { - JSON, XML -} + diff --git a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/RepresentationContentType.kt b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/RepresentationContentType.kt new file mode 100644 index 000000000..ebc85adec --- /dev/null +++ b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/RepresentationContentType.kt @@ -0,0 +1,8 @@ +package io.holunda.camunda.taskpool.upcast + +/** + * Supported content types for this upcaster. + */ +enum class RepresentationContentType { + JSON, XML +} \ No newline at end of file diff --git a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/definition/ProcessDefinitionEventUpcasters.kt b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/definition/ProcessDefinitionEventUpcasters.kt index 1564b918b..e70d6aed8 100644 --- a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/definition/ProcessDefinitionEventUpcasters.kt +++ b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/definition/ProcessDefinitionEventUpcasters.kt @@ -1,6 +1,9 @@ package io.holunda.camunda.taskpool.upcast.definition -import io.holunda.camunda.taskpool.upcast.definition.RepresentationContentType.JSON +import io.holunda.camunda.taskpool.upcast.AnnotatedEventUpcaster +import io.holunda.camunda.taskpool.upcast.AnnotationBasedSingleEventUpcaster +import io.holunda.camunda.taskpool.upcast.RepresentationContentType +import io.holunda.camunda.taskpool.upcast.RepresentationContentType.JSON import mu.KLogging import org.axonframework.serialization.SimpleSerializedType import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation @@ -24,7 +27,8 @@ class ProcessDefinitionEventXMLNullTo1Upcaster : AnnotationBasedSingleEventUpcas override fun doUpcast(representation: IntermediateEventRepresentation): IntermediateEventRepresentation { return representation.upcastPayload( SimpleSerializedType(RESULT_OBJECT_TYPE, "1"), - Document::class.java) + Document::class.java + ) // XStream writes the event types into the event. { document -> document.apply { diff --git a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskAttributeUpdatedEngineEvent4To5Upcaster.kt b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskAttributeUpdatedEngineEvent4To5Upcaster.kt index e592e3910..7c32ccdc1 100644 --- a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskAttributeUpdatedEngineEvent4To5Upcaster.kt +++ b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskAttributeUpdatedEngineEvent4To5Upcaster.kt @@ -1,7 +1,7 @@ package io.holunda.camunda.taskpool.upcast.task -import io.holunda.camunda.taskpool.upcast.definition.AnnotatedEventUpcaster -import io.holunda.camunda.taskpool.upcast.definition.AnnotationBasedSingleEventUpcaster +import io.holunda.camunda.taskpool.upcast.AnnotatedEventUpcaster +import io.holunda.camunda.taskpool.upcast.AnnotationBasedSingleEventUpcaster import mu.KLogging import org.axonframework.serialization.SimpleSerializedType import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation @@ -24,7 +24,8 @@ class TaskAttributeUpdatedEngineEvent4To5Upcaster : AnnotationBasedSingleEventUp override fun doUpcast(representation: IntermediateEventRepresentation): IntermediateEventRepresentation { return representation.upcastPayload( SimpleSerializedType(RESULT_OBJECT_TYPE, "5"), - Document::class.java) { document -> + Document::class.java + ) { document -> document.apply { if (document.selectNodes("//correlations").isEmpty()) { document.rootElement.addElement("correlations").apply { @@ -41,5 +42,4 @@ class TaskAttributeUpdatedEngineEvent4To5Upcaster : AnnotationBasedSingleEventUp } } } - } diff --git a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskEventEventUpcasterForPatchingSourceRefernce.kt b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskEventEventUpcasterForPatchingSourceRefernce.kt index 18959cffe..786c09617 100644 --- a/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskEventEventUpcasterForPatchingSourceRefernce.kt +++ b/core/taskpool/taskpool-event/src/main/kotlin/io/holunda/camunda/taskpool/upcast/task/TaskEventEventUpcasterForPatchingSourceRefernce.kt @@ -1,7 +1,7 @@ package io.holunda.camunda.taskpool.upcast.task -import io.holunda.camunda.taskpool.upcast.definition.AnnotatedEventUpcaster -import io.holunda.camunda.taskpool.upcast.definition.AnnotationBasedSingleEventUpcaster +import io.holunda.camunda.taskpool.upcast.AnnotatedEventUpcaster +import io.holunda.camunda.taskpool.upcast.AnnotationBasedSingleEventUpcaster import mu.KLogging import org.axonframework.serialization.SimpleSerializedType import org.axonframework.serialization.upcasting.event.IntermediateEventRepresentation diff --git a/integration/camunda-bpm/springboot-autoconfigure/pom.xml b/integration/camunda-bpm/springboot-autoconfigure/pom.xml index f850a5258..da992288c 100755 --- a/integration/camunda-bpm/springboot-autoconfigure/pom.xml +++ b/integration/camunda-bpm/springboot-autoconfigure/pom.xml @@ -21,11 +21,53 @@ io.holunda.polyflow polyflow-datapool-sender - org.springframework.boot spring-boot-starter + + + org.camunda.bpm.springboot + camunda-bpm-spring-boot-starter + test + + + org.springframework.boot + spring-boot-test + test + + + org.springframework + spring-test + test + + + org.mockito + mockito-core + test + + + org.mockito.kotlin + mockito-kotlin + test + + + com.h2database + h2 + test + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + + diff --git a/integration/camunda-bpm/springboot-autoconfigure/src/test/kotlin/io/holunda/polyflow/taskpool/TaskpoolEngineSupportConfigurationITest.kt b/integration/camunda-bpm/springboot-autoconfigure/src/test/kotlin/io/holunda/polyflow/taskpool/TaskpoolEngineSupportConfigurationITest.kt new file mode 100644 index 000000000..96c9ea37d --- /dev/null +++ b/integration/camunda-bpm/springboot-autoconfigure/src/test/kotlin/io/holunda/polyflow/taskpool/TaskpoolEngineSupportConfigurationITest.kt @@ -0,0 +1,42 @@ +package io.holunda.polyflow.taskpool + +import io.holunda.polyflow.datapool.sender.DataEntryCommandSender +import io.holunda.polyflow.taskpool.sender.task.EngineTaskCommandSender +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.commandhandling.gateway.DefaultCommandGateway +import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication +import org.junit.jupiter.api.Test +import org.mockito.kotlin.mock +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.ImportAutoConfiguration +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.context.annotation.Bean + +@SpringBootTest +internal class TaskpoolEngineSupportConfigurationITest { + + @Test + fun `starts taskpool engine support`( + @Autowired dataEntrySender: DataEntryCommandSender, + @Autowired engineTaskCommandSender: EngineTaskCommandSender + ) { + assertThat(dataEntrySender).isNotNull + assertThat(engineTaskCommandSender).isNotNull + } + + + @SpringBootApplication + @EnableTaskpoolEngineSupport + @EnableProcessApplication + @ImportAutoConfiguration( + io.holunda.polyflow.taskpool.collector.CamundaTaskpoolCollectorConfiguration::class, + io.holunda.polyflow.taskpool.sender.SenderConfiguration::class, + io.holunda.polyflow.datapool.DataEntrySenderConfiguration::class + ) + class TestApplication { + + @Bean + fun commandGateway() = DefaultCommandGateway.builder().commandBus(mock()).build() + } +} diff --git a/integration/camunda-bpm/springboot-autoconfigure/src/test/resources/logback.xml b/integration/camunda-bpm/springboot-autoconfigure/src/test/resources/logback.xml new file mode 100644 index 000000000..b35926b40 --- /dev/null +++ b/integration/camunda-bpm/springboot-autoconfigure/src/test/resources/logback.xml @@ -0,0 +1,11 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + diff --git a/integration/camunda-bpm/springboot-starter/pom.xml b/integration/camunda-bpm/springboot-starter/pom.xml index a7d84f51a..26b1df76c 100755 --- a/integration/camunda-bpm/springboot-starter/pom.xml +++ b/integration/camunda-bpm/springboot-starter/pom.xml @@ -17,6 +17,48 @@ io.holunda.polyflow polyflow-camunda-bpm-springboot-autoconfigure + + + org.camunda.bpm.springboot + camunda-bpm-spring-boot-starter + test + + + org.springframework.boot + spring-boot-test + test + + + org.springframework + spring-test + test + + + org.mockito + mockito-core + test + + + org.mockito.kotlin + mockito-kotlin + test + + + com.h2database + h2 + test + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + diff --git a/integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt b/integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt new file mode 100644 index 000000000..f3e8c20b6 --- /dev/null +++ b/integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt @@ -0,0 +1,35 @@ +import io.holunda.polyflow.datapool.sender.DataEntryCommandSender +import io.holunda.polyflow.taskpool.EnableTaskpoolEngineSupport +import io.holunda.polyflow.taskpool.sender.task.EngineTaskCommandSender +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.commandhandling.gateway.DefaultCommandGateway +import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication +import org.junit.jupiter.api.Test +import org.mockito.kotlin.mock +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.context.annotation.Bean + +@SpringBootTest +internal class TaskpoolStarterITest { + + @Test + fun `starts taskpool engine support`( + @Autowired dataEntrySender: DataEntryCommandSender, + @Autowired engineTaskCommandSender: EngineTaskCommandSender + ) { + assertThat(dataEntrySender).isNotNull + assertThat(engineTaskCommandSender).isNotNull + } + + + @SpringBootApplication + @EnableTaskpoolEngineSupport + @EnableProcessApplication + class TestApplication { + + @Bean + fun commandGateway() = DefaultCommandGateway.builder().commandBus(mock()).build() + } +} diff --git a/integration/common/datapool-sender/pom.xml b/integration/common/datapool-sender/pom.xml index f4926883f..c2beaac2a 100755 --- a/integration/common/datapool-sender/pom.xml +++ b/integration/common/datapool-sender/pom.xml @@ -62,11 +62,6 @@ mockito-kotlin test - - org.assertj - assertj-core - test - org.springframework.boot spring-boot-test diff --git a/integration/common/tasklist-url-resolver/pom.xml b/integration/common/tasklist-url-resolver/pom.xml index 37e31b66a..73aed263c 100644 --- a/integration/common/tasklist-url-resolver/pom.xml +++ b/integration/common/tasklist-url-resolver/pom.xml @@ -26,11 +26,6 @@ spring-boot-test test - - org.assertj - assertj-core - test - org.springframework spring-test diff --git a/view/form-url-resolver/pom.xml b/view/form-url-resolver/pom.xml index 052e6b1a7..81bb6828a 100644 --- a/view/form-url-resolver/pom.xml +++ b/view/form-url-resolver/pom.xml @@ -28,6 +28,10 @@ commons-text 1.10.0 + + org.springframework.boot + spring-boot-autoconfigure + org.springframework spring-context @@ -40,10 +44,5 @@ com.fasterxml.jackson.module jackson-module-kotlin - - org.assertj - assertj-core - - diff --git a/view/jpa/pom.xml b/view/jpa/pom.xml index 303d7f458..2b38ae4f6 100644 --- a/view/jpa/pom.xml +++ b/view/jpa/pom.xml @@ -51,7 +51,6 @@ com.h2database h2 - 1.4.200 test diff --git a/view/view-api-client/pom.xml b/view/view-api-client/pom.xml index 7637b043b..fefc01071 100755 --- a/view/view-api-client/pom.xml +++ b/view/view-api-client/pom.xml @@ -17,10 +17,17 @@ io.holunda.polyflow polyflow-view-api - - org.assertj - assertj-core - test - + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + diff --git a/view/view-api/pom.xml b/view/view-api/pom.xml index d4019b2b0..edd520459 100755 --- a/view/view-api/pom.xml +++ b/view/view-api/pom.xml @@ -21,15 +21,14 @@ io.holunda.polyflow polyflow-datapool-event - io.holixon.axon.gateway axon-gateway-extension - org.assertj - assertj-core - test + org.springframework + spring-core + provided From a96abc5e9a54d3eb651e9209322d462769702f29 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 23 Nov 2022 12:51:30 +0100 Subject: [PATCH 3/6] bugfix: flip the value in deletion strategy configuration, wrote tests for configuration --- .../core/DataPoolCoreConfiguration.kt | 2 +- .../datapool/core/DataPoolProperties.kt | 7 +- .../datapool/core/DeletionStrategyValue.kt | 16 ++++ ...olCoreDeletionStrategyConfigurationTest.kt | 78 +++++++++++++++++++ 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DeletionStrategyValue.kt create mode 100644 core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt index 24dbeb1d2..c0e975824 100755 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt @@ -97,7 +97,7 @@ class DataPoolCoreConfiguration { ) @Bean fun strictDeletionStrategy(): DeletionStrategy = object : DeletionStrategy { - override fun strictMode(): Boolean = false + override fun strictMode(): Boolean = true } } diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolProperties.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolProperties.kt index 129ef643a..346f68de3 100644 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolProperties.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolProperties.kt @@ -20,5 +20,10 @@ data class DataPoolProperties( * Defaults to [org.axonframework.eventsourcing.EventSourcingRepository]. * Consider to use [io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository] if you want to load the aggregate with first event only. */ - val eventSourcingRepositoryType: String = EventSourcingRepository::class.java.canonicalName + val eventSourcingRepositoryType: String = EventSourcingRepository::class.java.canonicalName, + + /** + * Specifies the deletion strategy for data entries. + */ + val deletionStrategy: DeletionStrategyValue? = DeletionStrategyValue.lax ) \ No newline at end of file diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DeletionStrategyValue.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DeletionStrategyValue.kt new file mode 100644 index 000000000..925a34249 --- /dev/null +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DeletionStrategyValue.kt @@ -0,0 +1,16 @@ +package io.holunda.polyflow.datapool.core + +/** + * Different deletion strategies. + */ +enum class DeletionStrategyValue { + /** + * Allow updates after deletes. + */ + strict, + + /** + * Enforces errors on any operation after deletion. + */ + lax +} diff --git a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt new file mode 100644 index 000000000..8a3c77011 --- /dev/null +++ b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt @@ -0,0 +1,78 @@ +package io.holunda.polyflow.datapool.core + +import org.assertj.core.api.Assertions.assertThat +import org.axonframework.eventsourcing.Snapshotter +import org.axonframework.eventsourcing.eventstore.EventStore +import org.junit.jupiter.api.Test +import org.mockito.kotlin.mock +import org.springframework.boot.context.annotation.UserConfigurations +import org.springframework.boot.test.context.runner.ApplicationContextRunner +import org.springframework.context.annotation.Bean + +internal class DataPoolCoreDeletionStrategyConfigurationTest { + + private val contextRunner = ApplicationContextRunner() + .withConfiguration(UserConfigurations.of(DataPoolCoreConfiguration::class.java)) + + @Test + fun `should do lax by default`() { + contextRunner + .withUserConfiguration(TestMockConfiguration::class.java) + .withPropertyValues("" + ).run { + assertThat(it.getBean(DataPoolProperties::class.java)).isNotNull + assertThat(it.getBean(DeletionStrategy::class.java)).isNotNull + + val properties = it.getBean(DataPoolProperties::class.java) + assertThat(properties.deletionStrategy).isEqualTo(DeletionStrategyValue.lax) + + val deletionStrategy = it.getBean(DeletionStrategy::class.java) + assertThat(deletionStrategy.strictMode()).isFalse() + } + } + + @Test + fun `should do strict if changed`() { + contextRunner + .withUserConfiguration(TestMockConfiguration::class.java) + .withPropertyValues( + "polyflow.core.data-entry.deletion-strategy=strict" + ).run { + assertThat(it.getBean(DataPoolProperties::class.java)).isNotNull + assertThat(it.getBean(DeletionStrategy::class.java)).isNotNull + + val properties = it.getBean(DataPoolProperties::class.java) + assertThat(properties.deletionStrategy).isEqualTo(DeletionStrategyValue.strict) + + val deletionStrategy: DeletionStrategy = it.getBean(DeletionStrategy::class.java) + assertThat(deletionStrategy.strictMode()).isTrue() + } + } + + @Test + fun `should do lax if changed`() { + contextRunner + .withUserConfiguration(TestMockConfiguration::class.java) + .withPropertyValues( + "polyflow.core.data-entry.deletion-strategy=lax" + ).run { + assertThat(it.getBean(DataPoolProperties::class.java)).isNotNull + assertThat(it.getBean(DeletionStrategy::class.java)).isNotNull + + val properties = it.getBean(DataPoolProperties::class.java) + assertThat(properties.deletionStrategy).isEqualTo(DeletionStrategyValue.lax) + + val deletionStrategy: DeletionStrategy = it.getBean(DeletionStrategy::class.java) + assertThat(deletionStrategy.strictMode()).isFalse() + } + } + + class TestMockConfiguration { + + @Bean + fun eventStore(): EventStore = mock() + + @Bean + fun snapshotter(): Snapshotter = mock() + } +} \ No newline at end of file From a747035752f25a9f48b814efb8b77be92c9e37e0 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 23 Nov 2022 13:50:59 +0100 Subject: [PATCH 4/6] fixed tests, split configuration into property and axon specific, re-enabled h2 to support JPA tests --- .../core/DataPoolCoreAxonConfiguration.kt | 83 +++++++++++++++++++ .../core/DataPoolCoreConfiguration.kt | 64 ++------------ ...eDataPool.kt => EnablePolyflowDataPool.kt} | 5 +- .../core/business/DataEntryAggregate.kt | 7 +- ...olCoreDeletionStrategyConfigurationTest.kt | 16 +++- ...stEventOnlyEventSourcingRepositoryITest.kt | 2 +- .../{ => core/itest}/TestApplication.kt | 2 +- .../src/test/kotlin/TaskpoolStarterITest.kt | 2 + view/jpa/pom.xml | 1 + 9 files changed, 117 insertions(+), 65 deletions(-) create mode 100755 core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt rename core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/{EnableDataPool.kt => EnablePolyflowDataPool.kt} (69%) rename core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/{ => core/itest}/TestApplication.kt (93%) diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt new file mode 100755 index 000000000..214b60604 --- /dev/null +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt @@ -0,0 +1,83 @@ +package io.holunda.polyflow.datapool.core + +import io.holunda.polyflow.datapool.core.business.CreateOrUpdateCommandHandler +import io.holunda.polyflow.datapool.core.business.DataEntryAggregate +import io.holunda.polyflow.datapool.core.business.upcaster.DataEntryCreatedEventUpcaster +import io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository +import mu.KLogging +import org.axonframework.common.caching.Cache +import org.axonframework.common.caching.WeakReferenceCache +import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition +import org.axonframework.eventsourcing.EventSourcingRepository +import org.axonframework.eventsourcing.SnapshotTriggerDefinition +import org.axonframework.eventsourcing.Snapshotter +import org.axonframework.eventsourcing.eventstore.EventStore +import org.springframework.boot.autoconfigure.AutoConfigureAfter +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.DependsOn +import org.springframework.context.annotation.Import + + +/** + * Configuration of polyflow data pool core axon setup. + */ +@Configuration +@Import( + DataEntryAggregate::class, + CreateOrUpdateCommandHandler::class, + DataEntryCreatedEventUpcaster::class +) +class DataPoolCoreAxonConfiguration { + + companion object : KLogging() { + const val DATA_ENTRY_REPOSITORY = "dataEntryEventSourcingRepository" + const val DATA_ENTRY_SNAPSHOTTER = "dataEntrySnapshotter" + const val DATA_ENTRY_CACHE = "dataEntryCache" + } + + /** + * Provides an event sourcing repository for data entry aggregates that creates the aggregate and uses the first event in the stream only. + * This repository avoids loading of all events and will avoid usage of snapshots. + */ + @ConditionalOnProperty( + name = ["polyflow.core.data-entry.event-sourcing-repository-type"], + havingValue = "io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository" + ) + @Bean(DATA_ENTRY_REPOSITORY) + fun firstEventDataEntryAggregateRepository(eventStore: EventStore): EventSourcingRepository { + return FirstEventOnlyEventSourcingRepository.builder(DataEntryAggregate::class.java).eventStore(eventStore).build() + } + + /** + * Provides a standard event sourcing repository for data entry aggregate. + */ + @ConditionalOnProperty( + name = ["polyflow.core.data-entry.event-sourcing-repository-type"], + havingValue = "org.axonframework.eventsourcing.EventSourcingRepository", + matchIfMissing = true + ) + @Bean(DATA_ENTRY_REPOSITORY) + fun dataEntryAggregateRepository(eventStore: EventStore): EventSourcingRepository { + return EventSourcingRepository.builder(DataEntryAggregate::class.java).eventStore(eventStore).build() + } + + /** + * Register snapshotter. It will trigger if the aggregate is loaded by the series of events and the series is exceeding the snapshot. + * This is the case by the standard [EventSourcingRepository] is used, but will never happen if the [FirstEventOnlyEventSourcingRepository] is used. + */ + @Bean(DATA_ENTRY_SNAPSHOTTER) + fun dataEntryAggregateSnapshotterTriggerDefinition(snapshotter: Snapshotter, dataPoolProperties: DataPoolProperties): SnapshotTriggerDefinition { + return EventCountSnapshotTriggerDefinition(snapshotter, dataPoolProperties.snapshotThreshold) + } + + /** + * Use weak reference cache. + */ + @Bean(DATA_ENTRY_CACHE) + fun dataEntryCache(): Cache = WeakReferenceCache() +} + diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt index c0e975824..db11e6fe7 100755 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreConfiguration.kt @@ -1,79 +1,23 @@ package io.holunda.polyflow.datapool.core -import io.holunda.polyflow.datapool.core.business.DataEntryAggregate -import io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository import mu.KLogging -import org.axonframework.common.caching.Cache -import org.axonframework.common.caching.WeakReferenceCache -import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition -import org.axonframework.eventsourcing.EventSourcingRepository -import org.axonframework.eventsourcing.SnapshotTriggerDefinition -import org.axonframework.eventsourcing.Snapshotter -import org.axonframework.eventsourcing.eventstore.EventStore import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Import /** * Configuration of polyflow data pool core. */ @Configuration -@ComponentScan @EnableConfigurationProperties( DataPoolProperties::class ) class DataPoolCoreConfiguration { - companion object : KLogging() { - const val DATA_ENTRY_REPOSITORY = "dataEntryEventSourcingRepository" - const val DATA_ENTRY_SNAPSHOTTER = "dataEntrySnapshotter" - const val DATA_ENTRY_CACHE = "dataEntryCache" - } - - /** - * Provides an event sourcing repository for data entry aggregates that creates the aggregate and uses the first event in the stream only. - * This repository avoids loading of all events and will avoid usage of snapshots. - */ - @ConditionalOnProperty( - name = ["polyflow.core.data-entry.event-sourcing-repository-type"], - havingValue = "io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository" - ) - @Bean(DATA_ENTRY_REPOSITORY) - fun firstEventDataEntryAggregateRepository(eventStore: EventStore): EventSourcingRepository { - return FirstEventOnlyEventSourcingRepository.builder(DataEntryAggregate::class.java).eventStore(eventStore).build() - } - - /** - * Provides a standard event sourcing repository for data entry aggregate. - */ - @ConditionalOnProperty( - name = ["polyflow.core.data-entry.event-sourcing-repository-type"], - havingValue = "org.axonframework.eventsourcing.EventSourcingRepository", - matchIfMissing = true - ) - @Bean(DATA_ENTRY_REPOSITORY) - fun dataEntryAggregateRepository(eventStore: EventStore): EventSourcingRepository { - return EventSourcingRepository.builder(DataEntryAggregate::class.java).eventStore(eventStore).build() - } - - /** - * Register snapshotter. It will trigger if the aggregate is loaded by the series of events and the series is exceeding the snapshot. - * This is the case by the standard [EventSourcingRepository] is used, but will never happen if the [FirstEventOnlyEventSourcingRepository] is used. - */ - @Bean(DATA_ENTRY_SNAPSHOTTER) - fun dataEntryAggregateSnapshotterTriggerDefinition(snapshotter: Snapshotter, dataPoolProperties: DataPoolProperties): SnapshotTriggerDefinition { - return EventCountSnapshotTriggerDefinition(snapshotter, dataPoolProperties.snapshotThreshold) - } - - /** - * Use weak reference cache. - */ - @Bean(DATA_ENTRY_CACHE) - fun dataEntryCache(): Cache = WeakReferenceCache() - + companion object: KLogging() /** * Deletion strategy for lax handling of updates after deletion (default). */ @@ -85,6 +29,8 @@ class DataPoolCoreConfiguration { @Bean fun laxDeletionStrategy(): DeletionStrategy = object : DeletionStrategy { override fun strictMode(): Boolean = false + }.also { + logger.info { "Data pool core: using LAX deletion strategy." } } /** @@ -98,6 +44,8 @@ class DataPoolCoreConfiguration { @Bean fun strictDeletionStrategy(): DeletionStrategy = object : DeletionStrategy { override fun strictMode(): Boolean = true + }.also { + logger.info { "Data pool core: using STRICT deletion strategy." } } } diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/EnableDataPool.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/EnablePolyflowDataPool.kt similarity index 69% rename from core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/EnableDataPool.kt rename to core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/EnablePolyflowDataPool.kt index 7809afa8f..93ff67083 100755 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/EnableDataPool.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/EnablePolyflowDataPool.kt @@ -6,5 +6,8 @@ import org.springframework.context.annotation.Import * Starts data pool component. */ @MustBeDocumented -@Import(DataPoolCoreConfiguration::class) +@Import( + DataPoolCoreConfiguration::class, + DataPoolCoreAxonConfiguration::class +) annotation class EnablePolyflowDataPool diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt index e66d56a37..ef51b4e23 100755 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt @@ -1,6 +1,7 @@ package io.holunda.polyflow.datapool.core.business import io.holunda.camunda.taskpool.api.business.* +import io.holunda.polyflow.datapool.core.DataPoolCoreAxonConfiguration import io.holunda.polyflow.datapool.core.DataPoolCoreConfiguration import io.holunda.polyflow.datapool.core.DeletionStrategy import mu.KLogging @@ -17,9 +18,9 @@ import org.axonframework.spring.stereotype.Aggregate * The aggregate is manually created by the CreateOrUpdateCommandHandler. */ @Aggregate( - repository = DataPoolCoreConfiguration.DATA_ENTRY_REPOSITORY, - snapshotTriggerDefinition = DataPoolCoreConfiguration.DATA_ENTRY_SNAPSHOTTER, - cache = DataPoolCoreConfiguration.DATA_ENTRY_CACHE, + repository = DataPoolCoreAxonConfiguration.DATA_ENTRY_REPOSITORY, + snapshotTriggerDefinition = DataPoolCoreAxonConfiguration.DATA_ENTRY_SNAPSHOTTER, + cache = DataPoolCoreAxonConfiguration.DATA_ENTRY_CACHE, ) class DataEntryAggregate() { diff --git a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt index 8a3c77011..dd3589a63 100644 --- a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt +++ b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreDeletionStrategyConfigurationTest.kt @@ -4,6 +4,7 @@ import org.assertj.core.api.Assertions.assertThat import org.axonframework.eventsourcing.Snapshotter import org.axonframework.eventsourcing.eventstore.EventStore import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows import org.mockito.kotlin.mock import org.springframework.boot.context.annotation.UserConfigurations import org.springframework.boot.test.context.runner.ApplicationContextRunner @@ -18,7 +19,8 @@ internal class DataPoolCoreDeletionStrategyConfigurationTest { fun `should do lax by default`() { contextRunner .withUserConfiguration(TestMockConfiguration::class.java) - .withPropertyValues("" + .withPropertyValues( + "" ).run { assertThat(it.getBean(DataPoolProperties::class.java)).isNotNull assertThat(it.getBean(DeletionStrategy::class.java)).isNotNull @@ -67,6 +69,18 @@ internal class DataPoolCoreDeletionStrategyConfigurationTest { } } + @Test + fun `should not allow wrong values in deletion mode`() { + + contextRunner + .withUserConfiguration(TestMockConfiguration::class.java) + .withPropertyValues( + "polyflow.core.data-entry.deletion-strategy=hugo" + ).run { + assertThrows { it.getBean(DataPoolProperties::class.java) } + } + } + class TestMockConfiguration { @Bean diff --git a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateFirstEventOnlyEventSourcingRepositoryITest.kt b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateFirstEventOnlyEventSourcingRepositoryITest.kt index 7f4d3df33..aff1a4693 100644 --- a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateFirstEventOnlyEventSourcingRepositoryITest.kt +++ b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregateFirstEventOnlyEventSourcingRepositoryITest.kt @@ -1,7 +1,7 @@ package io.holunda.polyflow.datapool.core.business import io.holunda.camunda.taskpool.api.business.* -import io.holunda.polyflow.datapool.TestApplication +import io.holunda.polyflow.datapool.core.itest.TestApplication import mu.KLogging import org.assertj.core.api.Assertions.assertThat import org.axonframework.commandhandling.gateway.CommandGateway diff --git a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/TestApplication.kt b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/itest/TestApplication.kt similarity index 93% rename from core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/TestApplication.kt rename to core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/itest/TestApplication.kt index 46bd47d01..97494e0f5 100644 --- a/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/TestApplication.kt +++ b/core/datapool/datapool-core/src/test/kotlin/io/holunda/polyflow/datapool/core/itest/TestApplication.kt @@ -1,4 +1,4 @@ -package io.holunda.polyflow.datapool +package io.holunda.polyflow.datapool.core.itest import com.thoughtworks.xstream.XStream import com.thoughtworks.xstream.security.AnyTypePermission diff --git a/integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt b/integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt index f3e8c20b6..5e12c94c6 100644 --- a/integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt +++ b/integration/camunda-bpm/springboot-starter/src/test/kotlin/TaskpoolStarterITest.kt @@ -1,3 +1,5 @@ +package io.holunda.polyflow.taskpool + import io.holunda.polyflow.datapool.sender.DataEntryCommandSender import io.holunda.polyflow.taskpool.EnableTaskpoolEngineSupport import io.holunda.polyflow.taskpool.sender.task.EngineTaskCommandSender diff --git a/view/jpa/pom.xml b/view/jpa/pom.xml index 2b38ae4f6..aa6808a9f 100644 --- a/view/jpa/pom.xml +++ b/view/jpa/pom.xml @@ -51,6 +51,7 @@ com.h2database h2 + 1.4.200 test From 45c899f0bd6b054ed44690195e8ce546c111dcf4 Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 23 Nov 2022 15:17:19 +0100 Subject: [PATCH 5/6] fixing deletion strategy injection into custom aggregate repository --- .../core/DataPoolCoreAxonConfiguration.kt | 41 ++++++++++++++----- .../core/business/DataEntryAggregate.kt | 5 ++- .../core/TaskPoolCoreConfiguration.kt | 10 +++-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt index 214b60604..91a10ad5f 100755 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/DataPoolCoreAxonConfiguration.kt @@ -12,13 +12,11 @@ import org.axonframework.eventsourcing.EventSourcingRepository import org.axonframework.eventsourcing.SnapshotTriggerDefinition import org.axonframework.eventsourcing.Snapshotter import org.axonframework.eventsourcing.eventstore.EventStore -import org.springframework.boot.autoconfigure.AutoConfigureAfter +import org.axonframework.messaging.annotation.ParameterResolverFactory +import org.springframework.beans.factory.annotation.Qualifier import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty -import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration -import org.springframework.context.annotation.DependsOn import org.springframework.context.annotation.Import @@ -31,8 +29,9 @@ import org.springframework.context.annotation.Import CreateOrUpdateCommandHandler::class, DataEntryCreatedEventUpcaster::class ) -class DataPoolCoreAxonConfiguration { - +class DataPoolCoreAxonConfiguration( + deletionStrategy: DeletionStrategy +) { companion object : KLogging() { const val DATA_ENTRY_REPOSITORY = "dataEntryEventSourcingRepository" const val DATA_ENTRY_SNAPSHOTTER = "dataEntrySnapshotter" @@ -48,8 +47,19 @@ class DataPoolCoreAxonConfiguration { havingValue = "io.holunda.polyflow.datapool.core.repository.FirstEventOnlyEventSourcingRepository" ) @Bean(DATA_ENTRY_REPOSITORY) - fun firstEventDataEntryAggregateRepository(eventStore: EventStore): EventSourcingRepository { - return FirstEventOnlyEventSourcingRepository.builder(DataEntryAggregate::class.java).eventStore(eventStore).build() + fun firstEventDataEntryAggregateRepository( + eventStore: EventStore, + factory: ParameterResolverFactory, + @Qualifier(DATA_ENTRY_CACHE) dataEntryCache: Cache, + @Qualifier(DATA_ENTRY_SNAPSHOTTER) dataEntryAggregateSnapshotterTriggerDefinition: SnapshotTriggerDefinition + ): EventSourcingRepository { + return FirstEventOnlyEventSourcingRepository + .builder(DataEntryAggregate::class.java) + .parameterResolverFactory(factory) + .cache(dataEntryCache) + .snapshotTriggerDefinition(dataEntryAggregateSnapshotterTriggerDefinition) + .eventStore(eventStore) + .build() } /** @@ -61,8 +71,19 @@ class DataPoolCoreAxonConfiguration { matchIfMissing = true ) @Bean(DATA_ENTRY_REPOSITORY) - fun dataEntryAggregateRepository(eventStore: EventStore): EventSourcingRepository { - return EventSourcingRepository.builder(DataEntryAggregate::class.java).eventStore(eventStore).build() + fun dataEntryAggregateRepository( + eventStore: EventStore, + factory: ParameterResolverFactory, + @Qualifier(DATA_ENTRY_CACHE) dataEntryCache: Cache, + @Qualifier(DATA_ENTRY_SNAPSHOTTER) dataEntryAggregateSnapshotterTriggerDefinition: SnapshotTriggerDefinition + ): EventSourcingRepository { + return EventSourcingRepository + .builder(DataEntryAggregate::class.java) + .parameterResolverFactory(factory) + .cache(dataEntryCache) + .snapshotTriggerDefinition(dataEntryAggregateSnapshotterTriggerDefinition) + .eventStore(eventStore) + .build() } /** diff --git a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt index ef51b4e23..5c056ec05 100755 --- a/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt +++ b/core/datapool/datapool-core/src/main/kotlin/io/holunda/polyflow/datapool/core/business/DataEntryAggregate.kt @@ -11,6 +11,7 @@ import org.axonframework.eventsourcing.EventSourcingHandler import org.axonframework.modelling.command.AggregateIdentifier import org.axonframework.modelling.command.AggregateLifecycle import org.axonframework.spring.stereotype.Aggregate +import org.springframework.beans.factory.annotation.Autowired /** * Aggregate representing a data entry. @@ -44,7 +45,7 @@ class DataEntryAggregate() { * Handle update. */ @CommandHandler - fun handle(command: UpdateDataEntryCommand, deletionStrategy: DeletionStrategy) { + fun handle(command: UpdateDataEntryCommand, @Autowired deletionStrategy: DeletionStrategy) { if (deletionStrategy.strictMode()) { if (deleted) { throw AggregateDeletedException(this.dataIdentity, "The data entry has already been deleted") @@ -59,7 +60,7 @@ class DataEntryAggregate() { * Handle delete. */ @CommandHandler - fun handle(command: DeleteDataEntryCommand, deletionStrategy: DeletionStrategy) { + fun handle(command: DeleteDataEntryCommand, @Autowired deletionStrategy: DeletionStrategy) { if (deletionStrategy.strictMode()) { if (deleted) { throw AggregateDeletedException(this.dataIdentity, "The data entry has already been deleted") diff --git a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt index b49b6d8d4..8214b6d15 100755 --- a/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt +++ b/core/taskpool/taskpool-core/src/main/kotlin/io/holunda/polyflow/taskpool/core/TaskPoolCoreConfiguration.kt @@ -5,6 +5,7 @@ import io.holunda.polyflow.taskpool.core.process.ProcessInstanceAggregate import io.holunda.polyflow.taskpool.core.task.TaskAggregate import org.axonframework.eventsourcing.EventSourcingRepository import org.axonframework.eventsourcing.eventstore.EventStore +import org.axonframework.messaging.annotation.ParameterResolverFactory import org.axonframework.modelling.command.Aggregate import org.axonframework.modelling.command.AggregateNotFoundException import org.springframework.context.annotation.Bean @@ -29,9 +30,10 @@ class TaskPoolCoreConfiguration { * Provide repository for task aggregates. */ @Bean(TASK_AGGREGATE_REPOSITORY) - fun taskAggregateRepository(eventStore: EventStore): EventSourcingRepository { + fun taskAggregateRepository(eventStore: EventStore, parameterResolverFactory: ParameterResolverFactory): EventSourcingRepository { return EventSourcingRepository .builder(TaskAggregate::class.java) + .parameterResolverFactory(parameterResolverFactory) .eventStore(eventStore) .build() } @@ -40,9 +42,10 @@ class TaskPoolCoreConfiguration { * Provide repository for process definition aggregates. */ @Bean(PROCESS_DEFINITION_AGGREGATE_REPOSITORY) - fun processDefinitionAggregateRepository(eventStore: EventStore): EventSourcingRepository { + fun processDefinitionAggregateRepository(eventStore: EventStore, parameterResolverFactory: ParameterResolverFactory): EventSourcingRepository { return EventSourcingRepository .builder(ProcessDefinitionAggregate::class.java) + .parameterResolverFactory(parameterResolverFactory) .eventStore(eventStore) .build() } @@ -51,9 +54,10 @@ class TaskPoolCoreConfiguration { * Provide repository for process instance aggregates. */ @Bean(PROCESS_INSTANCE_AGGREGATE_REPOSITORY) - fun processInstanceAggregateRepository(eventStore: EventStore): EventSourcingRepository { + fun processInstanceAggregateRepository(eventStore: EventStore, parameterResolverFactory: ParameterResolverFactory): EventSourcingRepository { return EventSourcingRepository .builder(ProcessInstanceAggregate::class.java) + .parameterResolverFactory(parameterResolverFactory) .eventStore(eventStore) .build() } From 7cf7874c917be4d98507ddcd9d1862b9a4ae152f Mon Sep 17 00:00:00 2001 From: Simon Zambrovski Date: Wed, 23 Nov 2022 16:01:14 +0100 Subject: [PATCH 6/6] Update for next development version --- bom/datapool-dependencies/pom.xml | 2 +- bom/parent/pom.xml | 2 +- bom/taskpool-dependencies/pom.xml | 2 +- core/bus-jackson/pom.xml | 2 +- core/datapool/datapool-api/pom.xml | 2 +- core/datapool/datapool-core/pom.xml | 2 +- core/datapool/datapool-event/pom.xml | 2 +- core/datapool/pom.xml | 2 +- core/taskpool/pom.xml | 2 +- core/taskpool/taskpool-api/pom.xml | 2 +- core/taskpool/taskpool-core/pom.xml | 2 +- core/taskpool/taskpool-event/pom.xml | 2 +- integration/camunda-bpm/engine-client/pom.xml | 2 +- integration/camunda-bpm/pom.xml | 2 +- integration/camunda-bpm/springboot-autoconfigure/pom.xml | 2 +- integration/camunda-bpm/springboot-starter/pom.xml | 2 +- integration/camunda-bpm/taskpool-collector/pom.xml | 2 +- integration/common/datapool-sender/pom.xml | 2 +- integration/common/pom.xml | 2 +- integration/common/tasklist-url-resolver/pom.xml | 2 +- integration/common/taskpool-sender/pom.xml | 2 +- integration/common/variable-serializer/pom.xml | 2 +- pom.xml | 2 +- view/form-url-resolver/pom.xml | 2 +- view/jpa/pom.xml | 2 +- view/mongo/pom.xml | 2 +- view/pom.xml | 2 +- view/simple/pom.xml | 2 +- view/view-api-client/pom.xml | 2 +- view/view-api/pom.xml | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) diff --git a/bom/datapool-dependencies/pom.xml b/bom/datapool-dependencies/pom.xml index 4dd34792b..a7be810bb 100644 --- a/bom/datapool-dependencies/pom.xml +++ b/bom/datapool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../parent/pom.xml diff --git a/bom/parent/pom.xml b/bom/parent/pom.xml index ac19f12df..6e28209b3 100644 --- a/bom/parent/pom.xml +++ b/bom/parent/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-root - 3.4.2-SNAPSHOT + 3.4.2 ../../pom.xml diff --git a/bom/taskpool-dependencies/pom.xml b/bom/taskpool-dependencies/pom.xml index ff82a98ff..0770c73e9 100644 --- a/bom/taskpool-dependencies/pom.xml +++ b/bom/taskpool-dependencies/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../parent/pom.xml diff --git a/core/bus-jackson/pom.xml b/core/bus-jackson/pom.xml index e20436c6f..6414afeae 100755 --- a/core/bus-jackson/pom.xml +++ b/core/bus-jackson/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../../bom/parent/pom.xml diff --git a/core/datapool/datapool-api/pom.xml b/core/datapool/datapool-api/pom.xml index 0430f83a2..4e826f40f 100755 --- a/core/datapool/datapool-api/pom.xml +++ b/core/datapool/datapool-api/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-datapool-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-datapool-api diff --git a/core/datapool/datapool-core/pom.xml b/core/datapool/datapool-core/pom.xml index b76b8ae42..3da83eaf1 100755 --- a/core/datapool/datapool-core/pom.xml +++ b/core/datapool/datapool-core/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-datapool-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-datapool-core diff --git a/core/datapool/datapool-event/pom.xml b/core/datapool/datapool-event/pom.xml index 57b7978ea..d2ce44e56 100755 --- a/core/datapool/datapool-event/pom.xml +++ b/core/datapool/datapool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-datapool-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-datapool-event diff --git a/core/datapool/pom.xml b/core/datapool/pom.xml index 2c9686066..7fc9a4b4d 100755 --- a/core/datapool/pom.xml +++ b/core/datapool/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../../bom/parent/pom.xml diff --git a/core/taskpool/pom.xml b/core/taskpool/pom.xml index 4c72c2857..df201885b 100755 --- a/core/taskpool/pom.xml +++ b/core/taskpool/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../../bom/parent/pom.xml diff --git a/core/taskpool/taskpool-api/pom.xml b/core/taskpool/taskpool-api/pom.xml index 6c706138f..07d3139c0 100755 --- a/core/taskpool/taskpool-api/pom.xml +++ b/core/taskpool/taskpool-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-taskpool-api diff --git a/core/taskpool/taskpool-core/pom.xml b/core/taskpool/taskpool-core/pom.xml index e5f1299f9..1ae3e0081 100755 --- a/core/taskpool/taskpool-core/pom.xml +++ b/core/taskpool/taskpool-core/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-taskpool-core diff --git a/core/taskpool/taskpool-event/pom.xml b/core/taskpool/taskpool-event/pom.xml index 3d04f98b1..660d958c9 100755 --- a/core/taskpool/taskpool-event/pom.xml +++ b/core/taskpool/taskpool-event/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-taskpool-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-taskpool-event diff --git a/integration/camunda-bpm/engine-client/pom.xml b/integration/camunda-bpm/engine-client/pom.xml index a64355663..c063bc8b9 100644 --- a/integration/camunda-bpm/engine-client/pom.xml +++ b/integration/camunda-bpm/engine-client/pom.xml @@ -4,7 +4,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-camunda-bpm-engine-client diff --git a/integration/camunda-bpm/pom.xml b/integration/camunda-bpm/pom.xml index f8e913ea8..b824bc056 100644 --- a/integration/camunda-bpm/pom.xml +++ b/integration/camunda-bpm/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../../bom/parent/pom.xml diff --git a/integration/camunda-bpm/springboot-autoconfigure/pom.xml b/integration/camunda-bpm/springboot-autoconfigure/pom.xml index da992288c..b7f09c19b 100755 --- a/integration/camunda-bpm/springboot-autoconfigure/pom.xml +++ b/integration/camunda-bpm/springboot-autoconfigure/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-camunda-bpm-springboot-autoconfigure diff --git a/integration/camunda-bpm/springboot-starter/pom.xml b/integration/camunda-bpm/springboot-starter/pom.xml index 26b1df76c..0bb231e90 100755 --- a/integration/camunda-bpm/springboot-starter/pom.xml +++ b/integration/camunda-bpm/springboot-starter/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-camunda-bpm-springboot-starter diff --git a/integration/camunda-bpm/taskpool-collector/pom.xml b/integration/camunda-bpm/taskpool-collector/pom.xml index 25bca78b1..9a89f3d74 100755 --- a/integration/camunda-bpm/taskpool-collector/pom.xml +++ b/integration/camunda-bpm/taskpool-collector/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-camunda-bpm-engine-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-camunda-bpm-taskpool-collector diff --git a/integration/common/datapool-sender/pom.xml b/integration/common/datapool-sender/pom.xml index c2beaac2a..d5b7a64e9 100755 --- a/integration/common/datapool-sender/pom.xml +++ b/integration/common/datapool-sender/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-datapool-sender diff --git a/integration/common/pom.xml b/integration/common/pom.xml index 190d1eddd..d2121c3a7 100755 --- a/integration/common/pom.xml +++ b/integration/common/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../../bom/parent/pom.xml diff --git a/integration/common/tasklist-url-resolver/pom.xml b/integration/common/tasklist-url-resolver/pom.xml index 73aed263c..3afdff43a 100644 --- a/integration/common/tasklist-url-resolver/pom.xml +++ b/integration/common/tasklist-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-tasklist-url-resolver diff --git a/integration/common/taskpool-sender/pom.xml b/integration/common/taskpool-sender/pom.xml index 58d5b93da..d085fab8c 100755 --- a/integration/common/taskpool-sender/pom.xml +++ b/integration/common/taskpool-sender/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-taskpool-sender diff --git a/integration/common/variable-serializer/pom.xml b/integration/common/variable-serializer/pom.xml index 24aee67a8..24d35ba02 100755 --- a/integration/common/variable-serializer/pom.xml +++ b/integration/common/variable-serializer/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-integration-common-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-variable-serializer diff --git a/pom.xml b/pom.xml index 525e99a08..ffd6dfbf5 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-root - 3.4.2-SNAPSHOT + 3.4.2 pom POM: ${project.artifactId} diff --git a/view/form-url-resolver/pom.xml b/view/form-url-resolver/pom.xml index 81bb6828a..6bebf1031 100644 --- a/view/form-url-resolver/pom.xml +++ b/view/form-url-resolver/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-form-url-resolver diff --git a/view/jpa/pom.xml b/view/jpa/pom.xml index aa6808a9f..73e0ecd7d 100644 --- a/view/jpa/pom.xml +++ b/view/jpa/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-view-jpa diff --git a/view/mongo/pom.xml b/view/mongo/pom.xml index c9ce42c35..68b99c18c 100755 --- a/view/mongo/pom.xml +++ b/view/mongo/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-view-mongo diff --git a/view/pom.xml b/view/pom.xml index ca67b9660..e7bbe3038 100644 --- a/view/pom.xml +++ b/view/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-parent - 3.4.2-SNAPSHOT + 3.4.2 ../bom/parent/pom.xml diff --git a/view/simple/pom.xml b/view/simple/pom.xml index 4d714b2ba..131e3a2e1 100755 --- a/view/simple/pom.xml +++ b/view/simple/pom.xml @@ -5,7 +5,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-view-simple diff --git a/view/view-api-client/pom.xml b/view/view-api-client/pom.xml index fefc01071..5cdb5f320 100755 --- a/view/view-api-client/pom.xml +++ b/view/view-api-client/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-view-api-client diff --git a/view/view-api/pom.xml b/view/view-api/pom.xml index edd520459..7ec20c893 100755 --- a/view/view-api/pom.xml +++ b/view/view-api/pom.xml @@ -6,7 +6,7 @@ io.holunda.polyflow polyflow-view-parent - 3.4.2-SNAPSHOT + 3.4.2 polyflow-view-api