From ebb5fcce310d48992b51f609a9b7e6ff4ec22d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Fern=C3=A1ndez?= Date: Wed, 6 Nov 2024 16:09:30 +0100 Subject: [PATCH] [incubator-kie-issues#1607] Fix JPA mappings for PostgresQL jsonb columns. (#2140) --- .../org/kie/kogito/index/test/TestUtils.java | 144 ++++++++++- .../AbstractProcessInstanceStorageIT.java | 149 ++++++++++- .../AbstractUserTaskInstanceStorageIT.java | 233 +++++++++++++++++- .../data-index-storage-jpa/pom.xml | 7 +- .../src/main/resources/META-INF/orm.xml | 34 --- .../ansi/V1.33.0__data_index_create.sql | 6 +- .../ansi/V1.44.0__data_index_definitions.sql | 24 +- ...V1.45.0.0__data_index_node_definitions.sql | 22 +- ...0.2__data_index_definitions_add_colums.sql | 14 +- .../index/jdbc/H2QuarkusTestProfile.java | 30 +++ .../jdbc/PostgreSQLQuarkusTestProfile.java | 30 +++ ...tyQueryIT.java => H2JobEntityQueryIT.java} | 9 +- ... => H2ProcessDefinitionEntityQueryIT.java} | 9 +- ...va => H2ProcessInstanceEntityQueryIT.java} | 9 +- ...a => H2UserTaskInstanceEntityQueryIT.java} | 9 +- .../query/PostgreSQLJobEntityQueryIT.java | 36 +++ ...tgreSQLProcessDefinitionEntityQueryIT.java | 36 +++ ...ostgreSQLProcessInstanceEntityQueryIT.java | 40 +++ ...stgreSQLUserTaskInstanceEntityQueryIT.java | 36 +++ ...{JobStorageIT.java => H2JobStorageIT.java} | 10 +- ...java => H2ProcessDefinitionStorageIT.java} | 10 +- ...T.java => H2ProcessInstanceStorageIT.java} | 10 +- ....java => H2UserTaskInstanceStorageIT.java} | 10 +- .../jdbc/storage/PostgreSQLJobStorageIT.java | 36 +++ .../PostgreSQLProcessDefinitionStorageIT.java | 36 +++ .../PostgreSQLProcessInstanceStorageIT.java | 35 +++ .../PostgreSQLUserTaskInstanceStorageIT.java | 35 +++ .../src/test/resources/application.properties | 14 +- .../storage/ProcessInstanceStorageIT.java | 2 + .../src/test/resources/application.properties | 3 +- .../jpa/converter/JsonBinaryConverter.java | 8 +- .../src/main/resources/application.properties | 0 .../ansi/V2.0.0__Create_Tables.sql | 4 +- .../src/main/resources/application.properties | 20 ++ ...__kogito_apps_create_kogito_data_cache.sql | 2 +- 35 files changed, 986 insertions(+), 126 deletions(-) delete mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/H2QuarkusTestProfile.java create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/PostgreSQLQuarkusTestProfile.java rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/{JobEntityQueryIT.java => H2JobEntityQueryIT.java} (75%) rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/{ProcessDefinitionEntityQueryIT.java => H2ProcessDefinitionEntityQueryIT.java} (74%) rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/{ProcessInstanceEntityQueryIT.java => H2ProcessInstanceEntityQueryIT.java} (75%) rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/{UserTaskInstanceEntityQueryIT.java => H2UserTaskInstanceEntityQueryIT.java} (74%) create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLJobEntityQueryIT.java create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessDefinitionEntityQueryIT.java create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessInstanceEntityQueryIT.java create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLUserTaskInstanceEntityQueryIT.java rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/{JobStorageIT.java => H2JobStorageIT.java} (79%) rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/{ProcessDefinitionStorageIT.java => H2ProcessDefinitionStorageIT.java} (78%) rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/{ProcessInstanceStorageIT.java => H2ProcessInstanceStorageIT.java} (77%) rename data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/{UserTaskInstanceStorageIT.java => H2UserTaskInstanceStorageIT.java} (77%) create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLJobStorageIT.java create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessDefinitionStorageIT.java create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessInstanceStorageIT.java create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLUserTaskInstanceStorageIT.java rename {persistence-commons/persistence-commons-postgresql => jobs-service/jobs-service-storage-jpa}/src/main/resources/application.properties (100%) create mode 100644 persistence-commons/persistence-commons-jpa-base/src/main/resources/application.properties diff --git a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java index 57c05f0498..59ee7601a0 100644 --- a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java +++ b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/TestUtils.java @@ -18,21 +18,16 @@ */ package org.kie.kogito.index.test; +import java.net.URI; import java.time.Instant; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import org.apache.commons.lang3.RandomStringUtils; -import org.kie.kogito.event.process.ProcessInstanceStateDataEvent; -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.process.*; +import org.kie.kogito.event.usertask.*; import org.kie.kogito.index.model.Attachment; import org.kie.kogito.index.model.Comment; import org.kie.kogito.index.model.Job; @@ -88,6 +83,137 @@ public static ProcessInstanceVariableDataEvent createProcessInstanceVariableEven return event; } + public static ProcessInstanceNodeDataEvent createProcessInstanceNodeDataEvent(String processInstance, String processId, String nodeDefinitionId, String nodeInstanceId, String nodeName, + String nodeType, int eventType) { + + ProcessInstanceNodeEventBody body = ProcessInstanceNodeEventBody.create() + .processId(processId) + .processInstanceId(processInstance) + .nodeDefinitionId(nodeDefinitionId) + .nodeInstanceId(nodeInstanceId) + .nodeName(nodeName) + .nodeType(nodeType) + .eventDate(new Date()) + .eventType(eventType) + .build(); + + ProcessInstanceNodeDataEvent event = new ProcessInstanceNodeDataEvent(); + event.setKogitoProcessId(processId); + event.setKogitoProcessInstanceId(processInstance); + event.setData(body); + + return event; + } + + public static ProcessInstanceErrorDataEvent createProcessInstanceErrorDataEvent(String processInstance, String processId, String userId, String errorMessage, String nodeDefinitionId, + String nodeInstanceId) { + ProcessInstanceErrorEventBody body = ProcessInstanceErrorEventBody.create() + .eventDate(new Date()) + .eventUser(userId) + .processId(processId) + .processInstanceId(processInstance) + .errorMessage(errorMessage) + .nodeDefinitionId(nodeDefinitionId) + .nodeInstanceId(nodeInstanceId) + .build(); + + ProcessInstanceErrorDataEvent event = new ProcessInstanceErrorDataEvent(); + event.setKogitoProcessInstanceId(processInstance); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceStateDataEvent createUserTaskStateEvent(String taskId, String taskName, String processInstanceId, String processId, String state) { + UserTaskInstanceStateEventBody body = UserTaskInstanceStateEventBody.create() + .userTaskInstanceId(taskId) + .userTaskName(taskName) + .state(state) + .processInstanceId(processInstanceId) + .build(); + + UserTaskInstanceStateDataEvent event = new UserTaskInstanceStateDataEvent(); + + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + + event.setData(body); + + return event; + } + + public static UserTaskInstanceCommentDataEvent createUserTaskCommentEvent(String taskId, String processInstanceId, String processId, String commentId, String comment, String userId, + int eventType) { + + UserTaskInstanceCommentEventBody body = UserTaskInstanceCommentEventBody.create() + .commentId(commentId) + .eventUser(userId) + .commentContent(comment) + .eventDate(new Date()) + .eventType(eventType) + .userTaskInstanceId(taskId) + .build(); + + UserTaskInstanceCommentDataEvent event = new UserTaskInstanceCommentDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceAttachmentDataEvent createUserTaskAttachmentEvent(String taskId, String processInstanceId, String processId, String attachmentId, String attachmentName, + URI attachmentURI, String userId, int eventType) { + + UserTaskInstanceAttachmentEventBody body = UserTaskInstanceAttachmentEventBody.create() + .attachmentId(attachmentId) + .eventUser(userId) + .attachmentName(attachmentName) + .attachmentURI(attachmentURI) + .eventDate(new Date()) + .eventType(eventType) + .userTaskInstanceId(taskId) + .build(); + + UserTaskInstanceAttachmentDataEvent event = new UserTaskInstanceAttachmentDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceAssignmentDataEvent createUserTaskAssignmentEvent(String taskId, String processInstanceId, String processId, String assignmentType, String... users) { + UserTaskInstanceAssignmentEventBody body = UserTaskInstanceAssignmentEventBody.create() + .users(users) + .assignmentType(assignmentType) + .build(); + + UserTaskInstanceAssignmentDataEvent event = new UserTaskInstanceAssignmentDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + + public static UserTaskInstanceVariableDataEvent createUserTaskVariableEvent(String taskId, String processInstanceId, String processId, String variableName, Object variableValue, + String variableType) { + UserTaskInstanceVariableEventBody body = UserTaskInstanceVariableEventBody.create() + .variableName(variableName) + .variableValue(variableValue) + .variableType(variableType) + .build(); + + UserTaskInstanceVariableDataEvent event = new UserTaskInstanceVariableDataEvent(); + event.setKogitoUserTaskInstanceId(taskId); + event.setKogitoProcessInstanceId(processInstanceId); + event.setKogitoProcessId(processId); + event.setData(body); + return event; + } + public static ProcessInstance createProcessInstance(String processInstanceId, String processId, String rootProcessInstanceId, diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java index 1ea09ce497..b60f7ed300 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java @@ -20,29 +20,158 @@ import java.util.UUID; -import org.apache.commons.lang3.RandomStringUtils; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.model.ProcessInstanceEntityRepository; +import org.kie.kogito.event.process.ProcessInstanceNodeEventBody; +import org.kie.kogito.index.model.ProcessInstance; import org.kie.kogito.index.model.ProcessInstanceState; import org.kie.kogito.index.test.TestUtils; import jakarta.inject.Inject; +import jakarta.transaction.Transactional; public abstract class AbstractProcessInstanceStorageIT { + private static final String PROCESS_ID = "travels"; + private static final String TRAVELER_NAME = "John"; + private static final String TRAVELER_LAST_NAME = "Doe"; @Inject - ProcessInstanceEntityRepository repository; + ProcessInstanceEntityStorage storage; @Test - public void testProcessInstanceEntity() { + @Transactional + public void testProcessInstanceStateEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + Assertions.assertThat(processInstance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("state", ProcessInstanceState.ACTIVE.ordinal()) + .hasFieldOrPropertyWithValue("rootProcessInstanceId", null) + .hasFieldOrPropertyWithValue("rootProcessId", null) + .hasFieldOrPropertyWithValue("variables", null); + + storage.indexState(TestUtils.createProcessInstanceEvent(processInstanceId, PROCESS_ID, null, null, ProcessInstanceState.COMPLETED.ordinal())); + + processInstance = storage.get(processInstanceId); + Assertions.assertThat(processInstance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("state", ProcessInstanceState.COMPLETED.ordinal()) + .hasFieldOrPropertyWithValue("rootProcessInstanceId", null) + .hasFieldOrPropertyWithValue("rootProcessId", null) + .hasFieldOrPropertyWithValue("variables", null); + } + + @Test + @Transactional + public void testProcessInstanceErrorEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getError()) + .isNull(); + + String nodeDefinitionId = UUID.randomUUID().toString(); + storage.indexError(TestUtils.createProcessInstanceErrorDataEvent(processInstanceId, PROCESS_ID, TRAVELER_NAME, "This is really wrong", nodeDefinitionId, UUID.randomUUID().toString())); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getError()) + .isNotNull() + .hasFieldOrPropertyWithValue("nodeDefinitionId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("message", "This is really wrong"); + } + + @Test + @Transactional + public void testProcessInstanceNodeEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getNodes()) + .isEmpty(); + + String nodeDefinitionId = UUID.randomUUID().toString(); + String nodeInstanceId = UUID.randomUUID().toString(); + + storage.indexNode(TestUtils.createProcessInstanceNodeDataEvent(processInstanceId, PROCESS_ID, nodeDefinitionId, nodeInstanceId, "nodeName", "BoundaryEventNode", + ProcessInstanceNodeEventBody.EVENT_TYPE_ENTER)); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getNodes()) + .hasSize(1); + + Assertions.assertThat(processInstance.getNodes().get(0)) + .hasNoNullFieldsOrPropertiesExcept("exit") + .hasFieldOrPropertyWithValue("name", "nodeName") + .hasFieldOrPropertyWithValue("type", "BoundaryEventNode") + .hasFieldOrPropertyWithValue("definitionId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("nodeId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("id", nodeInstanceId); + + storage.indexNode(TestUtils.createProcessInstanceNodeDataEvent(processInstanceId, PROCESS_ID, nodeDefinitionId, nodeInstanceId, "nodeName", "BoundaryEventNode", + ProcessInstanceNodeEventBody.EVENT_TYPE_EXIT)); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getNodes()) + .hasSize(1); + + Assertions.assertThat(processInstance.getNodes().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("name", "nodeName") + .hasFieldOrPropertyWithValue("type", "BoundaryEventNode") + .hasFieldOrPropertyWithValue("definitionId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("nodeId", nodeDefinitionId) + .hasFieldOrPropertyWithValue("id", nodeInstanceId); + } + + @Test + @Transactional + public void testProcessInstanceVariableEvent() { + String processInstanceId = createNewProcessInstance(); + + ProcessInstance processInstance = storage.get(processInstanceId); + + Assertions.assertThat(processInstance.getVariables()) + .isNull(); + + storage.indexVariable(TestUtils.createProcessInstanceVariableEvent(processInstanceId, PROCESS_ID, TRAVELER_NAME, TRAVELER_LAST_NAME)); + + processInstance = storage.get(processInstanceId); + + Assertions.assertThatObject(processInstance.getVariables()) + .isNotNull() + .extracting(jsonNodes -> jsonNodes.at("/traveller/firstName").asText(), jsonNodes -> jsonNodes.at("/traveller/lastName").asText()) + .contains(TRAVELER_NAME, TRAVELER_LAST_NAME); + } + + private String createNewProcessInstance() { String processInstanceId = UUID.randomUUID().toString(); - TestUtils - .createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.ACTIVE.ordinal(), 0L); - TestUtils - .createProcessInstance(processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), ProcessInstanceState.COMPLETED.ordinal(), 1000L); + Assertions.assertThat(storage.get(processInstanceId)) + .isNull(); + + storage.indexState(TestUtils.createProcessInstanceEvent(processInstanceId, PROCESS_ID, null, null, ProcessInstanceState.ACTIVE.ordinal())); + + ProcessInstance processInstance = storage.get(processInstanceId); + Assertions.assertThat(processInstance) + .isNotNull() + .hasFieldOrPropertyWithValue("id", processInstanceId) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("state", ProcessInstanceState.ACTIVE.ordinal()) + .hasFieldOrPropertyWithValue("rootProcessInstanceId", null) + .hasFieldOrPropertyWithValue("rootProcessId", null) + .hasFieldOrPropertyWithValue("variables", null); + + return processInstanceId; } } diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java index 9b8c0056c9..d44d534955 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java @@ -18,19 +18,226 @@ */ package org.kie.kogito.index.jpa.storage; -import java.util.UUID; +import java.net.URI; +import java.util.*; import org.apache.commons.lang3.RandomStringUtils; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; +import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentEventBody; +import org.kie.kogito.index.jpa.model.UserTaskInstanceEntity; import org.kie.kogito.index.jpa.model.UserTaskInstanceEntityRepository; +import org.kie.kogito.index.model.UserTaskInstance; +import org.kie.kogito.index.storage.UserTaskInstanceStorage; import org.kie.kogito.index.test.TestUtils; import jakarta.inject.Inject; +import jakarta.transaction.Transactional; public abstract class AbstractUserTaskInstanceStorageIT { + private static final String PROCESS_INSTANCE_ID = "87daz3446-2386-4056-91dc-dbc3804d157c"; + private static final String PROCESS_ID = "travels"; + private static final String TASK_NAME = "HR Interview"; + + @Inject + UserTaskInstanceStorage storage; + @Inject - UserTaskInstanceEntityRepository repository; + UserTaskInstanceEntityRepository userTaskInstanceRepository; + + @Test + @Transactional + public void testUserTaskStateEvent() { + String taskId = createUserTaskInstance(); + + storage.indexState(TestUtils.createUserTaskStateEvent(taskId, TASK_NAME, PROCESS_INSTANCE_ID, PROCESS_ID, "Completed")); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task) + .isNotNull() + .hasFieldOrPropertyWithValue("id", taskId) + .hasFieldOrPropertyWithValue("name", TASK_NAME) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("processInstanceId", PROCESS_INSTANCE_ID) + .hasFieldOrPropertyWithValue("state", "Completed"); + } + + @Test + @Transactional + public void testUserTaskAssignmentEvents() { + + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task) + .hasFieldOrPropertyWithValue("potentialUsers", null) + .hasFieldOrPropertyWithValue("potentialGroups", null) + .hasFieldOrPropertyWithValue("adminGroups", null) + .hasFieldOrPropertyWithValue("adminUsers", null) + .hasFieldOrPropertyWithValue("excludedUsers", null); + + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "USER_OWNERS", "John")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "USER_GROUPS", "user-group")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "ADMIN_GROUPS", "administrators")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "ADMIN_USERS", "super-user")); + storage.indexAssignment(TestUtils.createUserTaskAssignmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "USERS_EXCLUDED", "excluded-user")); + + task = storage.get(taskId); + + Assertions.assertThat(task.getPotentialUsers()) + .containsExactly("John"); + Assertions.assertThat(task.getPotentialGroups()) + .containsExactly("user-group"); + Assertions.assertThat(task.getAdminGroups()) + .containsExactly("administrators"); + Assertions.assertThat(task.getAdminUsers()) + .containsExactly("super-user"); + Assertions.assertThat(task.getExcludedUsers()) + .containsExactly("excluded-user"); + } + + @Transactional + @Test + public void testUserTaskVariableEvents() { + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task.getInputs()) + .isNull(); + Assertions.assertThat(task.getOutputs()) + .isNull(); + + Map person = new HashMap<>(); + person.put("firstName", "John"); + person.put("lastName", "Doe"); + + storage.indexVariable(TestUtils.createUserTaskVariableEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "person", person, "INPUT")); + + task = storage.get(taskId); + + Assertions.assertThatObject(task.getInputs()) + .isNotNull() + .extracting(jsonNodes -> jsonNodes.at("/person/firstName").asText(), jsonNodes -> jsonNodes.at("/person/lastName").asText()) + .contains("John", "Doe"); + + Assertions.assertThat(task.getOutputs()) + .isNull(); + + person = new HashMap<>(); + person.put("age", 50); + person.put("married", true); + + storage.indexVariable(TestUtils.createUserTaskVariableEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, "person", person, "OUTPUT")); + + task = storage.get(taskId); + + Assertions.assertThatObject(task.getOutputs()) + .isNotNull() + .extracting(jsonNodes -> jsonNodes.at("/person/age").asInt(), jsonNodes -> jsonNodes.at("/person/married").asBoolean()) + .contains(50, true); + } + + @Transactional + @Test + public void testUserTaskCommentEvents() { + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .isEmpty(); + + String commentId = UUID.randomUUID().toString(); + storage.indexComment( + TestUtils.createUserTaskCommentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, commentId, "this is a comment", "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_ADDED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .hasSize(1); + + Assertions.assertThat(task.getComments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", commentId) + .hasFieldOrPropertyWithValue("content", "this is a comment") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexComment( + TestUtils.createUserTaskCommentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, commentId, "this is an updated comment", "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_CHANGE)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .hasSize(1); + + Assertions.assertThat(task.getComments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", commentId) + .hasFieldOrPropertyWithValue("content", "this is an updated comment") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexComment( + TestUtils.createUserTaskCommentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, commentId, "this is an updated comment", "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_DELETED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getComments()) + .hasSize(0); + } + + @Transactional + @Test + public void testUserTaskAttachmentEvents() { + String taskId = createUserTaskInstance(); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .isEmpty(); + + String attachmentId = UUID.randomUUID().toString(); + storage.indexAttachment(TestUtils.createUserTaskAttachmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, attachmentId, "Attachment-1", URI.create("http://localhost:8080/my-doc.txt"), "John", + UserTaskInstanceAttachmentEventBody.EVENT_TYPE_ADDED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .hasSize(1); + + Assertions.assertThat(task.getAttachments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", attachmentId) + .hasFieldOrPropertyWithValue("name", "Attachment-1") + .hasFieldOrPropertyWithValue("content", "http://localhost:8080/my-doc.txt") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexAttachment(TestUtils.createUserTaskAttachmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, attachmentId, "Attachment-1.2", URI.create("http://localhost:8080/my-doc2.txt"), + "John", UserTaskInstanceAttachmentEventBody.EVENT_TYPE_CHANGE)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .hasSize(1); + + Assertions.assertThat(task.getAttachments().get(0)) + .hasNoNullFieldsOrProperties() + .hasFieldOrPropertyWithValue("id", attachmentId) + .hasFieldOrPropertyWithValue("name", "Attachment-1.2") + .hasFieldOrPropertyWithValue("content", "http://localhost:8080/my-doc2.txt") + .hasFieldOrPropertyWithValue("updatedBy", "John"); + + storage.indexAttachment(TestUtils.createUserTaskAttachmentEvent(taskId, PROCESS_INSTANCE_ID, PROCESS_ID, attachmentId, "Attachment-1", URI.create("http://localhost:8080/my-doc2.txt"), "John", + UserTaskInstanceAttachmentEventBody.EVENT_TYPE_DELETED)); + + task = storage.get(taskId); + + Assertions.assertThat(task.getAttachments()) + .hasSize(0); + } @Test public void testUserTaskInstanceEntity() { @@ -46,4 +253,26 @@ public void testUserTaskInstanceEntity() { RandomStringUtils.randomAlphabetic(10), "Completed", 1000L); } + private String createUserTaskInstance() { + String taskId = UUID.randomUUID().toString(); + + storage.indexState(TestUtils.createUserTaskStateEvent(taskId, TASK_NAME, PROCESS_INSTANCE_ID, PROCESS_ID, "InProgress")); + + UserTaskInstance task = storage.get(taskId); + + Assertions.assertThat(task) + .isNotNull() + .hasFieldOrPropertyWithValue("id", taskId) + .hasFieldOrPropertyWithValue("name", TASK_NAME) + .hasFieldOrPropertyWithValue("processId", PROCESS_ID) + .hasFieldOrPropertyWithValue("processInstanceId", PROCESS_INSTANCE_ID) + .hasFieldOrPropertyWithValue("state", "InProgress"); + + // Initializing comments and attachments just for the test + UserTaskInstanceEntity taskInstanceEntity = userTaskInstanceRepository.findById(taskId); + taskInstanceEntity.setComments(new ArrayList<>()); + taskInstanceEntity.setAttachments(new ArrayList<>()); + + return taskId; + } } 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 393cc0901d..7db734cf5e 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 @@ -38,7 +38,7 @@ 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.index.jpa @@ -60,6 +60,11 @@ quarkus-test-h2 test + + io.quarkus + quarkus-jdbc-postgresql + test + org.kie.kogito data-index-storage-api diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml deleted file mode 100644 index 2e9789c752..0000000000 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql index 564a9c72e9..3aa01f1e84 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.33.0__data_index_create.sql @@ -98,7 +98,7 @@ create table processes root_process_instance_id varchar(255), start_time timestamp, state integer, - variables varbinary(max), + variables varchar(max), CONSTRAINT processes_pk PRIMARY KEY (id), CONSTRAINT processes_variables_json CHECK (variables IS JSON) ); @@ -124,10 +124,10 @@ create table tasks completed timestamp, description varchar(255), endpoint varchar(255), - inputs varbinary(max), + inputs varchar(max), last_update timestamp, name varchar(255), - outputs varbinary(max), + outputs varchar(max), priority varchar(255), process_id varchar(255), process_instance_id varchar(255), diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql index 4f361d57c1..2dbdee38e1 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.44.0__data_index_definitions.sql @@ -19,28 +19,28 @@ create table definitions ( - id varchar2(255) not null, - version varchar2(255) not null, - name varchar2(255), + id varchar(255) not null, + version varchar(255) not null, + name varchar(255), source bytea, - type varchar2(255), - endpoint varchar2(255), + type varchar(255), + endpoint varchar(255), primary key (id, version) ); create table definitions_addons ( - process_id varchar2(255) not null, - process_version varchar2(255) not null, - addon varchar2(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + addon varchar(255) not null, primary key (process_id, process_version, addon) ); create table definitions_roles ( - process_id varchar2(255) not null, - process_version varchar2(255) not null, - role varchar2(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + role varchar(255) not null, primary key (process_id, process_version, role) ); @@ -57,4 +57,4 @@ alter table definitions_roles on delete cascade; alter table processes - add column version varchar2(255); \ No newline at end of file + add column version varchar(255); \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql index 7bce973a34..e318e7d5f8 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.0__data_index_node_definitions.sql @@ -19,22 +19,22 @@ create table definitions_nodes ( - id varchar2(255) not null, - name varchar2(255), - type varchar2(255), - unique_id varchar2(255), - process_id varchar2(255) not null, - process_version varchar2(255) not null, + id varchar(255) not null, + name varchar(255), + type varchar(255), + unique_id varchar(255), + process_id varchar(255) not null, + process_version varchar(255) not null, primary key (id, process_id, process_version) ); create table definitions_nodes_metadata ( - node_id varchar2(255) not null, - process_id varchar2(255) not null, - process_version varchar2(255) not null, - value varchar2(255), - key varchar2(255) not null, + node_id varchar(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + value varchar(255), + key varchar(255) not null, primary key (node_id, process_id, process_version, key) ); diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql index 8abae1b55a..30dad9ca80 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.2__data_index_definitions_add_colums.sql @@ -19,18 +19,18 @@ create table definitions_annotations ( - value varchar2(255) not null, - process_id varchar2(255) not null, - process_version varchar2(255) not null, + value varchar(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, primary key (value, process_id, process_version) ); create table definitions_metadata ( - process_id varchar2(255) not null, - process_version varchar2(255) not null, - value varchar2(255), - key varchar2(255) not null, + process_id varchar(255) not null, + process_version varchar(255) not null, + value varchar(255), + key varchar(255) not null, primary key (process_id, process_version, key) ); diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/H2QuarkusTestProfile.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/H2QuarkusTestProfile.java new file mode 100644 index 0000000000..b42ab3699d --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/H2QuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * 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.jdbc; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class H2QuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-h2"; + } +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/PostgreSQLQuarkusTestProfile.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/PostgreSQLQuarkusTestProfile.java new file mode 100644 index 0000000000..4445c0f4ff --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/PostgreSQLQuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * 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.jdbc; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class PostgreSQLQuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-postgresql"; + } +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/JobEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2JobEntityQueryIT.java similarity index 75% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/JobEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2JobEntityQueryIT.java index a99c7eeabd..88aa60b863 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/JobEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2JobEntityQueryIT.java @@ -18,14 +18,19 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractJobEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class JobEntityQueryIT extends AbstractJobEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2JobEntityQueryIT extends AbstractJobEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessDefinitionEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessDefinitionEntityQueryIT.java similarity index 74% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessDefinitionEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessDefinitionEntityQueryIT.java index c99803b83a..704c46164b 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessDefinitionEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessDefinitionEntityQueryIT.java @@ -18,14 +18,19 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractProcessDefinitionEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class ProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2ProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessInstanceEntityQueryIT.java similarity index 75% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessInstanceEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessInstanceEntityQueryIT.java index 10bd679b53..c68e22d9d0 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2ProcessInstanceEntityQueryIT.java @@ -18,15 +18,20 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractProcessInstanceEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class ProcessInstanceEntityQueryIT extends AbstractProcessInstanceEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2ProcessInstanceEntityQueryIT extends AbstractProcessInstanceEntityQueryIT { @Override protected Boolean isDateTimeAsLong() { diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2UserTaskInstanceEntityQueryIT.java similarity index 74% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2UserTaskInstanceEntityQueryIT.java index abaffc8741..79e6ea184b 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/H2UserTaskInstanceEntityQueryIT.java @@ -18,14 +18,19 @@ */ package org.kie.kogito.index.jdbc.query; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.query.AbstractUserTaskInstanceEntityQueryIT; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class UserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceEntityQueryIT { +@TestTransaction +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2UserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLJobEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLJobEntityQueryIT.java new file mode 100644 index 0000000000..049b7596de --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLJobEntityQueryIT.java @@ -0,0 +1,36 @@ +/* + * 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.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractJobEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLJobEntityQueryIT extends AbstractJobEntityQueryIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessDefinitionEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessDefinitionEntityQueryIT.java new file mode 100644 index 0000000000..55d756025d --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessDefinitionEntityQueryIT.java @@ -0,0 +1,36 @@ +/* + * 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.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractProcessDefinitionEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionEntityQueryIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessInstanceEntityQueryIT.java new file mode 100644 index 0000000000..13fddcf9c0 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLProcessInstanceEntityQueryIT.java @@ -0,0 +1,40 @@ +/* + * 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.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractProcessInstanceEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLProcessInstanceEntityQueryIT extends AbstractProcessInstanceEntityQueryIT { + + @Override + protected Boolean isDateTimeAsLong() { + return false; + } +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLUserTaskInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLUserTaskInstanceEntityQueryIT.java new file mode 100644 index 0000000000..1574f3833c --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/PostgreSQLUserTaskInstanceEntityQueryIT.java @@ -0,0 +1,36 @@ +/* + * 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.jdbc.query; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.query.AbstractUserTaskInstanceEntityQueryIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLUserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceEntityQueryIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/JobStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2JobStorageIT.java similarity index 79% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/JobStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2JobStorageIT.java index 88c5db0fbb..3a6815e467 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/JobStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2JobStorageIT.java @@ -18,14 +18,16 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractJobStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -public class JobStorageIT extends AbstractJobStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +public class H2JobStorageIT extends AbstractJobStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessDefinitionStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessDefinitionStorageIT.java similarity index 78% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessDefinitionStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessDefinitionStorageIT.java index b0369d8369..ab110245e0 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessDefinitionStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessDefinitionStorageIT.java @@ -18,14 +18,16 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractProcessDefinitionStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class ProcessDefinitionStorageIT extends AbstractProcessDefinitionStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +class H2ProcessDefinitionStorageIT extends AbstractProcessDefinitionStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessInstanceStorageIT.java similarity index 77% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessInstanceStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessInstanceStorageIT.java index 9f40d50928..3b73dd3fb3 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2ProcessInstanceStorageIT.java @@ -18,13 +18,15 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -public class ProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +public class H2ProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/UserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2UserTaskInstanceStorageIT.java similarity index 77% rename from data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/UserTaskInstanceStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2UserTaskInstanceStorageIT.java index 4a6b9921e5..b8b5105c6a 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/UserTaskInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/H2UserTaskInstanceStorageIT.java @@ -18,13 +18,15 @@ */ package org.kie.kogito.index.jdbc.storage; +import org.kie.kogito.index.jdbc.H2QuarkusTestProfile; import org.kie.kogito.index.jpa.storage.AbstractUserTaskInstanceStorageIT; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -public class UserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { +@TestTransaction +@TestProfile(H2QuarkusTestProfile.class) +public class H2UserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLJobStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLJobStorageIT.java new file mode 100644 index 0000000000..df8d352480 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLJobStorageIT.java @@ -0,0 +1,36 @@ +/* + * 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.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractJobStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgreSQLJobStorageIT extends AbstractJobStorageIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessDefinitionStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessDefinitionStorageIT.java new file mode 100644 index 0000000000..31c2f1109d --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessDefinitionStorageIT.java @@ -0,0 +1,36 @@ +/* + * 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.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractProcessDefinitionStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgreSQLProcessDefinitionStorageIT extends AbstractProcessDefinitionStorageIT { + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessInstanceStorageIT.java new file mode 100644 index 0000000000..19c7e61237 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLProcessInstanceStorageIT.java @@ -0,0 +1,35 @@ +/* + * 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.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgreSQLProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLUserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLUserTaskInstanceStorageIT.java new file mode 100644 index 0000000000..f0284db9f0 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/PostgreSQLUserTaskInstanceStorageIT.java @@ -0,0 +1,35 @@ +/* + * 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.jdbc.storage; + +import org.kie.kogito.index.jdbc.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.index.jpa.storage.AbstractUserTaskInstanceStorageIT; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.TestTransaction; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestTransaction +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgreSQLUserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties b/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties index a5b6fe7459..eb83483fe9 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties @@ -21,13 +21,19 @@ kogito.apps.persistence.type=jdbc kie.flyway.enabled=true -# Data source -quarkus.datasource.db-kind=h2 -quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test;NON_KEYWORDS=VALUE,KEY +# Data sources +%test-postgresql.quarkus.datasource.db-kind=postgresql +%test-postgresql.quarkus.datasource.devservices.enabled=false +%test-h2.quarkus.datasource.db-kind=h2 +%test-h2.quarkus.datasource.username=kogito +%test-h2.quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY + # Hibernate quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy quarkus.hibernate-orm.jdbc.timezone=UTC -quarkus.hibernate-orm.log.sql=true +# Enforcing flush to ensure data is correctly stored in DB +quarkus.hibernate-orm.flush.mode=always + # Disabling Security for tests quarkus.oidc.enabled=false diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java index 0ad8baf9b6..0ac176627c 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessInstanceStorageIT.java @@ -21,10 +21,12 @@ import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; +import io.quarkus.test.TestTransaction; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest +@TestTransaction @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) public class ProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties b/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties index b5637dfd64..a91fc1a378 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/resources/application.properties @@ -25,8 +25,7 @@ quarkus.datasource.username=kogito quarkus.datasource.password=kogito quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/kogito # Hibernate -quarkus.hibernate-orm.database.generation=drop-and-create -quarkus.hibernate-orm.database.generation.halt-on-error=true + quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy quarkus.hibernate-orm.jdbc.timezone=UTC quarkus.hibernate-orm.log.sql=true diff --git a/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java b/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java index b269ab9eaf..924fae07fa 100644 --- a/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java +++ b/jobs-service/jobs-service-storage-jpa/src/main/java/org/kie/kogito/jobs/service/repository/jpa/converter/JsonBinaryConverter.java @@ -27,19 +27,19 @@ import jakarta.persistence.AttributeConverter; -public class JsonBinaryConverter implements AttributeConverter { +public class JsonBinaryConverter implements AttributeConverter { @Override - public byte[] convertToDatabaseColumn(ObjectNode attribute) { + public String convertToDatabaseColumn(ObjectNode attribute) { try { - return attribute == null ? null : ObjectMapperFactory.get().writeValueAsBytes(attribute); + return attribute == null ? null : ObjectMapperFactory.get().writeValueAsString(attribute); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override - public ObjectNode convertToEntityAttribute(byte[] dbData) { + public ObjectNode convertToEntityAttribute(String dbData) { try { return dbData == null ? null : ObjectMapperFactory.get().readValue(dbData, ObjectNode.class); } catch (IOException e) { diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/application.properties b/jobs-service/jobs-service-storage-jpa/src/main/resources/application.properties similarity index 100% rename from persistence-commons/persistence-commons-postgresql/src/main/resources/application.properties rename to jobs-service/jobs-service-storage-jpa/src/main/resources/application.properties diff --git a/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql b/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql index b48a32a95c..eaf988097c 100644 --- a/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql +++ b/jobs-service/jobs-service-storage-jpa/src/main/resources/kie-flyway/db/jobs-service/ansi/V2.0.0__Create_Tables.sql @@ -27,8 +27,8 @@ create table job_details execution_counter integer, scheduled_id varchar(40), priority integer, - recipient varbinary(max), - trigger varbinary(max), + recipient varchar(max), + trigger varchar(max), fire_time timestamp, execution_timeout bigint, execution_timeout_unit varchar(40), diff --git a/persistence-commons/persistence-commons-jpa-base/src/main/resources/application.properties b/persistence-commons/persistence-commons-jpa-base/src/main/resources/application.properties new file mode 100644 index 0000000000..c4820ddf59 --- /dev/null +++ b/persistence-commons/persistence-commons-jpa-base/src/main/resources/application.properties @@ -0,0 +1,20 @@ +# +# 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. +# + +quarkus.datasource.jdbc.additional-jdbc-properties.stringtype=unspecified diff --git a/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql index 3b6a41389d..bf660066aa 100644 --- a/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql +++ b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.0__kogito_apps_create_kogito_data_cache.sql @@ -20,6 +20,6 @@ create table if not exists kogito_data_cache ( key varchar(255) not null, name varchar(255) not null, - json_value varbinary(max), + json_value varchar(max), primary key (key, name) ); \ No newline at end of file