From 36216717a55ab8abf9a4830736555fe015a8f15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Fri, 4 Oct 2024 15:56:19 +0200 Subject: [PATCH 1/3] NO_ISSUE: Copying resources directly to `target` instead to `src/main/resources` to keep module sources clean. (#2106) * NO_ISSUE: Copying resources directly to `target` instead to `src/main/resources` to keep module sources clean. * - changed it tests * - fix springboot it-tests - renamed path variables * - renamed path variables * - fix target path * Revert "- fix target path" This reverts commit c6e36fe42cac397df4400f5aa1bdd2afe0fbf852. * - fix Trusty Springboot IT test --- .../.gitignore | 19 --------------- .../pom.xml | 16 +------------ .../.gitignore | 19 --------------- .../pom.xml | 16 +------------ .../.gitignore | 18 --------------- .../pom.xml | 2 +- .../.gitignore | 18 --------------- .../pom.xml | 15 +----------- .../.gitignore | 18 --------------- .../pom.xml | 23 ++++++++----------- .../data-index-storage-jpa/.gitignore | 1 - .../data-index-storage-jpa/pom.xml | 13 ++++++----- .../resources/META-INF/kie-flyway.properties | 4 ++-- .../resources/META-INF/kie-flyway.properties | 2 +- .../jobs-service-storage-jpa/.gitignore | 1 - jobs-service/jobs-service-storage-jpa/pom.xml | 11 +++++---- .../persistence-commons-jpa/.gitignore | 1 - .../persistence-commons-jpa/pom.xml | 11 +++++---- 18 files changed, 35 insertions(+), 173 deletions(-) delete mode 100644 apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/.gitignore delete mode 100644 apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/.gitignore delete mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/.gitignore delete mode 100644 apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/.gitignore delete mode 100644 apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/.gitignore delete mode 100644 data-index/data-index-storage/data-index-storage-jpa/.gitignore delete mode 100644 jobs-service/jobs-service-storage-jpa/.gitignore delete mode 100644 persistence-commons/persistence-commons-jpa/.gitignore diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/.gitignore b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/.gitignore deleted file mode 100644 index e4c482fe2f..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# 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. - -src/main/resources/**/*.bpmn -src/main/resources/*.sql \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/pom.xml b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/pom.xml index 5773846b3f..ad1b65312d 100644 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/pom.xml @@ -137,7 +137,7 @@ copy-resources - ${project.basedir}/src/main/resources + ${project.basedir}/target/classes ${project.parent.basedir}/integration-tests-data-index-service-common/src/main/resources @@ -156,20 +156,6 @@ - - maven-clean-plugin - - - - ${project.basedir}/src/main/resources/ - - **/*.bpmn - *create.sql - - - - - io.quarkus quarkus-maven-plugin diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/.gitignore b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/.gitignore deleted file mode 100644 index 27e5bc0483..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# 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. - -src/main/resources/**/*.bpmn -src/main/resources/*create.sql \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/pom.xml b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/pom.xml index 9540d3e3ea..afc37da461 100644 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/pom.xml +++ b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/pom.xml @@ -152,7 +152,7 @@ copy-resources - ${project.basedir}/src/main/resources + ${project.basedir}/target/generated-resources ${project.parent.basedir}/integration-tests-data-index-service-common/src/main/resources @@ -171,20 +171,6 @@ - - maven-clean-plugin - - - - ${project.basedir}/src/main/resources/ - - **/*.bpmn - *create.sql - - - - - org.springframework.boot spring-boot-maven-plugin diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/.gitignore b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/.gitignore deleted file mode 100644 index 76298e6003..0000000000 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# 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. - -src/main/resources/**/*.bpmn \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml index 5ee3f0acb4..c7c28d746d 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml @@ -109,7 +109,7 @@ copy-resources - src/main/resources + ${project.basedir}/target/generated-resources ${common.test.resources.dir} diff --git a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/.gitignore b/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/.gitignore deleted file mode 100644 index 2109313e7a..0000000000 --- a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# 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. - -src/main/resources/**/*.dmn diff --git a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/pom.xml b/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/pom.xml index ea3863b225..2b4ea70d92 100644 --- a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-quarkus/pom.xml @@ -83,7 +83,7 @@ copy-resources - ${project.basedir}/src/main/resources + ${project.basedir}/target/classes ${project.parent.basedir}/integration-tests-trusty-service-common/src/main/resources @@ -96,19 +96,6 @@ - - maven-clean-plugin - - - - ${project.basedir}/src/main/resources - - *.dmn - - - - - io.quarkus diff --git a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/.gitignore b/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/.gitignore deleted file mode 100644 index 2109313e7a..0000000000 --- a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# 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. - -src/main/resources/**/*.dmn diff --git a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/pom.xml b/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/pom.xml index ccc4b93310..1f01ab3b42 100644 --- a/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/pom.xml +++ b/apps-integration-tests/integration-tests-trusty-service/integration-tests-trusty-service-springboot/pom.xml @@ -77,6 +77,14 @@ + + + src/main/resources + + + ${project.basedir}/target/generated-resources + + maven-resources-plugin @@ -87,7 +95,7 @@ copy-resources - ${project.basedir}/src/main/resources + ${project.basedir}/target/generated-resources ${project.parent.basedir}/integration-tests-trusty-service-common/src/main/resources @@ -100,19 +108,6 @@ - - maven-clean-plugin - - - - ${project.basedir}/src/main/resources - - *.dmn - - - - - org.kie.kogito kogito-maven-plugin diff --git a/data-index/data-index-storage/data-index-storage-jpa/.gitignore b/data-index/data-index-storage/data-index-storage-jpa/.gitignore deleted file mode 100644 index dcbcbd9203..0000000000 --- a/data-index/data-index-storage/data-index-storage-jpa/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/src/main/resources/kie-flyway/db/data-index/postgresql/* diff --git a/data-index/data-index-storage/data-index-storage-jpa/pom.xml b/data-index/data-index-storage/data-index-storage-jpa/pom.xml index 61e0e2b61b..393cc0901d 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/pom.xml +++ b/data-index/data-index-storage/data-index-storage-jpa/pom.xml @@ -34,12 +34,13 @@ ../data-index-storage-postgresql - src/main/resources/kie-flyway/db/ - ${path.to.postgresql.storage}/${path.to.script.folder}/data-index/postgresql - ${path.to.script.folder}/data-index/postgresql + kie-flyway/db/data-index/postgresql + src/main/resources/${path.to.flyway.location} + ${path.to.postgresql.storage}/${path.to.script.folder} + target/classes/${path.to.flyway.location} org.kie.kogito.index.jpa - + org.kie.kogito @@ -131,10 +132,10 @@ copy-resources - ${path.to.migration.scripts.to} + ${path.to.migration.scripts.target} - ${path.to.migration.scripts.from} + ${path.to.migration.scripts.source} *.sql diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties index d8f805bbbf..41c52109f4 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/kie-flyway.properties @@ -19,5 +19,5 @@ module.name=data-index -module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-common/postgresql -module.locations.default=classpath:kie-flyway/db/data-index/ansi,classpath:kie-flyway/db/persistence-common/ansi \ No newline at end of file +module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-commons/postgresql +module.locations.default=classpath:kie-flyway/db/data-index/ansi,classpath:kie-flyway/db/persistence-commons/ansi \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties index 2d8c8351cf..383546a8fe 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/META-INF/kie-flyway.properties @@ -19,4 +19,4 @@ module.name=data-index -module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-common/postgresql \ No newline at end of file +module.locations.postgresql=classpath:kie-flyway/db/data-index/postgresql,classpath:kie-flyway/db/persistence-commons/postgresql \ No newline at end of file diff --git a/jobs-service/jobs-service-storage-jpa/.gitignore b/jobs-service/jobs-service-storage-jpa/.gitignore deleted file mode 100644 index 2df81122b4..0000000000 --- a/jobs-service/jobs-service-storage-jpa/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/src/main/resources/kie-flyway/db/jobs-service/postgresql/* diff --git a/jobs-service/jobs-service-storage-jpa/pom.xml b/jobs-service/jobs-service-storage-jpa/pom.xml index b4a1054791..b49d36ce73 100644 --- a/jobs-service/jobs-service-storage-jpa/pom.xml +++ b/jobs-service/jobs-service-storage-jpa/pom.xml @@ -35,9 +35,10 @@ ../jobs-service-postgresql-common - src/main/resources/db/ - ${path.to.postgresql.storage}/${path.to.script.folder}/jobs-service/postgresql - ${path.to.script.folder}/jobs-service/postgresql + kie-flyway/db/jobs-service/postgresql + src/main/resources/${path.to.flyway.location} + ${path.to.postgresql.storage}/${path.to.script.folder} + target/classes/${path.to.flyway.location} org.kie.kogito.job.service.repository.jpa @@ -138,10 +139,10 @@ copy-resources - ${path.to.migration.scripts.to} + ${path.to.migration.scripts.target} - ${path.to.migration.scripts.from} + ${path.to.migration.scripts.source} *.sql diff --git a/persistence-commons/persistence-commons-jpa/.gitignore b/persistence-commons/persistence-commons-jpa/.gitignore deleted file mode 100644 index 398874aed7..0000000000 --- a/persistence-commons/persistence-commons-jpa/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/src/main/resources/kie-flyway/db/persistence-commons/postgresql/* \ No newline at end of file diff --git a/persistence-commons/persistence-commons-jpa/pom.xml b/persistence-commons/persistence-commons-jpa/pom.xml index 55a1c1ace2..234a388048 100644 --- a/persistence-commons/persistence-commons-jpa/pom.xml +++ b/persistence-commons/persistence-commons-jpa/pom.xml @@ -34,9 +34,10 @@ ../persistence-commons-postgresql - src/main/resources/kie-flyway/db/ - ${path.to.postgresql.storage}/${path.to.script.folder}/persistence-commons/postgresql - ${path.to.script.folder}/persistence-commons/postgresql + kie-flyway/db/persistence-commons/postgresql + src/main/resources/${path.to.flyway.location} + ${path.to.postgresql.storage}/${path.to.script.folder} + target/classes/${path.to.flyway.location} org.kie.kogito.persistence.jpa @@ -77,10 +78,10 @@ copy-resources - ${path.to.migration.scripts.to} + ${path.to.migration.scripts.target} - ${path.to.migration.scripts.from} + ${path.to.migration.scripts.source} *.sql From f10d4b632e0a93d0490ea41c18b340a59d3966f0 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:44:41 +0200 Subject: [PATCH 2/3] [apache/incubator-kie-issues#1457] Allow grouping of events (#2093) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add unit tests * [Fix apache/incubator-kie-issues#1457] Grouping of events 2nd approach * Add integration tests * [Fix apache/incubator-kie-issues#1457] Grouping of event serialization * [Fix apache/incubator-kie-issues#1457] DataAudit serialization * Update data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingConsumerIT.java Co-authored-by: Gonzalo Muñoz Update data-index/data-index-service/data-index-service-postgresql/src/test/java/org/kie/kogito/index/service/messaging/PostgreSqlMessagingKafkaConsumerIT.java Co-authored-by: Gonzalo Muñoz Update data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingConsumerIT.java Co-authored-by: Gonzalo Muñoz Update data-index/data-index-service/data-index-service-postgresql/src/test/java/org/kie/kogito/index/service/messaging/PostgreSqlMessagingKafkaConsumerIT.java Co-authored-by: Gonzalo Muñoz Fix to run collections tests for all * [Fix apache/incubator-kie-issues#1457] Converter deserialization * [Fix apache/incubator-kie-issues#1457] Converter deserialization right --------- Co-authored-by: gmunozfe --- ...nProcessInstanceDataEventDeserializer.java | 3 + ...UserTaskInstanceDataEventDeserializer.java | 3 + .../audit/api/DataAuditStoreProxyService.java | 34 ++-- ...nProcessInstanceDataEventDeserializer.java | 3 + ...UserTaskInstanceDataEventDeserializer.java | 5 +- .../kogito/index/service/IndexingService.java | 21 +++ .../messaging/KogitoIndexEventConverter.java | 34 +++- .../AbstractMessagingConsumerIT.java | 65 +++++++ .../AbstractMessagingHttpConsumerIT.java | 27 +++ .../AbstractMessagingKafkaConsumerIT.java | 34 ++++ .../BlockingMessagingEventConsumerTest.java | 171 ++++++++++++++++++ .../process_definition_11_event.json | 162 +++++++++++++++++ .../src/test/resources/application.properties | 12 ++ 13 files changed, 557 insertions(+), 17 deletions(-) create mode 100644 data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java create mode 100644 data-index/data-index-service/data-index-service-common/src/test/resources/process_definition_11_event.json diff --git a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonProcessInstanceDataEventDeserializer.java b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonProcessInstanceDataEventDeserializer.java index a5801a763c..de164e6ff3 100644 --- a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonProcessInstanceDataEventDeserializer.java +++ b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonProcessInstanceDataEventDeserializer.java @@ -20,6 +20,7 @@ import java.io.IOException; +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent; import org.kie.kogito.event.process.ProcessInstanceNodeDataEvent; @@ -57,6 +58,8 @@ public ProcessInstanceDataEvent deserialize(JsonParser jp, DeserializationCon String type = node.get("type").asText(); switch (type) { + case MultipleProcessInstanceDataEvent.TYPE: + return jp.getCodec().treeToValue(node, MultipleProcessInstanceDataEvent.class); case "ProcessInstanceErrorDataEvent": return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceErrorDataEvent.class); case "ProcessInstanceNodeDataEvent": diff --git a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUserTaskInstanceDataEventDeserializer.java b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUserTaskInstanceDataEventDeserializer.java index e9d57f86c0..32e53e4f98 100644 --- a/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUserTaskInstanceDataEventDeserializer.java +++ b/data-audit/data-audit-common-service/src/main/java/org/kie/kogito/app/audit/json/JsonUserTaskInstanceDataEventDeserializer.java @@ -20,6 +20,7 @@ import java.io.IOException; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceCommentDataEvent; @@ -58,6 +59,8 @@ public UserTaskInstanceDataEvent deserialize(JsonParser jp, DeserializationCo String type = node.get("type").asText(); switch (type) { + case MultipleUserTaskInstanceDataEvent.TYPE: + return jp.getCodec().treeToValue(node, MultipleUserTaskInstanceDataEvent.class); case "UserTaskInstanceAssignmentDataEvent": return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceAssignmentDataEvent.class); case "UserTaskInstanceAttachmentDataEvent": diff --git a/data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/api/DataAuditStoreProxyService.java b/data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/api/DataAuditStoreProxyService.java index 8d844d0a02..a945d8410f 100644 --- a/data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/api/DataAuditStoreProxyService.java +++ b/data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/api/DataAuditStoreProxyService.java @@ -23,12 +23,14 @@ import org.kie.kogito.app.audit.spi.DataAuditStore; import org.kie.kogito.event.job.JobInstanceDataEvent; +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent; import org.kie.kogito.event.process.ProcessInstanceNodeDataEvent; import org.kie.kogito.event.process.ProcessInstanceSLADataEvent; import org.kie.kogito.event.process.ProcessInstanceStateDataEvent; import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceCommentDataEvent; @@ -52,23 +54,29 @@ private DataAuditStoreProxyService(DataAuditStore auditStoreService) { } public void storeProcessInstanceDataEvent(DataAuditContext context, ProcessInstanceDataEvent event) { - - typeCheckOf(ProcessInstanceErrorDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); - typeCheckOf(ProcessInstanceNodeDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); - typeCheckOf(ProcessInstanceSLADataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); - typeCheckOf(ProcessInstanceStateDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); - typeCheckOf(ProcessInstanceVariableDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); + if (event instanceof MultipleProcessInstanceDataEvent) { + ((MultipleProcessInstanceDataEvent) event).getData().forEach(e -> storeProcessInstanceDataEvent(context, e)); + } else { + typeCheckOf(ProcessInstanceErrorDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); + typeCheckOf(ProcessInstanceNodeDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); + typeCheckOf(ProcessInstanceSLADataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); + typeCheckOf(ProcessInstanceStateDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); + typeCheckOf(ProcessInstanceVariableDataEvent.class).ifType(context, event, auditStoreService::storeProcessInstanceDataEvent); + } } public void storeUserTaskInstanceDataEvent(DataAuditContext context, UserTaskInstanceDataEvent event) { - - typeCheckOf(UserTaskInstanceAssignmentDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); - typeCheckOf(UserTaskInstanceAttachmentDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); - typeCheckOf(UserTaskInstanceCommentDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); - typeCheckOf(UserTaskInstanceDeadlineDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); - typeCheckOf(UserTaskInstanceStateDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); - typeCheckOf(UserTaskInstanceVariableDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); + if (event instanceof MultipleUserTaskInstanceDataEvent) { + ((MultipleUserTaskInstanceDataEvent) event).getData().forEach(e -> storeUserTaskInstanceDataEvent(context, e)); + } else { + typeCheckOf(UserTaskInstanceAssignmentDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); + typeCheckOf(UserTaskInstanceAttachmentDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); + typeCheckOf(UserTaskInstanceCommentDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); + typeCheckOf(UserTaskInstanceDeadlineDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); + typeCheckOf(UserTaskInstanceStateDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); + typeCheckOf(UserTaskInstanceVariableDataEvent.class).ifType(context, event, auditStoreService::storeUserTaskInstanceDataEvent); + } } diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonProcessInstanceDataEventDeserializer.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonProcessInstanceDataEventDeserializer.java index e60b3e4681..261bcc4084 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonProcessInstanceDataEventDeserializer.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonProcessInstanceDataEventDeserializer.java @@ -20,6 +20,7 @@ import java.io.IOException; +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent; import org.kie.kogito.event.process.ProcessInstanceNodeDataEvent; @@ -57,6 +58,8 @@ public ProcessInstanceDataEvent deserialize(JsonParser jp, DeserializationCon String type = node.get("type").asText(); switch (type) { + case MultipleProcessInstanceDataEvent.TYPE: + return jp.getCodec().treeToValue(node, MultipleProcessInstanceDataEvent.class); case "ProcessInstanceErrorDataEvent": return (ProcessInstanceDataEvent) jp.getCodec().treeToValue(node, ProcessInstanceErrorDataEvent.class); case "ProcessInstanceNodeDataEvent": diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUserTaskInstanceDataEventDeserializer.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUserTaskInstanceDataEventDeserializer.java index 7aa0437f55..3a515a5e8b 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUserTaskInstanceDataEventDeserializer.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUserTaskInstanceDataEventDeserializer.java @@ -20,6 +20,7 @@ import java.io.IOException; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceCommentDataEvent; @@ -58,6 +59,8 @@ public UserTaskInstanceDataEvent deserialize(JsonParser jp, DeserializationCo String type = node.get("type").asText(); switch (type) { + case MultipleUserTaskInstanceDataEvent.TYPE: + return jp.getCodec().treeToValue(node, MultipleUserTaskInstanceDataEvent.class); case "UserTaskInstanceAssignmentDataEvent": return (UserTaskInstanceDataEvent) jp.getCodec().treeToValue(node, UserTaskInstanceAssignmentDataEvent.class); case "UserTaskInstanceAttachmentDataEvent": @@ -76,4 +79,4 @@ public UserTaskInstanceDataEvent deserialize(JsonParser jp, DeserializationCo } } -} \ No newline at end of file +} diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/service/IndexingService.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/service/IndexingService.java index 2802fe8f94..f3cd153d5b 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/service/IndexingService.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/service/IndexingService.java @@ -26,6 +26,7 @@ import java.util.Optional; import org.eclipse.microprofile.faulttolerance.Retry; +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessDefinitionDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent; @@ -33,6 +34,7 @@ import org.kie.kogito.event.process.ProcessInstanceSLADataEvent; import org.kie.kogito.event.process.ProcessInstanceStateDataEvent; import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceCommentDataEvent; @@ -76,6 +78,15 @@ public class IndexingService { @Retry(maxRetries = 3, delay = 300, jitter = 100, retryOn = ConcurrentModificationException.class) public void indexProcessInstanceEvent(ProcessInstanceDataEvent event) { ProcessInstanceStorage storage = manager.getProcessInstanceStorage(); + if (event instanceof MultipleProcessInstanceDataEvent) { + for (ProcessInstanceDataEvent item : ((MultipleProcessInstanceDataEvent) event).getData()) + indexProccessInstanceEvent(storage, item); + } else { + indexProccessInstanceEvent(storage, event); + } + } + + private void indexProccessInstanceEvent(ProcessInstanceStorage storage, ProcessInstanceDataEvent event) { if (event instanceof ProcessInstanceErrorDataEvent) { storage.indexError((ProcessInstanceErrorDataEvent) event); } else if (event instanceof ProcessInstanceNodeDataEvent) { @@ -100,6 +111,16 @@ public void indexProcessDefinition(ProcessDefinitionDataEvent definitionDataEven @Retry(maxRetries = 3, delay = 300, jitter = 100, retryOn = ConcurrentModificationException.class) public void indexUserTaskInstanceEvent(UserTaskInstanceDataEvent event) { UserTaskInstanceStorage storage = manager.getUserTaskInstanceStorage(); + if (event instanceof MultipleUserTaskInstanceDataEvent) { + for (UserTaskInstanceDataEvent item : ((MultipleUserTaskInstanceDataEvent) event).getData()) { + indexUserTaskInstanceEvent(storage, item); + } + } else { + indexUserTaskInstanceEvent(storage, event); + } + } + + private void indexUserTaskInstanceEvent(UserTaskInstanceStorage storage, UserTaskInstanceDataEvent event) { if (event instanceof UserTaskInstanceAssignmentDataEvent) { storage.indexAssignment((UserTaskInstanceAssignmentDataEvent) event); } else if (event instanceof UserTaskInstanceAttachmentDataEvent) { diff --git a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java b/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java index 430ecee796..cef45271e0 100644 --- a/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java +++ b/data-index/data-index-service/data-index-service-common/src/main/java/org/kie/kogito/index/service/messaging/KogitoIndexEventConverter.java @@ -20,11 +20,13 @@ import java.io.IOException; import java.lang.reflect.Type; +import java.util.Collection; import java.util.function.Supplier; import org.eclipse.microprofile.reactive.messaging.Message; import org.kie.kogito.event.AbstractDataEvent; import org.kie.kogito.event.DataEvent; +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessDefinitionDataEvent; import org.kie.kogito.event.process.ProcessDefinitionEventBody; import org.kie.kogito.event.process.ProcessInstanceDataEvent; @@ -38,6 +40,7 @@ import org.kie.kogito.event.process.ProcessInstanceStateEventBody; import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; import org.kie.kogito.event.process.ProcessInstanceVariableEventBody; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentEventBody; import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent; @@ -57,6 +60,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.cloudevents.CloudEvent; @@ -81,6 +85,11 @@ public class KogitoIndexEventConverter implements MessageConverter { ObjectMapper objectMapper; + @Override + public int getPriority() { + return CONVERTER_DEFAULT_PRIORITY - 2; + } + @Override public boolean canConvert(Message message, Type type) { return isIndexable(type) && @@ -139,6 +148,9 @@ public void setObjectMapper(ObjectMapper objectMapper) { private DataEvent buildProcessInstanceDataEventVariant(CloudEvent cloudEvent) throws IOException { switch (cloudEvent.getType()) { + case MultipleProcessInstanceDataEvent.TYPE: + return buildDataEvent(cloudEvent, objectMapper, MultipleProcessInstanceDataEvent::new, new TypeReference>>() { + }); case "ProcessInstanceErrorDataEvent": return buildDataEvent(cloudEvent, objectMapper, ProcessInstanceErrorDataEvent::new, ProcessInstanceErrorEventBody.class); case "ProcessInstanceNodeDataEvent": @@ -156,6 +168,9 @@ private DataEvent buildProcessInstanceDataEventVariant(CloudEvent cloudEvent) private DataEvent buildUserTaskInstanceDataEvent(CloudEvent cloudEvent) throws IOException { switch (cloudEvent.getType()) { + case MultipleUserTaskInstanceDataEvent.TYPE: + return buildDataEvent(cloudEvent, objectMapper, MultipleUserTaskInstanceDataEvent::new, new TypeReference>>() { + }); case "UserTaskInstanceAssignmentDataEvent": return buildDataEvent(cloudEvent, objectMapper, UserTaskInstanceAssignmentDataEvent::new, UserTaskInstanceAssignmentEventBody.class); case "UserTaskInstanceAttachmentDataEvent": @@ -188,16 +203,29 @@ private KogitoJobCloudEvent buildKogitoJobCloudEvent(CloudEvent cloudEvent) thro return jobCloudEvent; } + private static , T> E buildDataEvent(CloudEvent cloudEvent, ObjectMapper objectMapper, Supplier supplier, TypeReference typeReference) throws IOException { + E dataEvent = buildEvent(cloudEvent, objectMapper, supplier); + if (cloudEvent.getData() != null) { + dataEvent.setData(objectMapper.readValue(cloudEvent.getData().toBytes(), typeReference)); + } + return dataEvent; + } + private static , T> E buildDataEvent(CloudEvent cloudEvent, ObjectMapper objectMapper, Supplier supplier, Class clazz) throws IOException { - E dataEvent = supplier.get(); - applyCloudEventAttributes(cloudEvent, dataEvent); - applyExtensions(cloudEvent, dataEvent); + E dataEvent = buildEvent(cloudEvent, objectMapper, supplier); if (cloudEvent.getData() != null) { dataEvent.setData(objectMapper.readValue(cloudEvent.getData().toBytes(), clazz)); } return dataEvent; } + private static > E buildEvent(CloudEvent cloudEvent, ObjectMapper objectMapper, Supplier supplier) throws IOException { + E dataEvent = supplier.get(); + applyCloudEventAttributes(cloudEvent, dataEvent); + applyExtensions(cloudEvent, dataEvent); + return dataEvent; + } + private static void applyCloudEventAttributes(CloudEvent cloudEvent, AbstractDataEvent dataEvent) { dataEvent.setSpecVersion(cloudEvent.getSpecVersion()); dataEvent.setId(cloudEvent.getId()); diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingConsumerIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingConsumerIT.java index e98b153025..fee277a1cf 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingConsumerIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingConsumerIT.java @@ -121,6 +121,66 @@ void testJobEvent() throws Exception { .body("data.Jobs[0].id", is(jobId))); } + @Test + void testProcessInstanceEventCollection() throws Exception { + sendProcessInstanceEventCollection(); + + String processInstanceId1 = "processId-UUID1"; + String processInstanceId2 = "processId-UUID2"; + + await() + .atMost(timeout) + .untilAsserted(() -> given().contentType(ContentType.JSON) + .body("{ \"query\" : \"{ ProcessInstances { id, state } }\" }") + .when().post("/graphql") + .then().log().ifValidationFails().statusCode(200) + .body("data.ProcessInstances.size()", is(2)) + .body("data.ProcessInstances[0].id", is(processInstanceId1)) + .body("data.ProcessInstances[0].state", is("ACTIVE")) + .body("data.ProcessInstances[1].id", is(processInstanceId2)) + .body("data.ProcessInstances[1].state", is("ACTIVE"))); + + } + + @Test + void testUserTaskInstanceEventCollection() throws Exception { + sendUserTaskInstanceEventCollection(); + + String taskId1 = "taskId-UUID1"; + String taskId2 = "taskId-UUID2"; + + await() + .atMost(timeout) + .untilAsserted(() -> given().contentType(ContentType.JSON) + .body("{ \"query\" : \"{ UserTaskInstances { id, state } }\" }") + .when().post("/graphql") + .then().log().ifValidationFails().statusCode(200) + .body("data.UserTaskInstances.size()", is(2)) + .body("data.UserTaskInstances[0].id", is(taskId1)) + .body("data.UserTaskInstances[0].state", is("IN_PROGRESS")) + .body("data.UserTaskInstances[1].id", is(taskId2)) + .body("data.UserTaskInstances[1].state", is("COMPLETED"))); + } + + @Test + void testProcessDefinitionEventCollection() throws Exception { + sendProcessDefinitionEventCollection(); + + String definitionId = "jsongreet"; + + await() + .atMost(timeout) + .untilAsserted(() -> given().contentType(ContentType.JSON) + .body("{ \"query\" : \"{ ProcessDefinitions { id, version } }\" }") + .when().post("/graphql") + .then().log().ifValidationFails().statusCode(200) + .body("data.ProcessDefinitions.size()", is(2)) + .body("data.ProcessDefinitions[0].id", is(definitionId)) + .body("data.ProcessDefinitions[0].version", is("1.0")) + .body("data.ProcessDefinitions[1].id", is(definitionId)) + .body("data.ProcessDefinitions[1].version", is("1.1"))); + } + protected abstract void sendUserTaskInstanceEvent() throws Exception; protected abstract void sendProcessInstanceEvent() throws Exception; @@ -129,4 +189,9 @@ void testJobEvent() throws Exception { protected abstract void sendJobEvent() throws Exception; + protected abstract void sendProcessInstanceEventCollection() throws Exception; + + protected abstract void sendUserTaskInstanceEventCollection() throws Exception; + + protected abstract void sendProcessDefinitionEventCollection() throws Exception; } diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java index 711968bc88..d9a1364fcf 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java @@ -18,8 +18,14 @@ */ package org.kie.kogito.index.service.messaging; +import java.net.URI; +import java.util.Collection; +import java.util.List; + +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessDefinitionDataEvent; import org.kie.kogito.event.process.ProcessInstanceDataEvent; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; import org.kie.kogito.index.event.KogitoJobCloudEvent; import org.kie.kogito.index.json.JsonUtils; @@ -69,4 +75,25 @@ protected void sendJobEvent() throws Exception { connector.source(KOGITO_JOBS_EVENTS).send(event); } + protected void sendProcessInstanceEventCollection() throws Exception { + Collection> events = List.of( + getProcessCloudEvent("travels", "processId-UUID1", ProcessInstanceState.ACTIVE, null, null, null, "user1"), + getProcessCloudEvent("travels", "processId-UUID2", ProcessInstanceState.ACTIVE, null, null, null, "user2")); + connector.source(KOGITO_PROCESSINSTANCES_EVENTS).send(new MultipleProcessInstanceDataEvent(URI.create("test"), events)); + } + + @Override + protected void sendUserTaskInstanceEventCollection() throws Exception { + Collection> events = List.of( + getUserTaskCloudEvent("taskId-UUID1", "travels", "processId-UUID1", null, null, "IN_PROGRESS"), + getUserTaskCloudEvent("taskId-UUID2", "travels", "processId-UUID1", null, null, "COMPLETED")); + connector.source(KOGITO_USERTASKINSTANCES_EVENTS).send(new MultipleUserTaskInstanceDataEvent(URI.create("test"), events)); + } + + @Override + protected void sendProcessDefinitionEventCollection() throws Exception { + connector.source(KOGITO_PROCESS_DEFINITIONS_EVENTS).send(JsonUtils.getObjectMapper().readValue(readFileContent("process_definition_event.json"), ProcessDefinitionDataEvent.class)); + connector.source(KOGITO_PROCESS_DEFINITIONS_EVENTS).send(JsonUtils.getObjectMapper().readValue(readFileContent("process_definition_11_event.json"), ProcessDefinitionDataEvent.class)); + } + } diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java index d398caf2e2..c8091f1ee0 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingKafkaConsumerIT.java @@ -18,9 +18,19 @@ */ package org.kie.kogito.index.service.messaging; +import java.net.URI; +import java.util.Collection; +import java.util.List; + import org.eclipse.microprofile.config.inject.ConfigProperty; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; +import org.kie.kogito.event.process.ProcessInstanceDataEvent; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; +import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; +import org.kie.kogito.index.model.ProcessInstanceState; +import org.kie.kogito.jackson.utils.ObjectMapperFactory; import org.kie.kogito.test.quarkus.kafka.KafkaTestClient; import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; @@ -28,6 +38,8 @@ import static org.kie.kogito.index.service.messaging.ReactiveMessagingEventConsumer.KOGITO_PROCESSINSTANCES_EVENTS; import static org.kie.kogito.index.service.messaging.ReactiveMessagingEventConsumer.KOGITO_PROCESS_DEFINITIONS_EVENTS; import static org.kie.kogito.index.service.messaging.ReactiveMessagingEventConsumer.KOGITO_USERTASKINSTANCES_EVENTS; +import static org.kie.kogito.index.test.TestUtils.getProcessCloudEvent; +import static org.kie.kogito.index.test.TestUtils.getUserTaskCloudEvent; import static org.kie.kogito.index.test.TestUtils.readFileContent; public abstract class AbstractMessagingKafkaConsumerIT extends AbstractMessagingConsumerIT { @@ -67,6 +79,28 @@ protected void sendJobEvent() throws Exception { send("job_event.json", KOGITO_JOBS_EVENTS); } + @Override + protected void sendProcessInstanceEventCollection() throws Exception { + Collection> events = List.of( + getProcessCloudEvent("travels", "processId-UUID1", ProcessInstanceState.ACTIVE, null, null, null, "user1"), + getProcessCloudEvent("travels", "processId-UUID2", ProcessInstanceState.ACTIVE, null, null, null, "user2")); + kafkaClient.produce(ObjectMapperFactory.get().writeValueAsString(new MultipleProcessInstanceDataEvent(URI.create("test"), events)), KOGITO_PROCESSINSTANCES_EVENTS); + } + + @Override + protected void sendUserTaskInstanceEventCollection() throws Exception { + Collection> events = List.of( + getUserTaskCloudEvent("taskId-UUID1", "travels", "processId-UUID1", null, null, "IN_PROGRESS"), + getUserTaskCloudEvent("taskId-UUID2", "travels", "processId-UUID1", null, null, "COMPLETED")); + kafkaClient.produce(ObjectMapperFactory.get().writeValueAsString(new MultipleUserTaskInstanceDataEvent(URI.create("test"), events)), KOGITO_USERTASKINSTANCES_EVENTS); + } + + @Override + protected void sendProcessDefinitionEventCollection() throws Exception { + kafkaClient.produce(readFileContent("process_definition_event.json"), KOGITO_PROCESS_DEFINITIONS_EVENTS); + kafkaClient.produce(readFileContent("process_definition_11_event.json"), KOGITO_PROCESS_DEFINITIONS_EVENTS); + } + private void send(String file, String topic) throws Exception { String json = readFileContent(file); kafkaClient.produce(json, topic); diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java new file mode 100644 index 0000000000..c8ac500d96 --- /dev/null +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/BlockingMessagingEventConsumerTest.java @@ -0,0 +1,171 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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. + */ + +package org.kie.kogito.index.service.messaging; + +import java.net.URI; +import java.util.Arrays; +import java.util.Collection; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.kie.kogito.event.DataEvent; +import org.kie.kogito.event.process.MultipleProcessInstanceDataEvent; +import org.kie.kogito.event.process.ProcessDefinitionDataEvent; +import org.kie.kogito.event.process.ProcessInstanceDataEvent; +import org.kie.kogito.event.usertask.MultipleUserTaskInstanceDataEvent; +import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; +import org.kie.kogito.index.event.KogitoJobCloudEvent; +import org.kie.kogito.index.model.Job; +import org.kie.kogito.index.service.IndexingService; +import org.kie.kogito.index.storage.DataIndexStorageService; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; + +import jakarta.enterprise.event.Event; + +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +@Disabled +class BlockingMessagingEventConsumerTest { + + @Mock + DataIndexStorageService dataIndexStorageService; + + @Mock + IndexingService indexingService; + + @Mock + Event> eventPublisher; + + @InjectMocks + BlockingMessagingEventConsumer consumer; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + } + + @Test + void testOnProcessInstanceEvent() { + // Arrange + ProcessInstanceDataEvent event1 = mock(ProcessInstanceDataEvent.class); + ProcessInstanceDataEvent event2 = mock(ProcessInstanceDataEvent.class); + Collection> events = Arrays.asList(event1, event2); + MultipleProcessInstanceDataEvent event = new MultipleProcessInstanceDataEvent(URI.create("dummy"), events); + + // Act + consumer.onProcessInstanceEvent(event); + + // Assert + verify(indexingService, times(1)).indexProcessInstanceEvent(event); + verify(eventPublisher, times(1)).fire(event); + } + + @Test + void testOnUserTaskInstanceEvent() { + // Arrange + UserTaskInstanceDataEvent event1 = mock(UserTaskInstanceDataEvent.class); + UserTaskInstanceDataEvent event2 = mock(UserTaskInstanceDataEvent.class); + Collection> events = Arrays.asList(event1, event2); + MultipleUserTaskInstanceDataEvent event = new MultipleUserTaskInstanceDataEvent(URI.create("dummy"), events); + + // Act + consumer.onUserTaskInstanceEvent(event); + + // Assert + verify(indexingService, times(1)).indexUserTaskInstanceEvent(event); + verify(eventPublisher, times(1)).fire(event); + } + + @Test + void testOnJobEvent() { + // Arrange + KogitoJobCloudEvent event = mock(KogitoJobCloudEvent.class); + Job mockJob = mock(Job.class); // Mock the Job object + when(event.getData()).thenReturn(mockJob); + + // Act + consumer.onJobEvent(event); + + // Assert + verify(indexingService, times(1)).indexJob(mockJob); // Perform the verification after Uni completes + } + + @Test + void testOnProcessDefinitionDataEvent() { + // Arrange + ProcessDefinitionDataEvent event1 = mock(ProcessDefinitionDataEvent.class); + + // Act + consumer.onProcessDefinitionDataEvent(event1); + + // Assert + verify(indexingService, times(1)).indexProcessDefinition(event1); + verify(eventPublisher, times(1)).fire(event1); + } + + @Test + void testErrorHandlingInOnProcessInstanceEvent() { + // Arrange + ProcessInstanceDataEvent event = mock(ProcessInstanceDataEvent.class); + Collection> events = Arrays.asList(event); + doThrow(new RuntimeException("On purpose! Indexing failed")).when(indexingService).indexProcessInstanceEvent(event); + + // Act + consumer.onProcessInstanceEvent(new MultipleProcessInstanceDataEvent(URI.create("dummy"), events)); + + // Assert + verify(eventPublisher, never()).fire(event); // Event should not be published if indexing fails + } + + @Test + void testErrorHanlingInOnUserTaskInstanceEvent() { + // Arrange + UserTaskInstanceDataEvent event = mock(UserTaskInstanceDataEvent.class); + Collection> events = Arrays.asList(event); + doThrow(new RuntimeException("On purpose! Indexing failed")).when(indexingService).indexUserTaskInstanceEvent(event); + + // Act + consumer.onUserTaskInstanceEvent(new MultipleUserTaskInstanceDataEvent(URI.create("dummy"), events)); + + // Assert + verify(eventPublisher, never()).fire(event); // Event should not be published if indexing fails + + } + + @Test + void testErrorHandlingInOnProcessDefinitionDataEvent() { + // Arrange + ProcessDefinitionDataEvent event = mock(ProcessDefinitionDataEvent.class); + doThrow(new RuntimeException("On purpose! Indexing failed")).when(indexingService).indexProcessDefinition(event); + + // Act + consumer.onProcessDefinitionDataEvent(event); + + // Assert + verify(indexingService, times(1)).indexProcessDefinition(event); + verify(eventPublisher, never()).fire(event); + } +} diff --git a/data-index/data-index-service/data-index-service-common/src/test/resources/process_definition_11_event.json b/data-index/data-index-service/data-index-service-common/src/test/resources/process_definition_11_event.json new file mode 100644 index 0000000000..7c10ef36a1 --- /dev/null +++ b/data-index/data-index-service/data-index-service-common/src/test/resources/process_definition_11_event.json @@ -0,0 +1,162 @@ +{ + "id": "717af02d-645a-4b27-8058-b67ff1fa8edb", + "source": "http://localhost:8080/jsongreet", + "type": "ProcessDefinitionEvent", + "time": "2023-10-19T10:18:01.540311-03:00", + "data": { + "id": "jsongreet", + "name": "Greeting workflow", + "description": "JSON based greeting workflow", + "version": "1.1", + "type": "ProcessDefinitionEvent", + "roles": null, + "addons": [ + "source-files", + "cloudevents" + ], + "annotations": [ + "test2", + "test3", + "test1" + ], + "endpoint": "http://localhost:8080/jsongreet", + "source": null, + "metadata": { + "Description": "JSON based greeting workflow", + "annotations": [ + "test1", + "test2", + "test3" + ], + "Tags": [ + "test1", + "test2", + "test3" + ] + }, + "nodes": [ + { + "id": "1", + "name": "Start", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-12", + "metadata": { + "UniqueId": "_jbpm-unique-12", + "state": "ChooseOnLanguage" + } + }, + { + "id": "2", + "name": "End", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-13", + "metadata": { + "UniqueId": "_jbpm-unique-13", + "state": "GreetPerson" + } + }, + { + "id": "3", + "name": "ChooseOnLanguage", + "type": "INTERNAL", + "uniqueId": "3", + "metadata": { + "UniqueId": "3", + "Variable": "workflowdata", + "state": "ChooseOnLanguage", + "Default": "3_12" + } + }, + { + "id": "4", + "name": "GreetInEnglish", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-15", + "metadata": { + "UniqueId": "_jbpm-unique-15", + "state": "GreetInEnglish" + } + }, + { + "id": "5", + "name": "GreetInSpanish", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-16", + "metadata": { + "UniqueId": "_jbpm-unique-16", + "state": "GreetInSpanish" + } + }, + { + "id": "6", + "name": "GreetPerson", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-17", + "metadata": { + "UniqueId": "_jbpm-unique-17", + "state": "GreetPerson" + } + }, + { + "id": "7", + "name": "EmbeddedStart", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-18", + "metadata": { + "UniqueId": "_jbpm-unique-18" + } + }, + { + "id": "9", + "name": "greetFunction", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-19", + "metadata": { + "UniqueId": "_jbpm-unique-19", + "action": "greetAction", + "state": "GreetPerson" + } + }, + { + "id": "10", + "name": "Script", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-20", + "metadata": { + "UniqueId": "_jbpm-unique-20" + } + }, + { + "id": "11", + "name": "EmbeddedEnd", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-21", + "metadata": { + "UniqueId": "_jbpm-unique-21" + } + }, + { + "id": "12", + "name": "Join-GreetInEnglish", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-22", + "metadata": { + "UniqueId": "_jbpm-unique-22", + "state": "GreetInEnglish" + } + }, + { + "id": "13", + "name": "Join-GreetPerson", + "type": "INTERNAL", + "uniqueId": "_jbpm-unique-23", + "metadata": { + "UniqueId": "_jbpm-unique-23", + "state": "GreetPerson" + } + } + ] + }, + "specversion": "1.0", + "kogitoprocid": "jsongreet" +} \ No newline at end of file diff --git a/data-index/data-index-service/data-index-service-postgresql/src/test/resources/application.properties b/data-index/data-index-service/data-index-service-postgresql/src/test/resources/application.properties index 9c9f91f716..4911da58f2 100644 --- a/data-index/data-index-service/data-index-service-postgresql/src/test/resources/application.properties +++ b/data-index/data-index-service/data-index-service-postgresql/src/test/resources/application.properties @@ -17,6 +17,18 @@ # under the License. # +quarkus.log.console.enable=true +quarkus.log.console.level=INFO +quarkus.log.level=DEBUG +quarkus.log.category."org.kie.kogito".level=DEBUG +quarkus.log.category."org.kie.kogito".min-level=DEBUG +quarkus.log.category."io.vertx".level=DEBUG +quarkus.log.category."io.restassured".level=DEBUG +quarkus.log.category."graphql".level=DEBUG +quarkus.log.category."io.smallrye".level=DEBUG + + + #Data Index kogito.apps.persistence.type=postgresql kogito.data-index.domain-indexing=false From b1d78f2619d9d5ed258e9261b0e4934f0dda0329 Mon Sep 17 00:00:00 2001 From: Roberto Oliveira Date: Thu, 10 Oct 2024 12:48:15 -0400 Subject: [PATCH 3/3] NO-ISSUE: remove legacy productized-multi-repo-zip.xml file (#2112) --- persistence-commons/kogito-ddl/pom.xml | 13 ---- .../assembly/productized-multi-repo-zip.xml | 75 ------------------- 2 files changed, 88 deletions(-) delete mode 100644 persistence-commons/kogito-ddl/src/assembly/productized-multi-repo-zip.xml diff --git a/persistence-commons/kogito-ddl/pom.xml b/persistence-commons/kogito-ddl/pom.xml index ca095ec2fb..e8dbb6ae4a 100644 --- a/persistence-commons/kogito-ddl/pom.xml +++ b/persistence-commons/kogito-ddl/pom.xml @@ -72,17 +72,4 @@ - - - productized - - - productized - - - - src/assembly/productized-multi-repo-zip.xml - - - \ No newline at end of file diff --git a/persistence-commons/kogito-ddl/src/assembly/productized-multi-repo-zip.xml b/persistence-commons/kogito-ddl/src/assembly/productized-multi-repo-zip.xml deleted file mode 100644 index 4a590072c8..0000000000 --- a/persistence-commons/kogito-ddl/src/assembly/productized-multi-repo-zip.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - db-scripts - - zip - - false - - - true - . - - org.kie:kie-ddl-runtimes:zip:db-scripts - - - - - - - ${project.root.dir}/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql - postgresql/persistence-commons - - *.sql - - - - - - ${project.root.dir}/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql - postgresql/data-index - - *.sql - - - - - - ${project.root.dir}/data-audit/kogito-addons-data-audit-jpa/kogito-addons-data-audit-jpa-common/src/main/resources/kie-flyway/db/data-audit/postgresql - postgresql/data-audit - - *.sql - - - - - - ${project.root.dir}/jobs-service/jobs-service-postgresql-common/src/main/resources/kie-flyway/db/jobs-service/postgresql - postgresql/jobs-service - - *.sql - - - -