This is an automated email from the ASF dual-hosted git repository.

fjtiradosarti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-apps.git


The following commit(s) were added to refs/heads/main by this push:
     new 56fd4b26a [kie-issues#2287] Add integration test for variables query 
(#2289)
56fd4b26a is described below

commit 56fd4b26a814bed64fd6f250b0462a19f2477bd4
Author: Gonzalo Muñoz <[email protected]>
AuthorDate: Thu Jan 8 13:29:40 2026 +0100

    [kie-issues#2287] Add integration test for variables query (#2289)
---
 .../kogito/index/AbstractProcessDataIndexIT.java   |   2 +-
 .../AbstractProcessDataIndexPostgreSqlIT.java      |  22 ++++
 .../query/VariablesAndMetadataJsonIT.java          | 112 +++++++++++++++++++++
 3 files changed, 135 insertions(+), 1 deletion(-)

diff --git 
a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-common/src/test/java/org/kie/kogito/index/AbstractProcessDataIndexIT.java
 
b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-common/src/test/java/org/kie/kogito/index/AbstractProcessDataIndexIT.java
index 8bf51d5bf..90abdd4c5 100644
--- 
a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-common/src/test/java/org/kie/kogito/index/AbstractProcessDataIndexIT.java
+++ 
b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-common/src/test/java/org/kie/kogito/index/AbstractProcessDataIndexIT.java
@@ -57,7 +57,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public abstract class AbstractProcessDataIndexIT {
 
-    private static Duration TIMEOUT = Duration.ofSeconds(30);
+    protected static Duration TIMEOUT = Duration.ofSeconds(30);
 
     static {
         RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
diff --git 
a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/postgresql/AbstractProcessDataIndexPostgreSqlIT.java
 
b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/postgresql/AbstractProcessDataIndexPostgreSqlIT.java
index d0e8c41a8..003df6326 100644
--- 
a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/postgresql/AbstractProcessDataIndexPostgreSqlIT.java
+++ 
b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/postgresql/AbstractProcessDataIndexPostgreSqlIT.java
@@ -18,9 +18,16 @@
  */
 package org.kie.kogito.index.postgresql;
 
+import org.junit.jupiter.api.Test;
 import org.kie.kogito.index.AbstractProcessDataIndexIT;
 import org.kie.kogito.test.quarkus.QuarkusTestProperty;
 
+import io.restassured.http.ContentType;
+
+import static io.restassured.RestAssured.given;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
 import static 
org.kie.kogito.index.test.Constants.KOGITO_DATA_INDEX_SERVICE_URL;
 
 public abstract class AbstractProcessDataIndexPostgreSqlIT extends 
AbstractProcessDataIndexIT {
@@ -42,4 +49,19 @@ public abstract class AbstractProcessDataIndexPostgreSqlIT 
extends AbstractProce
     public boolean validateGetProcessInstanceSource() {
         return true;
     }
+
+    @Test
+    public void testJsonQueryVariablesAndMetadata() throws Exception {
+        String pId = createTestProcessInstance();
+
+        await().atMost(TIMEOUT).untilAsserted(() -> 
given().spec(dataIndexSpec())
+                .contentType(ContentType.JSON)
+                .body("{ \"query\": \"{ ProcessInstances(where: { id: { equal: 
\\\"" + pId + "\\\" } }) { id variables state } }\" }")
+                .when().post("/graphql")
+                .then().statusCode(200)
+                .body("data.ProcessInstances[0].id", containsString(pId))
+                
.body("data.ProcessInstances[0].variables.traveller.firstName", 
containsString("Darth"))
+                .body("data.ProcessInstances[0].state", is("ACTIVE")));
+    }
+
 }
diff --git 
a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/VariablesAndMetadataJsonIT.java
 
b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/VariablesAndMetadataJsonIT.java
new file mode 100644
index 000000000..d767c5f35
--- /dev/null
+++ 
b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/VariablesAndMetadataJsonIT.java
@@ -0,0 +1,112 @@
+/*
+ * 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.postgresql.query;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.junit.jupiter.api.Test;
+import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent;
+import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage;
+import org.kie.kogito.index.model.ProcessDefinition;
+import org.kie.kogito.index.model.ProcessDefinitionKey;
+import org.kie.kogito.index.model.ProcessInstance;
+import org.kie.kogito.index.storage.ProcessInstanceStorage;
+import org.kie.kogito.index.test.TestUtils;
+import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import io.quarkus.test.common.QuarkusTestResource;
+import io.quarkus.test.junit.QuarkusTest;
+
+import jakarta.inject.Inject;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@QuarkusTest
+@QuarkusTestResource(PostgreSqlQuarkusTestResource.class)
+class VariablesAndMetadataJsonIT {
+
+    @Inject
+    ProcessInstanceStorage storage;
+
+    @Inject
+    ProcessDefinitionEntityStorage definitionStorage;
+
+    @Test
+    void shouldStoreAndRetrieveVariablesAndMetadataWithPostgresJson() {
+        String processId = "json.process";
+        String processInstanceId = UUID.randomUUID().toString();
+
+        final String version = "1.0";
+        ProcessDefinitionKey key = new ProcessDefinitionKey(processId, 
version);
+        ProcessDefinition definitionEvent = 
TestUtils.createProcessDefinition(processId, version, Set.of());
+        definitionEvent.setAnnotations(Set.of("TestAnnotation"));
+        definitionEvent.setMetadata(Map.of(
+                "name", "TestProcess",
+                "type", "demo",
+                "owner", "pepe"));
+        definitionStorage.put(key, definitionEvent);
+
+        ProcessInstanceVariableDataEvent variableEvent =
+                TestUtils.createProcessInstanceVariableEvent(
+                        processInstanceId,
+                        processId,
+                        "John",
+                        28,
+                        false,
+                        List.of("A", "B"));
+        variableEvent.setKogitoProcessInstanceVersion(version);
+
+        storage.indexVariable(variableEvent);
+
+        ProcessInstance result = storage.get(processInstanceId);
+        assertThat(result).isNotNull();
+
+        JsonNode variablesNode = result.getVariables();
+        assertThat(variablesNode).isNotNull();
+        assertThat(variablesNode.has("traveller")).isTrue();
+
+        JsonNode travellerNode = variablesNode.get("traveller");
+        assertThat(travellerNode.get("name").asText()).isEqualTo("John");
+        assertThat(travellerNode.get("age").asInt()).isEqualTo(28);
+        assertThat(travellerNode.get("isMartian").asBoolean()).isFalse();
+
+        JsonNode aliasesNode = travellerNode.get("aliases");
+        assertThat(aliasesNode.isArray()).isTrue();
+        assertThat(aliasesNode).hasSize(2);
+        assertThat(aliasesNode.get(0).asText()).isEqualTo("A");
+        assertThat(aliasesNode.get(1).asText()).isEqualTo("B");
+
+        ProcessDefinition storedDefinition = definitionStorage.get(key);
+        assertThat(storedDefinition).isNotNull();
+
+        Map<String, Object> metadata = storedDefinition.getMetadata();
+        assertThat(metadata).isNotNull();
+        assertThat(metadata).containsEntry("name", "TestProcess");
+        assertThat(metadata).containsEntry("type", "demo");
+        assertThat(metadata).containsEntry("owner", "pepe");
+
+        Set<String> annotations = storedDefinition.getAnnotations();
+        assertThat(annotations).contains("TestAnnotation");
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to