diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/AbstractProcessDataIndexOracleIT.java b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/AbstractProcessDataIndexOracleIT.java deleted file mode 100644 index fd5d48fccd..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/AbstractProcessDataIndexOracleIT.java +++ /dev/null @@ -1,40 +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. - */ -package org.kie.kogito.index.oracle; - -import org.kie.kogito.index.AbstractProcessDataIndexIT; -import org.kie.kogito.test.quarkus.QuarkusTestProperty; - -import static org.kie.kogito.index.test.Constants.KOGITO_DATA_INDEX_SERVICE_URL; - -public abstract class AbstractProcessDataIndexOracleIT extends AbstractProcessDataIndexIT { - - @QuarkusTestProperty(name = KOGITO_DATA_INDEX_SERVICE_URL) - String dataIndex; - - @Override - public String getDataIndexURL() { - return dataIndex; - } - - @Override - public boolean validateDomainData() { - return false; - } -} diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/ProcessDataIndexOracleHttpIT.java b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/ProcessDataIndexOracleHttpIT.java deleted file mode 100644 index d323cbc6e0..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/ProcessDataIndexOracleHttpIT.java +++ /dev/null @@ -1,29 +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. - */ -package org.kie.kogito.index.oracle; - -import org.kie.kogito.index.quarkus.http.OracleHttpTestProfile; - -import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.quarkus.test.junit.TestProfile; - -@QuarkusIntegrationTest -@TestProfile(OracleHttpTestProfile.class) -public class ProcessDataIndexOracleHttpIT extends AbstractProcessDataIndexOracleIT { -} diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/ProcessDataIndexOracleKafkaIT.java b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/ProcessDataIndexOracleKafkaIT.java deleted file mode 100644 index bfcd0a7486..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/oracle/ProcessDataIndexOracleKafkaIT.java +++ /dev/null @@ -1,29 +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. - */ -package org.kie.kogito.index.oracle; - -import org.kie.kogito.index.quarkus.kafka.OracleKafkaTestProfile; - -import io.quarkus.test.junit.QuarkusIntegrationTest; -import io.quarkus.test.junit.TestProfile; - -@QuarkusIntegrationTest -@TestProfile(OracleKafkaTestProfile.class) -public class ProcessDataIndexOracleKafkaIT extends AbstractProcessDataIndexOracleIT { -} diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/quarkus/http/OracleHttpTestProfile.java b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/quarkus/http/OracleHttpTestProfile.java deleted file mode 100644 index e8bc357953..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/quarkus/http/OracleHttpTestProfile.java +++ /dev/null @@ -1,37 +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. - */ -package org.kie.kogito.index.quarkus.http; - -import java.util.Arrays; -import java.util.List; - -import org.kie.kogito.index.test.quarkus.http.DataIndexOracleHttpQuarkusTestResource; -import org.kie.kogito.index.test.quarkus.http.KogitoServiceRandomPortQuarkusHttpTestResource; - -import io.quarkus.test.junit.QuarkusTestProfile; - -public class OracleHttpTestProfile implements QuarkusTestProfile { - - @Override - public List testResources() { - return Arrays.asList(new TestResourceEntry(KogitoServiceRandomPortQuarkusHttpTestResource.class), - new TestResourceEntry(DataIndexOracleHttpQuarkusTestResource.class)); - } - -} diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/quarkus/kafka/OracleKafkaTestProfile.java b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/quarkus/kafka/OracleKafkaTestProfile.java deleted file mode 100644 index 4e129fb0f0..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-quarkus/src/test/java/org/kie/kogito/index/quarkus/kafka/OracleKafkaTestProfile.java +++ /dev/null @@ -1,36 +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. - */ -package org.kie.kogito.index.quarkus.kafka; - -import java.util.Arrays; -import java.util.List; - -import org.kie.kogito.index.test.quarkus.kafka.DataIndexOracleQuarkusKafkaTestResource; - -import io.quarkus.test.junit.QuarkusTestProfile; - -public class OracleKafkaTestProfile implements QuarkusTestProfile { - - @Override - public List testResources() { - return Arrays.asList(new TestResourceEntry(KogitoServiceRandomPortQuarkusKafkaTestResource.class), - new TestResourceEntry(DataIndexOracleQuarkusKafkaTestResource.class)); - } - -} diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/src/test/java/org/kie/kogito/index/ProcessDataIndexOracleIT.java b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/src/test/java/org/kie/kogito/index/ProcessDataIndexOracleIT.java deleted file mode 100644 index 9f9278ce26..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/src/test/java/org/kie/kogito/index/ProcessDataIndexOracleIT.java +++ /dev/null @@ -1,61 +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. - */ -package org.kie.kogito.index; - -import org.junit.jupiter.api.BeforeEach; -import org.kie.kogito.KogitoApplication; -import org.kie.kogito.index.spring.DataIndexOracleSpringTestResource; -import org.kie.kogito.index.spring.KogitoServiceRandomPortSpringTestResource; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; - -import io.restassured.RestAssured; - -import static org.kie.kogito.index.test.Constants.KOGITO_DATA_INDEX_SERVICE_URL; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { KogitoApplication.class }) -@ContextConfiguration(initializers = { KogitoServiceRandomPortSpringTestResource.class, DataIndexOracleSpringTestResource.class }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) -public class ProcessDataIndexOracleIT extends SpringBootAbstractProcessInstanceIT { - - @LocalServerPort - private int httpPort; - - @Value("${" + KOGITO_DATA_INDEX_SERVICE_URL + "}") - private String dataIndexUrl; - - @Override - public String getDataIndexURL() { - return dataIndexUrl; - } - - @Override - public boolean validateDomainData() { - return false; - } - - @BeforeEach - public void setup() { - RestAssured.port = httpPort; - } - -} diff --git a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/src/test/java/org/kie/kogito/index/spring/DataIndexOracleSpringTestResource.java b/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/src/test/java/org/kie/kogito/index/spring/DataIndexOracleSpringTestResource.java deleted file mode 100644 index fd8d1ef41c..0000000000 --- a/apps-integration-tests/integration-tests-data-index-service/integration-tests-data-index-service-springboot/src/test/java/org/kie/kogito/index/spring/DataIndexOracleSpringTestResource.java +++ /dev/null @@ -1,42 +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. - */ -package org.kie.kogito.index.spring; - -import java.util.HashMap; -import java.util.Map; - -import org.kie.kogito.index.test.quarkus.kafka.DataIndexOracleKafkaResource; -import org.kie.kogito.test.resources.ConditionalSpringBootTestResource; - -import static org.kie.kogito.index.test.Constants.KOGITO_DATA_INDEX_SERVICE_URL; - -public class DataIndexOracleSpringTestResource extends ConditionalSpringBootTestResource { - public DataIndexOracleSpringTestResource() { - super(new DataIndexOracleKafkaResource()); - } - - @Override - protected Map getProperties() { - Map properties = new HashMap<>(); - properties.put(KOGITO_DATA_INDEX_SERVICE_URL, "http://localhost:" + getTestResource().getMappedPort()); - properties.putAll(getTestResource().getProperties()); - return properties; - } - -} diff --git a/data-index/data-index-common/pom.xml b/data-index/data-index-common/pom.xml index bca376617f..ec7bf7d92f 100644 --- a/data-index/data-index-common/pom.xml +++ b/data-index/data-index-common/pom.xml @@ -45,6 +45,10 @@ org.kie.kogito kogito-events-core + + com.graphql-java + graphql-java + io.quarkus quarkus-jackson diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/DateTimeCoercing.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/DateTimeCoercing.java similarity index 96% rename from data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/DateTimeCoercing.java rename to data-index/data-index-common/src/main/java/org/kie/kogito/index/api/DateTimeCoercing.java index 3b72407932..621bf6d716 100644 --- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/DateTimeCoercing.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/DateTimeCoercing.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.graphql; +package org.kie.kogito.index.api; import graphql.schema.Coercing; diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/DefaultDateTimeCoercing.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/DefaultDateTimeCoercing.java similarity index 98% rename from data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/DefaultDateTimeCoercing.java rename to data-index/data-index-common/src/main/java/org/kie/kogito/index/api/DefaultDateTimeCoercing.java index 9bdde6dce1..95fba82147 100644 --- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/DefaultDateTimeCoercing.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/api/DefaultDateTimeCoercing.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.graphql; +package org.kie.kogito.index.api; import java.time.DateTimeException; import java.time.Instant; diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java index c1d6a4c8c0..8dbf880581 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/JsonUtils.java @@ -20,10 +20,14 @@ import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceDataEvent; +import org.kie.kogito.jackson.utils.JsonObjectUtils; +import org.kie.kogito.jackson.utils.MergeUtils; +import org.kie.kogito.jackson.utils.ObjectMapperFactory; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import io.cloudevents.jackson.JsonFormat; @@ -50,4 +54,20 @@ public static ObjectMapper configure(ObjectMapper objectMapper) { objectMapper.registerModule(module); return objectMapper; } + + public static ObjectNode mergeVariable(String variableName, Object variableValue, ObjectNode variables) { + return (ObjectNode) MergeUtils.merge(createObjectNode(variableName, variableValue), variables); + } + + private static ObjectNode createObjectNode(String variableName, Object variableValue) { + int indexOf = variableName.indexOf('.'); + ObjectNode result = ObjectMapperFactory.get().createObjectNode(); + if (indexOf == -1) { + result.set(variableName, JsonObjectUtils.fromValue(variableValue)); + } else { + String name = variableName.substring(0, indexOf); + result.set(name, createObjectNode(variableName.substring(indexOf + 1), variableValue)); + } + return result; + } } 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 4e9c733f3e..2802fe8f94 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 @@ -41,7 +41,7 @@ import org.kie.kogito.event.usertask.UserTaskInstanceStateDataEvent; import org.kie.kogito.event.usertask.UserTaskInstanceVariableDataEvent; import org.kie.kogito.index.model.Job; -import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; import org.kie.kogito.index.storage.DataIndexStorageService; import org.kie.kogito.index.storage.ProcessInstanceStorage; import org.kie.kogito.index.storage.UserTaskInstanceStorage; @@ -92,9 +92,8 @@ public void indexProcessInstanceEvent(ProcessInstanceDataEvent event) { //retry in case of rare but possible race condition during the insert for the first registry @Retry(maxRetries = 3, delay = 300, jitter = 100, retryOn = ConcurrentModificationException.class) public void indexProcessDefinition(ProcessDefinitionDataEvent definitionDataEvent) { - ProcessDefinition definition = ProcessDefinitionHelper - .merge(manager.getProcessDefinitionStorage().get(ProcessDefinition.toKey(definitionDataEvent.getKogitoProcessId(), definitionDataEvent.getData().getVersion())), definitionDataEvent); - manager.getProcessDefinitionStorage().put(definition.getKey(), definition); + ProcessDefinitionKey key = new ProcessDefinitionKey(definitionDataEvent.getKogitoProcessId(), definitionDataEvent.getData().getVersion()); + manager.getProcessDefinitionStorage().put(key, ProcessDefinitionHelper.merge(manager.getProcessDefinitionStorage().get(key), definitionDataEvent)); } //retry in case of rare but possible race condition during the insert for the first registry diff --git a/data-index/data-index-common/src/test/java/org/kie/kogito/index/json/JsonUtilsTest.java b/data-index/data-index-common/src/test/java/org/kie/kogito/index/json/JsonUtilsTest.java new file mode 100644 index 0000000000..c814d9c879 --- /dev/null +++ b/data-index/data-index-common/src/test/java/org/kie/kogito/index/json/JsonUtilsTest.java @@ -0,0 +1,48 @@ +/* + * 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.json; + +import org.junit.jupiter.api.Test; +import org.kie.kogito.jackson.utils.ObjectMapperFactory; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +import static org.assertj.core.api.Assertions.assertThat; + +public class JsonUtilsTest { + + @Test + void testMergeWithDot() { + ObjectNode expected = ObjectMapperFactory.get().createObjectNode().set("key", ObjectMapperFactory.get().createObjectNode().put("user1", "manolo")); + assertThat(JsonUtils.mergeVariable("key.user1", "manolo", null)).isEqualTo(expected); + } + + @Test + void testSimpleMerge() { + ObjectNode expected = ObjectMapperFactory.get().createObjectNode().put("user1", "manolo"); + assertThat(JsonUtils.mergeVariable("user1", "manolo", null)).isEqualTo(expected); + } + + @Test + void testComplexMergeWithDot() { + ObjectNode expected = ObjectMapperFactory.get().createObjectNode().set("key", ObjectMapperFactory.get().createObjectNode().put("user1", "manolo").put("user2", "pepe")); + assertThat(JsonUtils.mergeVariable("key.user1", "manolo", ObjectMapperFactory.get().createObjectNode().set("key", ObjectMapperFactory.get().createObjectNode().put("user2", "pepe")))) + .isEqualTo(expected); + } +} diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java index bcb759c63e..6dd81262b1 100644 --- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java +++ b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/AbstractGraphQLSchemaManager.java @@ -34,6 +34,7 @@ import org.kie.kogito.index.model.Job; import org.kie.kogito.index.model.Node; 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.model.UserTaskInstance; import org.kie.kogito.index.service.DataIndexServiceException; @@ -137,7 +138,7 @@ public String getProcessInstanceServiceUrl(DataFetchingEnvironment env) { public ProcessDefinition getProcessDefinition(DataFetchingEnvironment env) { ProcessInstance source = env.getSource(); - return cacheService.getProcessDefinitionStorage().get(ProcessDefinition.toKey(source.getProcessId(), source.getVersion())); + return cacheService.getProcessDefinitionStorage().get(new ProcessDefinitionKey(source.getProcessId(), source.getVersion())); } protected String getServiceUrl(String endpoint, String processId) { @@ -188,7 +189,7 @@ protected Collection getProcessInstancesValues(DataFetchingEnvi return executeAdvancedQueryForCache(cacheService.getProcessInstanceStorage(), env); } - protected List executeAdvancedQueryForCache(StorageFetcher cache, DataFetchingEnvironment env) { + protected List executeAdvancedQueryForCache(StorageFetcher cache, DataFetchingEnvironment env) { Objects.requireNonNull(cache, "Cache not found"); String inputTypeName = ((GraphQLNamedType) env.getFieldDefinition().getArgument("where").getType()).getName(); @@ -231,7 +232,7 @@ public CompletableFuture getProcessInstanceDiagram(DataFetchingEnvironme public CompletableFuture getProcessInstanceSource(DataFetchingEnvironment env) { ProcessInstance pi = env.getSource(); - ProcessDefinition pd = cacheService.getProcessDefinitionStorage().get(ProcessDefinition.toKey(pi.getProcessId(), pi.getVersion())); + ProcessDefinition pd = cacheService.getProcessDefinitionStorage().get(new ProcessDefinitionKey(pi.getProcessId(), pi.getVersion())); if (pd == null) { return dataIndexApiExecutor.getProcessDefinitionSourceFileContent(getServiceUrl(pi.getEndpoint(), pi.getProcessId()), pi.getProcessId()); } else { @@ -241,7 +242,7 @@ public CompletableFuture getProcessInstanceSource(DataFetchingEnvironmen public CompletableFuture> getProcessInstanceNodes(DataFetchingEnvironment env) { ProcessInstance pi = env.getSource(); - ProcessDefinition pd = cacheService.getProcessDefinitionStorage().get(ProcessDefinition.toKey(pi.getProcessId(), pi.getVersion())); + ProcessDefinition pd = cacheService.getProcessDefinitionStorage().get(new ProcessDefinitionKey(pi.getProcessId(), pi.getVersion())); if (pd == null) { return dataIndexApiExecutor.getProcessDefinitionNodes(getServiceUrl(pi.getEndpoint(), pi.getProcessId()), pi.getProcessId()); } else { diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLScalarTypeProducer.java b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLScalarTypeProducer.java index 84f5744804..e84698c831 100644 --- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLScalarTypeProducer.java +++ b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/GraphQLScalarTypeProducer.java @@ -18,6 +18,8 @@ */ package org.kie.kogito.index.graphql; +import org.kie.kogito.index.api.DateTimeCoercing; + import graphql.schema.GraphQLScalarType; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.inject.Produces; diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/PostgreSqlDateTimeCoercing.java b/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/PostgreSqlDateTimeCoercing.java deleted file mode 100644 index e4001bb797..0000000000 --- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/PostgreSqlDateTimeCoercing.java +++ /dev/null @@ -1,51 +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. - */ -package org.kie.kogito.index.graphql; - -import java.time.ZonedDateTime; - -import io.quarkus.arc.properties.IfBuildProperty; - -import graphql.language.StringValue; -import jakarta.enterprise.context.ApplicationScoped; - -import static org.kie.kogito.persistence.api.factory.Constants.PERSISTENCE_TYPE_PROPERTY; - -@ApplicationScoped -@IfBuildProperty(name = PERSISTENCE_TYPE_PROPERTY, stringValue = "postgresql") -public class PostgreSqlDateTimeCoercing extends DefaultDateTimeCoercing implements DateTimeCoercing { - - @Override - public Object parseValue(Object input) { - return input == null ? null : getZonedDateTime((String) input); - } - - private ZonedDateTime getZonedDateTime(String input) { - return parseDateTime(input); - } - - @Override - public Object parseLiteral(Object input) { - if (input instanceof StringValue) { - return getZonedDateTime(((StringValue) input).getValue()); - } else { - return null; - } - } -} diff --git a/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DateTimeScalarTypeProducerTest.java b/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DateTimeScalarTypeProducerTest.java index 224e45fce3..4558cffd97 100644 --- a/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DateTimeScalarTypeProducerTest.java +++ b/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DateTimeScalarTypeProducerTest.java @@ -19,6 +19,7 @@ package org.kie.kogito.index.graphql; import org.junit.jupiter.api.Test; +import org.kie.kogito.index.api.DefaultDateTimeCoercing; import graphql.schema.GraphQLScalarType; diff --git a/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DefaultDateTimeCoercingTest.java b/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DefaultDateTimeCoercingTest.java index 46aa657512..0f60f439e9 100644 --- a/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DefaultDateTimeCoercingTest.java +++ b/data-index/data-index-graphql/src/test/java/org/kie/kogito/index/graphql/DefaultDateTimeCoercingTest.java @@ -25,6 +25,7 @@ import java.time.temporal.ChronoUnit; import org.junit.jupiter.api.Test; +import org.kie.kogito.index.api.DefaultDateTimeCoercing; import graphql.language.StringValue; import graphql.schema.CoercingSerializeException; diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/GraphQLQueryMapperTest.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/GraphQLQueryMapperTest.java index ebcca023fd..6caec6c860 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/GraphQLQueryMapperTest.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/GraphQLQueryMapperTest.java @@ -28,7 +28,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.kie.kogito.index.graphql.DefaultDateTimeCoercing; +import org.kie.kogito.index.api.DefaultDateTimeCoercing; import org.kie.kogito.index.graphql.GraphQLScalarTypeProducer; import org.kie.kogito.index.graphql.query.GraphQLQueryParser; import org.kie.kogito.index.graphql.query.GraphQLQueryParserRegistry; diff --git a/data-index/data-index-service/data-index-service-oracle/pom.xml b/data-index/data-index-service/data-index-service-oracle/pom.xml deleted file mode 100644 index 7df9739814..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/pom.xml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - data-index-service - org.kie.kogito - 9.99.0 - - 4.0.0 - - data-index-service-oracle - Kogito Apps :: Data Index Service with Oracle - - - org.kie.kogito.index.service.oracle - - - - - org.kie.kogito - data-index-service-common - - - org.kie.kogito - data-index-storage-oracle - - - io.quarkus - quarkus-smallrye-reactive-messaging-kafka - - - io.quarkus - quarkus-container-image-jib - - - io.quarkus - quarkus-flyway - - - - org.kie.kogito - data-index-test-utils - test - - - org.kie.kogito - data-index-service-common - test-jar - test - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - org.mockito - mockito-junit-jupiter - test - - - org.assertj - assertj-core - test - - - org.kie.kogito - kogito-quarkus-test-utils - test - - - org.keycloak - keycloak-core - test - - - org.awaitility - awaitility - test - - - io.smallrye.reactive - smallrye-reactive-messaging-in-memory - test - - - - - - - io.quarkus - quarkus-maven-plugin - - true - - - - - build - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - integration-test - - integration-test - verify - - - - - - - \ No newline at end of file diff --git a/data-index/data-index-service/data-index-service-oracle/src/main/resources/application.properties b/data-index/data-index-service/data-index-service-oracle/src/main/resources/application.properties deleted file mode 100644 index 6ee6ffb0cd..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/main/resources/application.properties +++ /dev/null @@ -1,39 +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. -# - -#Data Index -kogito.apps.persistence.type=oracle -kogito.data-index.domain-indexing=false -kogito.data-index.blocking=true - -#Kafka -quarkus.kafka.health.enabled=true - -quarkus.datasource.db-kind=oracle - -#Hibernate -quarkus.hibernate-orm.jdbc.timezone=UTC -quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy -# Normalizing timezones storage as Hibernate ORM 5 for backwards compatibility. -quarkus.hibernate-orm.mapping.timezone.default-storage=normalize - -#Container image -quarkus.container-image.build=${quarkus.build.image:true} -quarkus.container-image.group=org.kie.kogito -quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080 diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/docker/docker-compose.yml b/data-index/data-index-service/data-index-service-oracle/src/test/docker/docker-compose.yml deleted file mode 100644 index 25578f35ed..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/test/docker/docker-compose.yml +++ /dev/null @@ -1,71 +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. -# - -version: "3" - -networks: - default: - driver: bridge - enable_ipv6: false - ipam: - config: - - subnet: 172.16.57.0/24 - -services: - zookeeper: - image: strimzi/kafka:0.20.1-kafka-2.6.0 - container_name: data-index-zookeeper - command: [ - "sh", "-c", - "bin/zookeeper-server-start.sh config/zookeeper.properties" - ] - ports: - - "2181:2181" - environment: - LOG_DIR: "/tmp/logs" - - kafka: - image: strimzi/kafka:0.20.1-kafka-2.6.0 - container_name: data-index-kafka - command: [ - "sh", "-c", - "bin/kafka-server-start.sh config/server.properties --override inter.broker.listener.name=$${KAFKA_INTER_BROKER_LISTENER_NAME} --override listener.security.protocol.map=$${KAFKA_LISTENER_SECURITY_PROTOCOL_MAP} --override listeners=$${KAFKA_LISTENERS} --override advertised.listeners=$${KAFKA_ADVERTISED_LISTENERS} --override zookeeper.connect=$${KAFKA_ZOOKEEPER_CONNECT}" - ] - depends_on: - - zookeeper - ports: - - "9092:9092" - environment: - KAFKA_BROKER_ID: 0 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_LISTENERS: INTERNAL://kafka:29092,EXTERNAL://kafka:9092 - KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:29092,EXTERNAL://localhost:9092 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT - KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL - KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true" - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 - LOG_DIR: "/tmp/logs" - - oracle: - image: gvenzl/oracle-xe:21.3.0-slim - container_name: data-index-oracle - environment: - ORACLE_PASSWORD: test - ports: - - 1521:1521 diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/graphql/OracleDateTimeCoercingTest.java b/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/graphql/OracleDateTimeCoercingTest.java deleted file mode 100644 index 92148ad792..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/graphql/OracleDateTimeCoercingTest.java +++ /dev/null @@ -1,89 +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. - */ -package org.kie.kogito.index.service.graphql; - -import java.time.ZonedDateTime; - -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.graphql.OracleDateTimeCoercing; - -import graphql.language.StringValue; -import graphql.schema.CoercingSerializeException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -public class OracleDateTimeCoercingTest { - - OracleDateTimeCoercing dateTimeCoercing = new OracleDateTimeCoercing(); - - @Test - public void testParseValueAsZonedDateTime() { - assertThat(dateTimeCoercing.parseValue(null)).isNull(); - assertThat(dateTimeCoercing.parseValue("2019-11-20T03:14:03.075Z")) - .isEqualTo(ZonedDateTime.parse("2019-11-20T03:14:03.075Z")); - } - - @Test - public void testParseLiteral() { - assertThat(dateTimeCoercing.parseLiteral(null)).isNull(); - assertThat(dateTimeCoercing.parseLiteral(new StringValue("2019-11-20T03:14:03.075Z"))) - .isEqualTo(ZonedDateTime.parse("2019-11-20T03:14:03.075Z")); - } - - @Test - public void testSerializeInvalidString() { - try { - dateTimeCoercing.serialize("test"); - fail("Method should throw CoercingSerializeException"); - } catch (CoercingSerializeException ex) { - assertThat(ex.getMessage()) - .isEqualTo("Invalid ISO-8601 value : 'test'. because of : 'Text 'test' could not be parsed at index 0'"); - } - } - - @Test - public void testSerializeNull() { - try { - dateTimeCoercing.serialize(null); - fail("Method should throw CoercingSerializeException"); - } catch (CoercingSerializeException ex) { - assertThat(ex.getMessage()) - .isEqualTo("Expected something we can convert to 'java.time.ZonedDateTime' but was 'null'."); - } - } - - @Test - public void testSerializeInvalidType() { - try { - dateTimeCoercing.serialize(1); - fail("Method should throw CoercingSerializeException"); - } catch (CoercingSerializeException ex) { - assertThat(ex.getMessage()) - .isEqualTo("Expected something we can convert to 'java.time.ZonedDateTime' but was 'java.lang.Integer'."); - } - } - - @Test - public void testSerializeString() { - String result = dateTimeCoercing.serialize("2019-08-20T19:26:02.092+00:00"); - assertThat(result).isEqualTo("2019-08-20T19:26:02.092Z"); - } - -} diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingLoadKafkaIT.java b/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingLoadKafkaIT.java deleted file mode 100644 index c36e54f125..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingLoadKafkaIT.java +++ /dev/null @@ -1,32 +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. - */ -package org.kie.kogito.index.service.messaging; - -import org.junit.jupiter.api.Disabled; -import org.kie.kogito.index.service.test.KafkaMessageTestProfile; - -import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.TestProfile; - -@QuarkusTest -@TestProfile(KafkaMessageTestProfile.class) -@Disabled -class OracleMessagingLoadKafkaIT extends AbstractMessagingLoadKafkaIT { - -} diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/InMemoryMessageTestProfile.java b/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/InMemoryMessageTestProfile.java deleted file mode 100644 index 27bfc31fb6..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/InMemoryMessageTestProfile.java +++ /dev/null @@ -1,36 +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. - */ -package org.kie.kogito.index.service.test; - -import java.util.Arrays; -import java.util.List; - -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.junit.QuarkusTestProfile; - -public class InMemoryMessageTestProfile implements QuarkusTestProfile { - - @Override - public List testResources() { - return Arrays.asList( - new TestResourceEntry(InMemoryMessagingTestResource.class), - new TestResourceEntry(OracleSqlQuarkusTestResource.class)); - } -} diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/KafkaMessageTestProfile.java b/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/KafkaMessageTestProfile.java deleted file mode 100644 index babcab6b20..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/KafkaMessageTestProfile.java +++ /dev/null @@ -1,42 +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. - */ -package org.kie.kogito.index.service.test; - -import java.util.Arrays; -import java.util.List; - -import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.junit.QuarkusTestProfile; - -public class KafkaMessageTestProfile implements QuarkusTestProfile { - - @Override - public List testResources() { - return Arrays.asList( - new TestResourceEntry(OracleSqlQuarkusTestResource.class), - new TestResourceEntry(KafkaQuarkusTestResource.class)); - } - - @Override - public String getConfigProfile() { - return "kafka-events-support"; - } -} diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/KeycloakTestProfile.java b/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/KeycloakTestProfile.java deleted file mode 100644 index f171568214..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/test/KeycloakTestProfile.java +++ /dev/null @@ -1,59 +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. - */ -package org.kie.kogito.index.service.test; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.kie.kogito.testcontainers.quarkus.KeycloakQuarkusTestResource; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.junit.QuarkusTestProfile; - -import static java.util.Collections.singletonMap; -import static org.kie.kogito.testcontainers.quarkus.KeycloakQuarkusTestResource.KOGITO_OIDC_TENANTS; - -public class KeycloakTestProfile implements QuarkusTestProfile { - - @Override - public Map getConfigOverrides() { - Map config = new HashMap<>(); - config.put("quarkus.http.auth.policy.role-policy1.roles-allowed", "confidential"); - config.put("quarkus.http.auth.permission.roles1.paths", "/*"); - config.put("quarkus.http.auth.permission.roles1.policy", "role-policy1"); - return config; - } - - @Override - public String getConfigProfile() { - return "keycloak-test"; - } - - @Override - public List testResources() { - Map args = singletonMap(KOGITO_OIDC_TENANTS, "web-app-tenant"); - return Arrays.asList( - new TestResourceEntry(OracleSqlQuarkusTestResource.class), - new TestResourceEntry(InMemoryMessagingTestResource.class), - new TestResourceEntry(KeycloakQuarkusTestResource.class, args)); - } - -} diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/resources/application.properties b/data-index/data-index-service/data-index-service-oracle/src/test/resources/application.properties deleted file mode 100644 index 1e250e5239..0000000000 --- a/data-index/data-index-service/data-index-service-oracle/src/test/resources/application.properties +++ /dev/null @@ -1,63 +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. -# - -#Data Index -kogito.apps.persistence.type=oracle -kogito.data-index.domain-indexing=false -kogito.data-index.blocking=true -kogito.data-index.vertx-graphql.ui.path=/graphiql -kogito.data-index.vertx-graphql.ui.tenant=web-app-tenant - -#Flyway -quarkus.flyway.migrate-at-start=true -quarkus.flyway.baseline-on-migrate=true - -# Kafka -kafka.bootstrap.servers=localhost:9092 -# Persistence -quarkus.datasource.db-kind=oracle -quarkus.datasource.username=test -quarkus.datasource.password=test -quarkus.datasource.jdbc.url=jdbc:oracle://localhost:1521/XEPDB1 - -#Hibernate -quarkus.hibernate-orm.jdbc.timezone=UTC -quarkus.hibernate-orm.database.generation.halt-on-error=true -quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy - -# Security -quarkus.oidc.enabled=false -quarkus.oidc.tenant-enabled=false -quarkus.oidc.auth-server-url=none - -# Keycloak oidc -%keycloak-test.quarkus.oidc.enabled=true -%keycloak-test.quarkus.oidc.tenant-enabled=true -#%keycloak-test.quarkus.oidc.auth-server-url=http://localhost:8281/auth/realms/kogito -%keycloak-test.quarkus.oidc.client-id=kogito-app -%keycloak-test.quarkus.oidc.credentials.secret=secret -%keycloak-test.quarkus.oidc.application-type=service - -#%keycloak-test.quarkus.oidc.web-app-tenant.auth-server-url=http://localhost:8281/auth/realms/kogito -%keycloak-test.quarkus.oidc.web-app-tenant.client-id=kogito-app -%keycloak-test.quarkus.oidc.web-app-tenant.credentials.secret=secret -%keycloak-test.quarkus.oidc.web-app-tenant.application-type=web-app - -# Not using Dev service in test, but rather org.kie.kogito.testcontainers.quarkus.KeycloakQuarkusTestResource -quarkus.keycloak.devservices.enabled=false diff --git a/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties b/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties index ac4d1958d9..10ce0cd969 100644 --- a/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties +++ b/data-index/data-index-service/data-index-service-postgresql/src/main/resources/application.properties @@ -39,9 +39,3 @@ quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.C quarkus.container-image.build=${quarkus.build.image:true} quarkus.container-image.group=org.kie.kogito quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080 - -quarkus.log.console.enable=true -quarkus.log.console.level=INFO -quarkus.log.level=INFO -quarkus.log.category."org.kie.kogito.index".level=INFO -quarkus.log.category."org.kie.kogito.index".min-level=INFO diff --git a/data-index/data-index-service/data-index-service-postgresql/src/test/java/org/kie/kogito/index/service/graphql/PostgreSqlDateTimeCoercingTest.java b/data-index/data-index-service/data-index-service-postgresql/src/test/java/org/kie/kogito/index/service/graphql/PostgreSqlDateTimeCoercingTest.java deleted file mode 100644 index 9ac63e7352..0000000000 --- a/data-index/data-index-service/data-index-service-postgresql/src/test/java/org/kie/kogito/index/service/graphql/PostgreSqlDateTimeCoercingTest.java +++ /dev/null @@ -1,89 +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. - */ -package org.kie.kogito.index.service.graphql; - -import java.time.ZonedDateTime; - -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.graphql.PostgreSqlDateTimeCoercing; - -import graphql.language.StringValue; -import graphql.schema.CoercingSerializeException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -public class PostgreSqlDateTimeCoercingTest { - - PostgreSqlDateTimeCoercing dateTimeCoercing = new PostgreSqlDateTimeCoercing(); - - @Test - public void testParseValueAsZonedDateTime() { - assertThat(dateTimeCoercing.parseValue(null)).isNull(); - assertThat(dateTimeCoercing.parseValue("2019-11-20T03:14:03.075Z")) - .isEqualTo(ZonedDateTime.parse("2019-11-20T03:14:03.075Z")); - } - - @Test - public void testParseLiteral() { - assertThat(dateTimeCoercing.parseLiteral(null)).isNull(); - assertThat(dateTimeCoercing.parseLiteral(new StringValue("2019-11-20T03:14:03.075Z"))) - .isEqualTo(ZonedDateTime.parse("2019-11-20T03:14:03.075Z")); - } - - @Test - public void testSerializeInvalidString() { - try { - dateTimeCoercing.serialize("test"); - fail("Method should throw CoercingSerializeException"); - } catch (CoercingSerializeException ex) { - assertThat(ex.getMessage()) - .isEqualTo("Invalid ISO-8601 value : 'test'. because of : 'Text 'test' could not be parsed at index 0'"); - } - } - - @Test - public void testSerializeNull() { - try { - dateTimeCoercing.serialize(null); - fail("Method should throw CoercingSerializeException"); - } catch (CoercingSerializeException ex) { - assertThat(ex.getMessage()) - .isEqualTo("Expected something we can convert to 'java.time.ZonedDateTime' but was 'null'."); - } - } - - @Test - public void testSerializeInvalidType() { - try { - dateTimeCoercing.serialize(1); - fail("Method should throw CoercingSerializeException"); - } catch (CoercingSerializeException ex) { - assertThat(ex.getMessage()) - .isEqualTo("Expected something we can convert to 'java.time.ZonedDateTime' but was 'java.lang.Integer'."); - } - } - - @Test - public void testSerializeString() { - String result = dateTimeCoercing.serialize("2019-08-20T19:26:02.092+00:00"); - assertThat(result).isEqualTo("2019-08-20T19:26:02.092Z"); - } - -} diff --git a/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessDefinition.java b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessDefinition.java index 200d4347f8..e6e2450ea0 100644 --- a/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessDefinition.java +++ b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessDefinition.java @@ -21,9 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.Set; -import java.util.regex.Pattern; public class ProcessDefinition { @@ -112,18 +110,6 @@ public void setNodes(List nodes) { this.nodes = nodes; } - public String getKey() { - return toKey(id, version); - } - - public static String toKey(String processId, String version) { - return processId + "$v:" + version; - } - - public static String[] fromKey(String key) { - return Optional.ofNullable(key).map(k -> k.split(Pattern.quote("$v:"))).orElse(new String[0]); - } - public String getDescription() { return description; } @@ -176,5 +162,4 @@ public String toString() { ", nodes='" + nodes + '\'' + '}'; } - } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityId.java b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessDefinitionKey.java similarity index 52% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityId.java rename to data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessDefinitionKey.java index 28f61990f5..a850f9efd8 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityId.java +++ b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessDefinitionKey.java @@ -16,74 +16,53 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.jpa.model; +package org.kie.kogito.index.model; -import java.io.Serializable; import java.util.Objects; -import static org.kie.kogito.index.model.ProcessDefinition.fromKey; -import static org.kie.kogito.index.model.ProcessDefinition.toKey; - -public class ProcessDefinitionEntityId implements Serializable { +public class ProcessDefinitionKey { private String id; - private String version; - public ProcessDefinitionEntityId() { - } - - public ProcessDefinitionEntityId(String key) { - String[] fromKey = fromKey(key); - this.id = fromKey[0]; - this.version = fromKey[1]; - } - - public ProcessDefinitionEntityId(String id, String version) { + public ProcessDefinitionKey(String id, String version) { this.id = id; this.version = version; } - public String getKey() { - return toKey(id, version); - } - public String getId() { return id; } - public void setId(String id) { - this.id = id; - } - public String getVersion() { return version; } - public void setVersion(String version) { - this.version = version; + @Override + public int hashCode() { + return Objects.hash(id, version); } @Override - public boolean equals(Object o) { - if (this == o) + public boolean equals(Object obj) { + if (this == obj) { return true; - if (o == null || getClass() != o.getClass()) + } + if (!(obj instanceof ProcessDefinitionKey)) { return false; - ProcessDefinitionEntityId that = (ProcessDefinitionEntityId) o; - return Objects.equals(id, that.id) && Objects.equals(version, that.version); + } + ProcessDefinitionKey other = (ProcessDefinitionKey) obj; + return Objects.equals(id, other.id) && Objects.equals(version, other.version); } @Override - public int hashCode() { - return Objects.hash(id, version); + public String toString() { + return "ProcessDefinitionKey [id=" + id + ", version=" + version + "]"; } - @Override - public String toString() { - return "ProcessDefinitionEntityId{" + - "id='" + id + '\'' + - ", version='" + version + '\'' + - '}'; + @SuppressWarnings("unused") + private ProcessDefinitionKey() { + // needed by external tools } + } diff --git a/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/storage/DataIndexStorageService.java b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/storage/DataIndexStorageService.java index 5e8995d08c..43c951fd83 100644 --- a/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/storage/DataIndexStorageService.java +++ b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/storage/DataIndexStorageService.java @@ -20,13 +20,14 @@ import org.kie.kogito.index.model.Job; import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; import org.kie.kogito.persistence.api.Storage; import com.fasterxml.jackson.databind.node.ObjectNode; public interface DataIndexStorageService { - Storage getProcessDefinitionStorage(); + Storage getProcessDefinitionStorage(); ProcessInstanceStorage getProcessInstanceStorage(); diff --git a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/QueryTestBase.java b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/QueryTestBase.java index c2a654df8e..5e25817c65 100644 --- a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/QueryTestBase.java +++ b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/QueryTestBase.java @@ -34,8 +34,8 @@ protected Boolean isDateTimeAsLong() { return true; } - public void queryAndAssert(BiConsumer, String[]> assertConsumer, StorageFetcher storage, List> filters, List sort, Integer offset, Integer limit, - String... ids) { + public void queryAndAssert(BiConsumer, K[]> assertConsumer, StorageFetcher storage, List> filters, List sort, Integer offset, Integer limit, + K... ids) { assertConsumer.accept(storage.query().filter(filters).sort(sort).offset(offset).limit(limit).execute(), ids); } diff --git a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/query/AbstractProcessDefinitionQueryIT.java b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/query/AbstractProcessDefinitionQueryIT.java index dc0bd2de9a..a6e61fc01f 100644 --- a/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/query/AbstractProcessDefinitionQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-api/src/test/java/org/kie/kogito/index/test/query/AbstractProcessDefinitionQueryIT.java @@ -22,8 +22,10 @@ import java.util.Set; import java.util.function.BiConsumer; +import org.assertj.core.groups.Tuple; import org.junit.jupiter.api.Test; import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; import org.kie.kogito.index.test.QueryTestBase; import org.kie.kogito.index.test.TestUtils; import org.kie.kogito.persistence.api.Storage; @@ -41,34 +43,37 @@ import static org.kie.kogito.persistence.api.query.QueryFilterFactory.notNull; import static org.kie.kogito.persistence.api.query.QueryFilterFactory.orderBy; -public abstract class AbstractProcessDefinitionQueryIT extends QueryTestBase { +public abstract class AbstractProcessDefinitionQueryIT extends QueryTestBase { - public abstract Storage getStorage(); + public abstract Storage getStorage(); @Test void testProcessDefinitionQuery() { String processId = "travels"; ProcessDefinition pdv1 = TestUtils.createProcessDefinition(processId, "1.0", Set.of("admin", "kogito")); - Storage storage = getStorage(); - storage.put(pdv1.getKey(), pdv1); + Storage storage = getStorage(); + ProcessDefinitionKey pdv1Key = new ProcessDefinitionKey(pdv1.getId(), pdv1.getVersion()); + storage.put(pdv1Key, pdv1); ProcessDefinition pdv2 = TestUtils.createProcessDefinition(processId, "2.0", Set.of("kogito")); - storage.put(pdv2.getKey(), pdv2); + ProcessDefinitionKey pdv2Key = new ProcessDefinitionKey(pdv2.getId(), pdv2.getVersion()); + storage.put(pdv2Key, pdv2); - queryAndAssert(assertWithKey(), storage, singletonList(isNull("type")), null, null, null, pdv1.getKey(), pdv2.getKey()); - queryAndAssert(assertWithKey(), storage, singletonList(notNull("version")), null, null, null, pdv1.getKey(), pdv2.getKey()); - queryAndAssert(assertWithKey(), storage, singletonList(equalTo("version", pdv1.getVersion())), null, null, null, pdv1.getKey()); - queryAndAssert(assertWithKey(), storage, singletonList(contains("roles", "admin")), null, null, null, pdv1.getKey()); - queryAndAssert(assertWithKey(), storage, singletonList(containsAny("roles", asList("admin", "kogito"))), null, null, null, pdv1.getKey(), pdv2.getKey()); - queryAndAssert(assertWithKey(), storage, singletonList(containsAll("roles", asList("admin", "kogito"))), null, null, null, pdv1.getKey()); + queryAndAssert(assertWithKey(), storage, singletonList(isNull("type")), null, null, null, pdv1Key, pdv2Key); + queryAndAssert(assertWithKey(), storage, singletonList(notNull("version")), null, null, null, pdv1Key, pdv2Key); + queryAndAssert(assertWithKey(), storage, singletonList(equalTo("version", pdv1.getVersion())), null, null, null, pdv1Key); + queryAndAssert(assertWithKey(), storage, singletonList(contains("roles", "admin")), null, null, null, pdv1Key); + queryAndAssert(assertWithKey(), storage, singletonList(containsAny("roles", asList("admin", "kogito"))), null, null, null, pdv1Key, pdv2Key); + queryAndAssert(assertWithKey(), storage, singletonList(containsAll("roles", asList("admin", "kogito"))), null, null, null, pdv1Key); queryAndAssert(assertWithKey(), storage, asList(in("id", asList(pdv1.getId(), pdv2.getId())), in("version", asList(pdv1.getVersion(), pdv2.getVersion()))), - singletonList(orderBy("version", SortDirection.ASC)), 1, 1, pdv2.getKey()); + singletonList(orderBy("version", SortDirection.ASC)), 1, 1, pdv2Key); queryAndAssert(assertWithKey(), storage, null, singletonList(orderBy("version", SortDirection.DESC)), null, - null, pdv2.getKey(), pdv1.getKey()); + null, pdv2Key, pdv1Key); } - public static BiConsumer, String[]> assertWithKey() { - return (instances, ids) -> assertThat(instances).hasSize(ids == null ? 0 : ids.length).extracting("key").containsExactly(ids); + public static BiConsumer, ProcessDefinitionKey[]> assertWithKey() { + return (instances, ids) -> assertThat(instances).hasSize(ids == null ? 0 : ids.length).extracting("id", "version").map(Tuple::toArray) + .map(objs -> new ProcessDefinitionKey((String) objs[0], (String) objs[1])).containsExactly(ids); } } diff --git a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelDataIndexStorageService.java b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelDataIndexStorageService.java index 007ecb51c0..693928d991 100644 --- a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelDataIndexStorageService.java +++ b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelDataIndexStorageService.java @@ -20,6 +20,7 @@ import org.kie.kogito.index.model.Job; 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.model.UserTaskInstance; import org.kie.kogito.persistence.api.Storage; @@ -43,8 +44,8 @@ public class ModelDataIndexStorageService implements DataIndexStorageService { StorageService storageService; @Override - public Storage getProcessDefinitionStorage() { - return storageService.getCache(PROCESS_DEFINITIONS_STORAGE, ProcessDefinition.class); + public Storage getProcessDefinitionStorage() { + return new ModelProcessDefinitionStorage(storageService.getCache(PROCESS_DEFINITIONS_STORAGE, ProcessDefinition.class)); } @Override diff --git a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelProcessDefinitionStorage.java b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelProcessDefinitionStorage.java new file mode 100644 index 0000000000..5462c4df08 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelProcessDefinitionStorage.java @@ -0,0 +1,73 @@ +/* + * 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.storage; + +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; +import org.kie.kogito.persistence.api.Storage; + +public class ModelProcessDefinitionStorage extends ModelStorageFetcher implements Storage { + + private static final String VERSION_SEPARATOR = "$v:"; + + static ProcessDefinitionKey fromString(String key) { + int indexOf = key.indexOf(VERSION_SEPARATOR); + return indexOf == -1 ? new ProcessDefinitionKey(key, null) + : new ProcessDefinitionKey(key.substring(0, indexOf), key.substring(indexOf + VERSION_SEPARATOR.length())); + } + + static String toString(ProcessDefinitionKey key) { + String id = key.getId(); + String version = key.getVersion(); + return version == null ? id : id + VERSION_SEPARATOR + version; + } + + public ModelProcessDefinitionStorage(Storage storage) { + super(storage, ModelProcessDefinitionStorage::toString, ModelProcessDefinitionStorage::fromString); + } + + @Override + public ProcessDefinition put(ProcessDefinitionKey key, ProcessDefinition value) { + return storage.put(toString(key), value); + } + + @Override + public ProcessDefinition remove(ProcessDefinitionKey key) { + return storage.remove(toString(key)); + } + + @Override + public boolean containsKey(ProcessDefinitionKey key) { + return storage.containsKey(toString(key)); + } + + @Override + public Map entries() { + return storage.entries().entrySet().stream().collect(Collectors.toMap(e -> fromString(e.getKey()), Entry::getValue)); + } + + @Override + public String getRootType() { + return ProcessDefinition.class.getName(); + } +} diff --git a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelProcessInstanceStorage.java b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelProcessInstanceStorage.java index 52c8b56892..9f21497fc2 100644 --- a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelProcessInstanceStorage.java +++ b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelProcessInstanceStorage.java @@ -1,3 +1,21 @@ +/* + * 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.storage; import org.kie.kogito.event.process.ProcessInstanceDataEvent; @@ -15,7 +33,7 @@ import org.kie.kogito.index.storage.merger.ProcessInstanceVariableDataEventMerger; import org.kie.kogito.persistence.api.Storage; -public class ModelProcessInstanceStorage extends ModelStorageFetcher implements ProcessInstanceStorage { +public class ModelProcessInstanceStorage extends ModelStorageFetcher implements ProcessInstanceStorage { private final ProcessInstanceErrorDataEventMerger errorMerger = new ProcessInstanceErrorDataEventMerger(); private final ProcessInstanceNodeDataEventMerger nodeMerger = new ProcessInstanceNodeDataEventMerger(); private final ProcessInstanceSLADataEventMerger slaMerger = new ProcessInstanceSLADataEventMerger(); diff --git a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelStorageFetcher.java b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelStorageFetcher.java index cbadc33c59..8ea6b833d4 100644 --- a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelStorageFetcher.java +++ b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelStorageFetcher.java @@ -1,17 +1,46 @@ +/* + * 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.storage; +import java.util.function.Function; + import org.kie.kogito.persistence.api.Storage; import org.kie.kogito.persistence.api.StorageFetcher; import org.kie.kogito.persistence.api.query.Query; import io.smallrye.mutiny.Multi; -public abstract class ModelStorageFetcher implements StorageFetcher { +public abstract class ModelStorageFetcher implements StorageFetcher { protected final Storage storage; + private final Function toString; + private final Function fromString; + public ModelStorageFetcher(Storage storage) { + this(storage, Object::toString, s -> (K) s); + } + + public ModelStorageFetcher(Storage storage, Function toString, Function fromString) { this.storage = storage; + this.toString = toString; + this.fromString = fromString; } @Override @@ -25,8 +54,8 @@ public Multi objectUpdatedListener() { } @Override - public Multi objectRemovedListener() { - return storage.objectRemovedListener(); + public Multi objectRemovedListener() { + return storage.objectRemovedListener().map(fromString); } @Override @@ -35,8 +64,8 @@ public Query query() { } @Override - public V get(String key) { - return storage.get(key); + public V get(K key) { + return storage.get(toString.apply(key)); } @Override diff --git a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelUserTaskInstanceStorage.java b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelUserTaskInstanceStorage.java index d5a46917a7..20f98a396c 100644 --- a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelUserTaskInstanceStorage.java +++ b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/ModelUserTaskInstanceStorage.java @@ -1,3 +1,21 @@ +/* + * 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.storage; import java.util.ArrayList; @@ -19,7 +37,7 @@ import org.kie.kogito.index.storage.merger.UserTaskInstanceVariableDataEventMerger; import org.kie.kogito.persistence.api.Storage; -public class ModelUserTaskInstanceStorage extends ModelStorageFetcher implements UserTaskInstanceStorage { +public class ModelUserTaskInstanceStorage extends ModelStorageFetcher implements UserTaskInstanceStorage { private final UserTaskInstanceAssignmentDataEventMerger assignmentMerger = new UserTaskInstanceAssignmentDataEventMerger(); private final UserTaskInstanceAttachmentDataEventMerger attachmentMerger = new UserTaskInstanceAttachmentDataEventMerger(); diff --git a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceVariableDataEventMerger.java b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceVariableDataEventMerger.java index f6ae8df0a7..d6102ec7b4 100644 --- a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceVariableDataEventMerger.java +++ b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceVariableDataEventMerger.java @@ -18,9 +18,6 @@ */ package org.kie.kogito.index.storage.merger; -import java.util.HashMap; -import java.util.Map; - import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; import org.kie.kogito.event.process.ProcessInstanceVariableEventBody; @@ -29,9 +26,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - import jakarta.enterprise.context.ApplicationScoped; @ApplicationScoped @@ -44,23 +38,8 @@ public class ProcessInstanceVariableDataEventMerger extends ProcessInstanceEvent public ProcessInstance merge(ProcessInstance pi, ProcessInstanceDataEvent data) { pi = getOrNew(pi, data); ProcessInstanceVariableDataEvent event = (ProcessInstanceVariableDataEvent) data; - try { - ProcessInstanceVariableEventBody body = event.getData(); - ObjectMapper mapper = JsonUtils.getObjectMapper(); - - Map variables = null; - if (pi.getVariables() == null) { - variables = new HashMap<>(); - } else { - variables = new HashMap<>(mapper.treeToValue(pi.getVariables(), HashMap.class)); - } - variables.put(body.getVariableName(), body.getVariableValue()); - pi.setVariables(mapper.valueToTree(variables)); - } catch (JsonProcessingException e) { - LOGGER.error("error during unmarshalling variable instance", e); - } catch (IllegalArgumentException e) { - LOGGER.error("error during merging variable instance event", e); - } + ProcessInstanceVariableEventBody body = event.getData(); + pi.setVariables(JsonUtils.mergeVariable(body.getVariableName(), body.getVariableValue(), pi.getVariables())); return pi; } } diff --git a/data-index/data-index-storage/data-index-storage-common/src/test/java/org/kie/kogito/index/storage/ModelDataIndexStorageServiceTest.java b/data-index/data-index-storage/data-index-storage-common/src/test/java/org/kie/kogito/index/storage/ModelDataIndexStorageServiceTest.java new file mode 100644 index 0000000000..64ab4b0d74 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-common/src/test/java/org/kie/kogito/index/storage/ModelDataIndexStorageServiceTest.java @@ -0,0 +1,36 @@ +package org.kie.kogito.index.storage; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; +import org.kie.kogito.index.model.ProcessDefinitionKey; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ModelDataIndexStorageServiceTest { + + @Test + void testIdAndVersion() { + assertKeyConversion(new ProcessDefinitionKey("Javierito", "1_0")); + } + + @Test + void testIdEmptyVersion() { + assertKeyConversion(new ProcessDefinitionKey("Javierito", "")); + } + + @Test + void testIdNullVersion() { + assertKeyConversion(new ProcessDefinitionKey("Javierito", null)); + } + + private void assertKeyConversion(ProcessDefinitionKey key) { + Set set = new HashSet<>(); + set.add(key); + ProcessDefinitionKey deserializedKey = ModelProcessDefinitionStorage.fromString(ModelProcessDefinitionStorage.toString(key)); + set.add(deserializedKey); + assertThat(deserializedKey).isEqualTo(key); + assertThat(set).hasSize(1); + } +} diff --git a/data-index/data-index-storage/data-index-storage-oracle/pom.xml b/data-index/data-index-storage/data-index-storage-jpa-common/pom.xml similarity index 58% rename from data-index/data-index-storage/data-index-storage-oracle/pom.xml rename to data-index/data-index-storage/data-index-storage-jpa-common/pom.xml index 2873f885be..061ed01c10 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/pom.xml +++ b/data-index/data-index-storage/data-index-storage-jpa-common/pom.xml @@ -29,21 +29,30 @@ 4.0.0 - data-index-storage-oracle - Kogito Apps :: Data Index Storage Oracle DB + data-index-storage-jpa-common + Kogito Apps :: Data Index Storage JPA common classes - org.kie.kogito.index.oracle + org.kie.kogito.index.jpa.common + org.kie.kogito - data-index-storage-jpa + data-index-storage-api - io.quarkus - quarkus-jdbc-oracle + org.kie.kogito + data-index-common + + + org.kie.kogito + persistence-commons-jpa + + + org.mapstruct + mapstruct org.kie.kogito @@ -51,7 +60,7 @@ test-jar test - + io.quarkus quarkus-junit5-mockito test @@ -72,65 +81,33 @@ test + org.apache.maven.plugins - maven-failsafe-plugin + maven-compiler-plugin - - org.jboss.logmanager.LogManager - + + + org.mapstruct + mapstruct-processor + ${version.org.mapstruct} + + + + + org.apache.maven.plugins + maven-jar-plugin - test - integration-test - verify + test-jar - - - - schema - - - generate.schema - - - - - - org.codehaus.mojo - exec-maven-plugin - - - package - - exec - - - - - java - - -classpath - - - org.kie.kogito.index.oracle.schema.DDLSchemaExporter - - test - - - - - - - \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/JobEntityMapper.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/JobEntityMapper.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/JobEntityMapper.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/JobEntityMapper.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessDefinitionEntityMapper.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessDefinitionEntityMapper.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessDefinitionEntityMapper.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessDefinitionEntityMapper.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessInstanceEntityMapper.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessInstanceEntityMapper.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessInstanceEntityMapper.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/ProcessInstanceEntityMapper.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/UserTaskInstanceEntityMapper.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/UserTaskInstanceEntityMapper.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/mapper/UserTaskInstanceEntityMapper.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/mapper/UserTaskInstanceEntityMapper.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/AbstractEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/AbstractEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/AbstractEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/AbstractEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/AttachmentEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/AttachmentEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/AttachmentEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/AttachmentEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/CommentEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/CommentEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/CommentEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/CommentEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/JobEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/JobEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/JobEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/JobEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/JobEntityRepository.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/JobEntityRepository.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/JobEntityRepository.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/JobEntityRepository.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntityId.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntityId.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntityId.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/MilestoneEntityId.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/NodeEntityId.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntityId.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/NodeEntityId.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntityId.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/NodeInstanceEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeInstanceEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/NodeInstanceEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeInstanceEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java similarity index 98% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java index 5ffdec6e26..dd2db761a6 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java @@ -23,6 +23,8 @@ import java.util.Objects; import java.util.Set; +import org.kie.kogito.index.model.ProcessDefinitionKey; + import jakarta.persistence.CascadeType; import jakarta.persistence.CollectionTable; import jakarta.persistence.Column; @@ -38,7 +40,7 @@ @Entity(name = "definitions") @Table(name = "definitions") -@IdClass(ProcessDefinitionEntityId.class) +@IdClass(ProcessDefinitionKey.class) public class ProcessDefinitionEntity extends AbstractEntity { @Id diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityRepository.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityRepository.java similarity index 89% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityRepository.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityRepository.java index a17d92a5fd..c055cba6b5 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityRepository.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntityRepository.java @@ -18,11 +18,13 @@ */ package org.kie.kogito.index.jpa.model; +import org.kie.kogito.index.model.ProcessDefinitionKey; + import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; import jakarta.enterprise.context.ApplicationScoped; @ApplicationScoped -public class ProcessDefinitionEntityRepository implements PanacheRepositoryBase { +public class ProcessDefinitionEntityRepository implements PanacheRepositoryBase { } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntityRepository.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntityRepository.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntityRepository.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceEntityRepository.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceErrorEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceErrorEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceErrorEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessInstanceErrorEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntity.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntity.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntity.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntityRepository.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntityRepository.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntityRepository.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/UserTaskInstanceEntityRepository.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/AbstractJPAStorageFetcher.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/AbstractJPAStorageFetcher.java similarity index 58% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/AbstractJPAStorageFetcher.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/AbstractJPAStorageFetcher.java index 881b7eb516..c8ab20c38f 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/AbstractJPAStorageFetcher.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/AbstractJPAStorageFetcher.java @@ -1,3 +1,21 @@ +/* + * 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.jpa.storage; import java.util.function.Function; @@ -11,18 +29,18 @@ import jakarta.transaction.Transactional; -public class AbstractJPAStorageFetcher implements StorageFetcher { +public class AbstractJPAStorageFetcher implements StorageFetcher { private static final String LISTENER_NOT_AVAILABLE_IN_JPA = "Listener not available in JPA database"; - protected PanacheRepositoryBase repository; + protected PanacheRepositoryBase repository; protected Class entityClass; protected Function mapToModel; protected AbstractJPAStorageFetcher() { } - protected AbstractJPAStorageFetcher(PanacheRepositoryBase repository, Class entityClass, Function mapToModel) { + protected AbstractJPAStorageFetcher(PanacheRepositoryBase repository, Class entityClass, Function mapToModel) { this.repository = repository; this.entityClass = entityClass; this.mapToModel = mapToModel; @@ -39,7 +57,7 @@ public Multi objectUpdatedListener() { } @Override - public Multi objectRemovedListener() { + public Multi objectRemovedListener() { throw new UnsupportedOperationException(LISTENER_NOT_AVAILABLE_IN_JPA); } @@ -50,7 +68,7 @@ public Query query() { @Override @Transactional - public V get(String key) { + public V get(K key) { return repository.findByIdOptional(key).map(mapToModel).orElse(null); } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/AbstractStorage.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/AbstractStorage.java similarity index 59% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/AbstractStorage.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/AbstractStorage.java index abae372ebe..de426fc4ef 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/AbstractStorage.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/AbstractStorage.java @@ -18,7 +18,6 @@ */ package org.kie.kogito.index.jpa.storage; -import java.util.ConcurrentModificationException; import java.util.Map; import java.util.function.Function; @@ -27,24 +26,22 @@ import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; -import jakarta.persistence.LockModeType; -import jakarta.persistence.PersistenceException; import jakarta.transaction.Transactional; import static java.util.stream.Collectors.toMap; -public abstract class AbstractStorage extends AbstractJPAStorageFetcher implements Storage { +public abstract class AbstractStorage extends AbstractJPAStorageFetcher implements Storage { private Class modelClass; private Function mapToEntity; - private Function mapEntityToKey; + private Function mapEntityToKey; protected AbstractStorage() { } - protected AbstractStorage(PanacheRepositoryBase repository, Class modelClass, Class entityClass, Function mapToModel, - Function mapToEntity, Function mapEntityToKey) { + protected AbstractStorage(PanacheRepositoryBase repository, Class modelClass, Class entityClass, Function mapToModel, + Function mapToEntity, Function mapEntityToKey) { super(repository, entityClass, mapToModel); this.modelClass = modelClass; this.mapToEntity = mapToEntity; @@ -53,26 +50,14 @@ protected AbstractStorage(PanacheRepositoryBase repository, Class @Override @Transactional - public V put(String key, V value) { - //Pessimistic lock is used to lock the row to handle concurrency with an exiting registry - E persistedEntity = repository.findById(key, LockModeType.PESSIMISTIC_WRITE); - E newEntity = mapToEntity.apply(value); - if (persistedEntity != null) { - repository.getEntityManager().merge(newEntity); - } else { - try { - //to handle concurrency in case of a new registry persist flush and throw an exception to allow retry on the caller side - repository.persistAndFlush(newEntity); - } catch (PersistenceException e) { - throw new ConcurrentModificationException(e); - } - } + public V put(K key, V value) { + repository.getEntityManager().merge(mapToEntity.apply(value)); return value; } @Override @Transactional - public V remove(String key) { + public V remove(K key) { V value = get(key); if (value != null) { repository.deleteById(key); @@ -82,12 +67,12 @@ public V remove(String key) { @Transactional @Override - public boolean containsKey(String key) { + public boolean containsKey(K key) { return repository.count("id = ?1", key) == 1; } @Override - public Map entries() { + public Map entries() { return repository.streamAll().collect(toMap(mapEntityToKey, mapToModel)); } @@ -102,7 +87,7 @@ public String getRootType() { return modelClass.getCanonicalName(); } - protected PanacheRepositoryBase getRepository() { + protected PanacheRepositoryBase getRepository() { return repository; } } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPADataIndexStorageService.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPADataIndexStorageService.java similarity index 72% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPADataIndexStorageService.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPADataIndexStorageService.java index 9a726a3a6e..99bbccf0c3 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPADataIndexStorageService.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPADataIndexStorageService.java @@ -20,26 +20,25 @@ import org.kie.kogito.index.model.Job; import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; import org.kie.kogito.index.storage.DataIndexStorageService; import org.kie.kogito.index.storage.ProcessInstanceStorage; import org.kie.kogito.index.storage.UserTaskInstanceStorage; import org.kie.kogito.persistence.api.Storage; -import org.kie.kogito.persistence.api.StorageService; import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import static org.kie.kogito.index.storage.Constants.JOBS_STORAGE; -import static org.kie.kogito.index.storage.Constants.PROCESS_DEFINITIONS_STORAGE; -import static org.kie.kogito.index.storage.Constants.PROCESS_ID_MODEL_STORAGE; - @ApplicationScoped public class JPADataIndexStorageService implements DataIndexStorageService { @Inject - StorageService storageService; + ProcessDefinitionEntityStorage definitionStorage; + + @Inject + JobEntityStorage jobsStorage; @Inject ProcessInstanceStorage processInstanceStorage; @@ -48,8 +47,8 @@ public class JPADataIndexStorageService implements DataIndexStorageService { UserTaskInstanceStorage userTaskInstanceStorage; @Override - public Storage getProcessDefinitionStorage() { - return storageService.getCache(PROCESS_DEFINITIONS_STORAGE, ProcessDefinition.class); + public Storage getProcessDefinitionStorage() { + return definitionStorage; } @Override @@ -64,13 +63,12 @@ public UserTaskInstanceStorage getUserTaskInstanceStorage() { @Override public Storage getJobsStorage() { - return storageService.getCache(JOBS_STORAGE, Job.class); + return jobsStorage; } @Override public Storage getDomainModelCache(String processId) { - String rootType = getProcessIdModelCache().get(processId); - return rootType == null ? null : storageService.getCache(getDomainModelCacheName(processId), ObjectNode.class, rootType); + throw new UnsupportedOperationException("Generic custom type cache not available in JPA"); } @Override @@ -80,6 +78,6 @@ public String getDomainModelCacheName(String processId) { @Override public Storage getProcessIdModelCache() { - return storageService.getCache(PROCESS_ID_MODEL_STORAGE); + throw new UnsupportedOperationException("Generic String cache not available in JPA"); } } diff --git a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/OracleDateTimeCoercing.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPADateTimeCoercing.java similarity index 80% rename from data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/OracleDateTimeCoercing.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPADateTimeCoercing.java index 1c604cae29..6ac9ef2dd4 100644 --- a/data-index/data-index-graphql/src/main/java/org/kie/kogito/index/graphql/OracleDateTimeCoercing.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPADateTimeCoercing.java @@ -16,20 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.graphql; +package org.kie.kogito.index.jpa.storage; import java.time.ZonedDateTime; -import io.quarkus.arc.properties.IfBuildProperty; +import org.kie.kogito.index.api.DateTimeCoercing; +import org.kie.kogito.index.api.DefaultDateTimeCoercing; import graphql.language.StringValue; import jakarta.enterprise.context.ApplicationScoped; -import static org.kie.kogito.persistence.api.factory.Constants.PERSISTENCE_TYPE_PROPERTY; - @ApplicationScoped -@IfBuildProperty(name = PERSISTENCE_TYPE_PROPERTY, stringValue = "oracle") -public class OracleDateTimeCoercing extends DefaultDateTimeCoercing implements DateTimeCoercing { +public class JPADateTimeCoercing extends DefaultDateTimeCoercing implements DateTimeCoercing { @Override public Object parseValue(Object input) { diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPAQuery.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPAQuery.java similarity index 100% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPAQuery.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JPAQuery.java diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JobEntityStorage.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JobEntityStorage.java similarity index 94% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JobEntityStorage.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JobEntityStorage.java index 697ed00c33..f5b9c270dd 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JobEntityStorage.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/JobEntityStorage.java @@ -28,7 +28,7 @@ import jakarta.inject.Inject; @ApplicationScoped -public class JobEntityStorage extends AbstractStorage { +public class JobEntityStorage extends AbstractStorage { protected JobEntityStorage() { } diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessDefinitionEntityStorage.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessDefinitionEntityStorage.java new file mode 100644 index 0000000000..e22670c665 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessDefinitionEntityStorage.java @@ -0,0 +1,49 @@ +/* + * 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.jpa.storage; + +import org.kie.kogito.index.jpa.mapper.ProcessDefinitionEntityMapper; +import org.kie.kogito.index.jpa.model.ProcessDefinitionEntity; +import org.kie.kogito.index.jpa.model.ProcessDefinitionEntityRepository; +import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@ApplicationScoped +public class ProcessDefinitionEntityStorage extends AbstractStorage { + + protected ProcessDefinitionEntityStorage() { + } + + @Inject + public ProcessDefinitionEntityStorage(ProcessDefinitionEntityRepository repository, ProcessDefinitionEntityMapper mapper) { + super(repository, ProcessDefinition.class, ProcessDefinitionEntity.class, mapper::mapToModel, mapper::mapToEntity, e -> new ProcessDefinitionKey(e.getId(), + e.getVersion())); + } + + @Transactional + @Override + public boolean containsKey(ProcessDefinitionKey key) { + return getRepository().count("id = ?1 and version = ?2", key.getId(), key.getVersion()) == 1; + } + +} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java similarity index 93% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java index f86570fbd4..5ae222d0b6 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java @@ -38,13 +38,10 @@ import org.kie.kogito.index.jpa.model.ProcessInstanceEntity; import org.kie.kogito.index.jpa.model.ProcessInstanceEntityRepository; import org.kie.kogito.index.jpa.model.ProcessInstanceErrorEntity; +import org.kie.kogito.index.json.JsonUtils; import org.kie.kogito.index.model.MilestoneStatus; import org.kie.kogito.index.model.ProcessInstance; import org.kie.kogito.index.storage.ProcessInstanceStorage; -import org.kie.kogito.jackson.utils.JsonObjectUtils; -import org.kie.kogito.jackson.utils.ObjectMapperFactory; - -import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; @@ -55,7 +52,7 @@ import static org.kie.kogito.index.DateTimeUtils.toZonedDateTime; @ApplicationScoped -public class ProcessInstanceEntityStorage extends AbstractJPAStorageFetcher implements ProcessInstanceStorage { +public class ProcessInstanceEntityStorage extends AbstractJPAStorageFetcher implements ProcessInstanceStorage { protected ProcessInstanceEntityStorage() { } @@ -203,13 +200,8 @@ private void indexState(ProcessInstanceStateEventBody data, Set addons, private void indexVariable(ProcessInstanceVariableEventBody data) { ProcessInstanceEntity pi = findOrInit(data.getProcessId(), data.getProcessInstanceId()); - ObjectNode node = pi.getVariables(); - if (node == null) { - node = ObjectMapperFactory.get().createObjectNode(); - } - node.set(data.getVariableName(), JsonObjectUtils.fromValue(data.getVariableValue())); - // Object node is not tracked, need explicit set - pi.setVariables(node); + pi.setVariables(JsonUtils.mergeVariable(data.getVariableName(), data.getVariableValue(), pi.getVariables())); repository.flush(); } + } diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/UserTaskInstanceEntityStorage.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/UserTaskInstanceEntityStorage.java similarity index 99% rename from data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/UserTaskInstanceEntityStorage.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/UserTaskInstanceEntityStorage.java index 4d5cc47003..1e2c127a36 100644 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/UserTaskInstanceEntityStorage.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/UserTaskInstanceEntityStorage.java @@ -56,7 +56,7 @@ import static org.kie.kogito.index.DateTimeUtils.toZonedDateTime; @ApplicationScoped -public class UserTaskInstanceEntityStorage extends AbstractJPAStorageFetcher implements UserTaskInstanceStorage { +public class UserTaskInstanceEntityStorage extends AbstractJPAStorageFetcher implements UserTaskInstanceStorage { protected UserTaskInstanceEntityStorage() { } diff --git a/data-index/data-index-service/data-index-service-oracle/src/main/resources/META-INF/beans.xml b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/resources/META-INF/beans.xml similarity index 100% rename from data-index/data-index-service/data-index-service-oracle/src/main/resources/META-INF/beans.xml rename to data-index/data-index-storage/data-index-storage-jpa-common/src/main/resources/META-INF/beans.xml diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/JobEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractJobEntityMapperIT.java similarity index 95% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/JobEntityMapperIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractJobEntityMapperIT.java index a7504f914f..dd8477855d 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/JobEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractJobEntityMapperIT.java @@ -16,24 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.mapper; +package org.kie.kogito.index.jpa.mapper; import java.time.ZonedDateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.JobEntityMapper; import org.kie.kogito.index.jpa.model.JobEntity; import org.kie.kogito.index.model.Job; -import io.quarkus.test.junit.QuarkusTest; - import jakarta.inject.Inject; import static org.assertj.core.api.Assertions.assertThat; -@QuarkusTest -class JobEntityMapperIT { +public abstract class AbstractJobEntityMapperIT { @Inject JobEntityMapper mapper; diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessDefinitionEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractProcessDefinitionEntityMapperIT.java similarity index 94% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessDefinitionEntityMapperIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractProcessDefinitionEntityMapperIT.java index 4369de3058..3df75e17bf 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessDefinitionEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractProcessDefinitionEntityMapperIT.java @@ -16,20 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.mapper; +package org.kie.kogito.index.jpa.mapper; import java.util.Set; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.ProcessDefinitionEntityMapper; import org.kie.kogito.index.jpa.model.NodeEntity; import org.kie.kogito.index.jpa.model.ProcessDefinitionEntity; import org.kie.kogito.index.model.Node; import org.kie.kogito.index.model.ProcessDefinition; -import io.quarkus.test.junit.QuarkusTest; - import jakarta.inject.Inject; import static java.util.Collections.singleton; @@ -37,8 +34,7 @@ import static java.util.Collections.singletonMap; import static org.assertj.core.api.Assertions.assertThat; -@QuarkusTest -class ProcessDefinitionEntityMapperIT { +public abstract class AbstractProcessDefinitionEntityMapperIT { ProcessDefinition pd = new ProcessDefinition(); ProcessDefinitionEntity entity = new ProcessDefinitionEntity(); diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessInstanceEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractProcessInstanceEntityMapperIT.java similarity index 96% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessInstanceEntityMapperIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractProcessInstanceEntityMapperIT.java index 95840d7e1a..1bb4b5a64f 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessInstanceEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractProcessInstanceEntityMapperIT.java @@ -16,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.mapper; +package org.kie.kogito.index.jpa.mapper; import java.time.ZonedDateTime; import java.util.Set; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.ProcessInstanceEntityMapper; import org.kie.kogito.index.jpa.model.MilestoneEntity; import org.kie.kogito.index.jpa.model.MilestoneEntityId; import org.kie.kogito.index.jpa.model.NodeInstanceEntity; @@ -37,16 +36,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import io.quarkus.test.junit.QuarkusTest; - import jakarta.inject.Inject; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -@QuarkusTest -class ProcessInstanceEntityMapperIT { +public abstract class AbstractProcessInstanceEntityMapperIT { ObjectMapper jsonMapper = new ObjectMapper(); ProcessInstance processInstance = new ProcessInstance(); @@ -72,7 +68,6 @@ void setup() { String testId = "testId"; String processId = "testProcessId"; - String version = "1.0"; Set roles = singleton("testRoles"); ObjectNode variables = jsonMapper.createObjectNode(); variables.put("test", "testValue"); @@ -108,7 +103,6 @@ void setup() { processInstance.setId(testId); processInstance.setProcessId(processId); - processInstance.setVersion(version); processInstance.setRoles(roles); processInstance.setVariables(variables); processInstance.setEndpoint(endpoint); @@ -153,7 +147,6 @@ void setup() { processInstanceEntity.setId(testId); processInstanceEntity.setProcessId(processId); - processInstanceEntity.setVersion(version); processInstanceEntity.setRoles(roles); processInstanceEntity.setVariables(variables); processInstanceEntity.setEndpoint(endpoint); @@ -169,9 +162,9 @@ void setup() { processInstanceEntity.setAddons(addons); processInstanceEntity.setLastUpdate(time); processInstanceEntity.setBusinessKey(businessKey); + processInstanceEntity.setMilestones(singletonList(milestoneEntity)); processInstanceEntity.setCreatedBy(createdBy); processInstanceEntity.setUpdatedBy(updatedBy); - processInstanceEntity.setMilestones(singletonList(milestoneEntity)); } @Test diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/UserTaskInstanceEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractUserTaskInstanceEntityMapperIT.java similarity index 97% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/UserTaskInstanceEntityMapperIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractUserTaskInstanceEntityMapperIT.java index 167da216df..6d4dd31e24 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/UserTaskInstanceEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/mapper/AbstractUserTaskInstanceEntityMapperIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.mapper; +package org.kie.kogito.index.jpa.mapper; import java.time.ZonedDateTime; import java.util.HashMap; @@ -25,7 +25,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.UserTaskInstanceEntityMapper; import org.kie.kogito.index.jpa.model.AttachmentEntity; import org.kie.kogito.index.jpa.model.CommentEntity; import org.kie.kogito.index.jpa.model.UserTaskInstanceEntity; @@ -36,16 +35,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import io.quarkus.test.junit.QuarkusTest; - import jakarta.inject.Inject; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; -@QuarkusTest -class UserTaskInstanceEntityMapperIT { +public abstract class AbstractUserTaskInstanceEntityMapperIT { UserTaskInstance userTaskInstance = new UserTaskInstance(); UserTaskInstanceEntity userTaskInstanceEntity = new UserTaskInstanceEntity(); diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/JobEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractJobEntityQueryIT.java similarity index 77% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/JobEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractJobEntityQueryIT.java index fe12f79d1d..f07b11b5dd 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/JobEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractJobEntityQueryIT.java @@ -16,22 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.query; +package org.kie.kogito.index.jpa.query; import org.kie.kogito.index.jpa.storage.JobEntityStorage; import org.kie.kogito.index.model.Job; import org.kie.kogito.index.test.query.AbstractJobQueryIT; import org.kie.kogito.persistence.api.Storage; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -class JobEntityQueryIT extends AbstractJobQueryIT { +public abstract class AbstractJobEntityQueryIT extends AbstractJobQueryIT { @Inject JobEntityStorage storage; diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/ProcessDefinitionEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractProcessDefinitionEntityQueryIT.java similarity index 73% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/ProcessDefinitionEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractProcessDefinitionEntityQueryIT.java index f5ab610f09..1c9a84d667 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/ProcessDefinitionEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractProcessDefinitionEntityQueryIT.java @@ -16,28 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.query; +package org.kie.kogito.index.jpa.query; 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.test.query.AbstractProcessDefinitionQueryIT; import org.kie.kogito.persistence.api.Storage; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -class ProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionQueryIT { +public abstract class AbstractProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionQueryIT { @Inject ProcessDefinitionEntityStorage storage; @Override - public Storage getStorage() { + public Storage getStorage() { return storage; } diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/ProcessInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractProcessInstanceEntityQueryIT.java similarity index 71% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/ProcessInstanceEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractProcessInstanceEntityQueryIT.java index 88e898e9c8..f2fc967907 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/ProcessInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractProcessInstanceEntityQueryIT.java @@ -16,20 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.query; +package org.kie.kogito.index.jpa.query; import org.kie.kogito.index.jpa.storage.ProcessInstanceEntityStorage; import org.kie.kogito.index.test.query.AbstractProcessInstanceQueryIT; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -class ProcessInstanceEntityQueryIT extends AbstractProcessInstanceQueryIT { +public abstract class AbstractProcessInstanceEntityQueryIT extends AbstractProcessInstanceQueryIT { @Inject ProcessInstanceEntityStorage storage; @@ -38,9 +32,4 @@ class ProcessInstanceEntityQueryIT extends AbstractProcessInstanceQueryIT { public ProcessInstanceEntityStorage getStorage() { return storage; } - - @Override - protected Boolean isDateTimeAsLong() { - return false; - } } diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/UserTaskInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractUserTaskInstanceEntityQueryIT.java similarity index 77% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/UserTaskInstanceEntityQueryIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractUserTaskInstanceEntityQueryIT.java index 522bd54ad2..347b2765c9 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/query/UserTaskInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/query/AbstractUserTaskInstanceEntityQueryIT.java @@ -16,20 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.query; +package org.kie.kogito.index.jpa.query; import org.kie.kogito.index.jpa.storage.UserTaskInstanceEntityStorage; import org.kie.kogito.index.test.query.AbstractUserTaskInstanceQueryIT; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -class UserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceQueryIT { +public abstract class AbstractUserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceQueryIT { @Inject UserTaskInstanceEntityStorage storage; diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/JobStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractJobStorageIT.java similarity index 72% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/JobStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractJobStorageIT.java index a602ad8c45..2510619cc4 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/JobStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractJobStorageIT.java @@ -16,45 +16,30 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.storage; +package org.kie.kogito.index.jpa.storage; import java.util.UUID; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Test; import org.kie.kogito.index.jpa.model.JobEntity; -import org.kie.kogito.index.jpa.model.JobEntityRepository; import org.kie.kogito.index.model.Job; import org.kie.kogito.index.test.TestUtils; -import org.kie.kogito.persistence.api.StorageService; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; +import org.kie.kogito.persistence.api.Storage; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -public class JobStorageIT extends AbstractStorageIT { - - @Inject - JobEntityRepository repository; +public abstract class AbstractJobStorageIT extends AbstractStorageIT { @Inject - StorageService storage; + JobEntityStorage storage; - public JobStorageIT() { + public AbstractJobStorageIT() { super(Job.class); } @Override - public JobEntityRepository getRepository() { - return repository; - } - - @Override - public StorageService getStorage() { + public Storage getStorage() { return storage; } @@ -71,5 +56,4 @@ public void testJobEntity() { RandomStringUtils.randomAlphabetic(10), "SCHEDULED", 1000L); testStorage(jobId, job1, job2); } - } diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/ProcessDefinitionStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessDefinitionStorageIT.java similarity index 60% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/ProcessDefinitionStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessDefinitionStorageIT.java index 7d915b5fed..bba2ee7e7c 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/ProcessDefinitionStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessDefinitionStorageIT.java @@ -16,56 +16,41 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.storage; +package org.kie.kogito.index.jpa.storage; import java.util.Set; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Test; import org.kie.kogito.index.jpa.model.ProcessDefinitionEntity; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntityRepository; -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.test.TestUtils; -import org.kie.kogito.persistence.api.StorageService; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; +import org.kie.kogito.persistence.api.Storage; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -class ProcessDefinitionStorageIT extends AbstractStorageIT { - - @Inject - ProcessDefinitionEntityRepository repository; +public abstract class AbstractProcessDefinitionStorageIT extends AbstractStorageIT { @Inject - StorageService storage; + ProcessDefinitionEntityStorage storage; - public ProcessDefinitionStorageIT() { + public AbstractProcessDefinitionStorageIT() { super(ProcessDefinition.class); } @Override - public ProcessDefinitionEntityStorage.RepositoryAdapter getRepository() { - return new ProcessDefinitionEntityStorage.RepositoryAdapter(repository); - } - - @Override - public StorageService getStorage() { + public Storage getStorage() { return storage; } @Test - void testProcessInstanceEntity() { + void testProcessDefinitionEntity() { String processId = RandomStringUtils.randomAlphabetic(10); String version = "1.0"; ProcessDefinition pdv1 = TestUtils.createProcessDefinition(processId, version, Set.of("admin", "kogito")); ProcessDefinition pdv2 = TestUtils.createProcessDefinition(processId, version, Set.of("kogito")); - testStorage(pdv1.getKey(), pdv1, pdv2); + testStorage(new ProcessDefinitionKey(pdv1.getId(), pdv1.getVersion()), pdv1, pdv2); } } diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/ProcessInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java similarity index 84% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/ProcessInstanceStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java index 1772743048..1ea09ce497 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/ProcessInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractProcessInstanceStorageIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.storage; +package org.kie.kogito.index.jpa.storage; import java.util.UUID; @@ -25,16 +25,10 @@ import org.kie.kogito.index.jpa.model.ProcessInstanceEntityRepository; import org.kie.kogito.index.model.ProcessInstanceState; import org.kie.kogito.index.test.TestUtils; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -public class ProcessInstanceStorageIT { +public abstract class AbstractProcessInstanceStorageIT { @Inject ProcessInstanceEntityRepository repository; diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/AbstractStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractStorageIT.java similarity index 77% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/AbstractStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractStorageIT.java index b50ff27551..165ce328dd 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/AbstractStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractStorageIT.java @@ -16,17 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.storage; +package org.kie.kogito.index.jpa.storage; import org.kie.kogito.index.jpa.model.AbstractEntity; import org.kie.kogito.persistence.api.Storage; -import org.kie.kogito.persistence.api.StorageService; - -import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; import static org.assertj.core.api.Assertions.assertThat; -public abstract class AbstractStorageIT { +public abstract class AbstractStorageIT { Class type; @@ -34,12 +31,10 @@ public AbstractStorageIT(Class type) { this.type = type; } - abstract StorageService getStorage(); - - abstract PanacheRepositoryBase getRepository(); + abstract Storage getStorage(); - void testStorage(String key, T value1, T value2) { - Storage cache = getStorage().getCache("cache", type); + void testStorage(K key, T value1, T value2) { + Storage cache = getStorage(); assertThat(cache.get(key)).isNull(); assertThat(cache.containsKey(key)).isFalse(); diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/UserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java similarity index 68% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/UserTaskInstanceStorageIT.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java index 0784f6d106..9b8c0056c9 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/UserTaskInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/AbstractUserTaskInstanceStorageIT.java @@ -16,28 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.storage; +package org.kie.kogito.index.jpa.storage; import java.util.UUID; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Test; import org.kie.kogito.index.jpa.model.UserTaskInstanceEntityRepository; -import org.kie.kogito.index.model.UserTaskInstance; import org.kie.kogito.index.test.TestUtils; -import org.kie.kogito.testcontainers.quarkus.OracleSqlQuarkusTestResource; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -@QuarkusTest -@QuarkusTestResource(OracleSqlQuarkusTestResource.class) -public class UserTaskInstanceStorageIT { +public abstract class AbstractUserTaskInstanceStorageIT { @Inject UserTaskInstanceEntityRepository repository; @@ -46,14 +36,14 @@ public class UserTaskInstanceStorageIT { public void testUserTaskInstanceEntity() { String taskId = UUID.randomUUID().toString(); String processInstanceId = UUID.randomUUID().toString(); - UserTaskInstance userTaskInstance1 = TestUtils + TestUtils .createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "InProgress", 0L); - ObjectMapper objectMapper = new ObjectMapper(); - ObjectNode node = objectMapper.createObjectNode(); - node.put("test", "test"); - userTaskInstance1.setInputs(node); + TestUtils + .createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), + UUID.randomUUID().toString(), + RandomStringUtils.randomAlphabetic(10), "Completed", 1000L); } } diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/DomainQueryTest.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/DomainQueryTest.java similarity index 98% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/DomainQueryTest.java rename to data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/DomainQueryTest.java index 768f872612..10657a8bc3 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/storage/DomainQueryTest.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/test/java/org/kie/kogito/index/jpa/storage/DomainQueryTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle.storage; +package org.kie.kogito.index.jpa.storage; import java.util.List; import java.util.function.Function; @@ -25,7 +25,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.kie.kogito.index.jpa.model.ProcessInstanceEntity; -import org.kie.kogito.index.jpa.storage.JPAQuery; import org.kie.kogito.index.model.ProcessInstance; import org.mockito.ArgumentCaptor; import org.mockito.Mock; 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 92f011dd68..1a925152c0 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 @@ -30,46 +30,83 @@ 4.0.0 data-index-storage-jpa - Kogito Apps :: Data Index Storage JPA + Kogito Apps :: Data Index Storage JPA compatible DBs org.kie.kogito.index.jpa - + org.kie.kogito - data-index-storage-api + data-index-storage-jpa-common + + + io.quarkus + quarkus-test-h2 + test - org.kie.kogito - data-index-common + io.quarkus + quarkus-jdbc-h2 org.kie.kogito - persistence-commons-jpa + data-index-storage-api + test-jar + test + ${project.version} + + + org.kie.kogito + data-index-storage-jpa-common + test-jar + test + ${project.version} + + + io.quarkus + quarkus-junit5-mockito + test - org.mapstruct - mapstruct + org.assertj + assertj-core + test + + + org.mockito + mockito-junit-jupiter + test + + + org.kie.kogito + kogito-quarkus-test-utils + test - org.apache.maven.plugins - maven-compiler-plugin + maven-failsafe-plugin - - - org.mapstruct - mapstruct-processor - ${version.org.mapstruct} - - + + org.jboss.logmanager.LogManager + + + + test + + integration-test + verify + + + + + \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/JsonBinaryConverter.java b/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jdbc/JsonBinaryConverter.java similarity index 97% rename from data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/JsonBinaryConverter.java rename to data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jdbc/JsonBinaryConverter.java index 5701e70dc0..586f60ed18 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/JsonBinaryConverter.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jdbc/JsonBinaryConverter.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.oracle; +package org.kie.kogito.index.jdbc; import java.io.IOException; import java.io.UncheckedIOException; diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPAStorageService.java b/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPAStorageService.java deleted file mode 100644 index 89446436fa..0000000000 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/JPAStorageService.java +++ /dev/null @@ -1,73 +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. - */ -package org.kie.kogito.index.jpa.storage; - -import org.kie.kogito.index.model.Job; -import org.kie.kogito.index.model.ProcessDefinition; -import org.kie.kogito.index.model.ProcessInstance; -import org.kie.kogito.index.model.UserTaskInstance; -import org.kie.kogito.persistence.api.Storage; -import org.kie.kogito.persistence.api.StorageService; - -import static java.lang.String.format; - -public class JPAStorageService implements StorageService { - - private ProcessDefinitionEntityStorage definitionStorage; - private ProcessInstanceEntityStorage processStorage; - private JobEntityStorage jobStorage; - private UserTaskInstanceEntityStorage taskStorage; - - public JPAStorageService(final ProcessDefinitionEntityStorage definitionStorage, - final ProcessInstanceEntityStorage processStorage, - final JobEntityStorage jobStorage, - final UserTaskInstanceEntityStorage taskStorage) { - this.definitionStorage = definitionStorage; - this.processStorage = processStorage; - this.jobStorage = jobStorage; - this.taskStorage = taskStorage; - } - - @Override - public Storage getCache(String name) { - throw new UnsupportedOperationException("Generic String cache not available in PostgresSQL"); - } - - @Override - public Storage getCache(String name, Class type) { - if (type == ProcessInstance.class) { - return (Storage) processStorage; - } - if (type == ProcessDefinition.class) { - return (Storage) definitionStorage; - } - if (type == Job.class) { - return (Storage) jobStorage; - } - if (type == UserTaskInstance.class) { - return (Storage) taskStorage; - } - throw new UnsupportedOperationException(format("Unknown class type: %s, cache not available", type.getCanonicalName())); - } - - @Override - public Storage getCache(String name, Class type, String rootType) { - throw new UnsupportedOperationException("Generic custom type cache not available in PostgresSQL"); - } -} diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/ProcessDefinitionEntityStorage.java b/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/ProcessDefinitionEntityStorage.java deleted file mode 100644 index 1bbe7d546c..0000000000 --- a/data-index/data-index-storage/data-index-storage-jpa/src/main/java/org/kie/kogito/index/jpa/storage/ProcessDefinitionEntityStorage.java +++ /dev/null @@ -1,89 +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. - */ -package org.kie.kogito.index.jpa.storage; - -import java.util.Optional; - -import org.kie.kogito.index.jpa.mapper.ProcessDefinitionEntityMapper; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntity; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntityId; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntityRepository; -import org.kie.kogito.index.model.ProcessDefinition; - -import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import jakarta.persistence.EntityManager; -import jakarta.persistence.LockModeType; -import jakarta.transaction.Transactional; - -@ApplicationScoped -public class ProcessDefinitionEntityStorage extends AbstractStorage { - - protected ProcessDefinitionEntityStorage() { - } - - @Inject - public ProcessDefinitionEntityStorage(ProcessDefinitionEntityRepository repository, ProcessDefinitionEntityMapper mapper) { - super(new RepositoryAdapter(repository), ProcessDefinition.class, ProcessDefinitionEntity.class, mapper::mapToModel, mapper::mapToEntity, e -> new ProcessDefinitionEntityId(e.getId(), - e.getVersion()).getKey()); - } - - @Transactional - @Override - public boolean containsKey(String key) { - ProcessDefinitionEntityId id = new ProcessDefinitionEntityId(key); - return getRepository().count("id = ?1 and version = ?2", id.getId(), id.getVersion()) == 1; - } - - public static class RepositoryAdapter implements PanacheRepositoryBase { - - ProcessDefinitionEntityRepository repository; - - public RepositoryAdapter(ProcessDefinitionEntityRepository repository) { - this.repository = repository; - } - - @Override - public boolean deleteById(String key) { - return repository.deleteById(new ProcessDefinitionEntityId(key)); - } - - @Override - public Optional findByIdOptional(String key) { - return repository.findByIdOptional(new ProcessDefinitionEntityId(key)); - } - - @Override - public ProcessDefinitionEntity findById(String s, LockModeType lockModeType) { - return repository.findById(new ProcessDefinitionEntityId(s), lockModeType); - } - - @Override - public void persist(ProcessDefinitionEntity entity) { - repository.persist(entity); - } - - @Override - public EntityManager getEntityManager() { - return repository.getEntityManager(); - } - } -} diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/META-INF/orm.xml b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml similarity index 78% rename from data-index/data-index-storage/data-index-storage-oracle/src/main/resources/META-INF/orm.xml rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml index ff5279f699..2e9789c752 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/META-INF/orm.xml +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/META-INF/orm.xml @@ -7,7 +7,7 @@ - + @@ -15,11 +15,11 @@ - + - + @@ -27,7 +27,7 @@ - + diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.33.0__data_index_create.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.33.0__data_index_create.sql similarity index 100% rename from data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.33.0__data_index_create.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.33.0__data_index_create.sql diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql similarity index 100% rename from data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.44.0__data_index_definitions.sql diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql similarity index 100% rename from data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.0__data_index_node_definitions.sql diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.45.0.1__add_identity_to_process_instance.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.1__add_identity_to_process_instance.sql similarity index 100% rename from data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.45.0.1__add_identity_to_process_instance.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.1__add_identity_to_process_instance.sql diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_collums.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_collums.sql similarity index 100% rename from data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_collums.sql rename to data-index/data-index-storage/data-index-storage-jpa/src/main/resources/db/migration/V1.45.0.2__data_index_definitions_add_collums.sql diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingKafkaConsumerIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/JobEntityMapperIT.java similarity index 75% rename from data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingKafkaConsumerIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/JobEntityMapperIT.java index ee54c4274a..5d85af3fcd 100644 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingKafkaConsumerIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/JobEntityMapperIT.java @@ -16,15 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.service.messaging; +package org.kie.kogito.index.jdbc.mapper; -import org.kie.kogito.index.service.test.KafkaMessageTestProfile; +import org.kie.kogito.index.jpa.mapper.AbstractJobEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.TestProfile; @QuarkusTest -@TestProfile(KafkaMessageTestProfile.class) -class OracleMessagingKafkaConsumerIT extends AbstractMessagingKafkaConsumerIT { - +class JobEntityMapperIT extends AbstractJobEntityMapperIT { } diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingHttpConsumerIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/ProcessDefinitionEntityMapperIT.java similarity index 75% rename from data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingHttpConsumerIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/ProcessDefinitionEntityMapperIT.java index 1a255cf16d..f2ea4d334b 100644 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/messaging/OracleMessagingHttpConsumerIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/ProcessDefinitionEntityMapperIT.java @@ -16,15 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.service.messaging; +package org.kie.kogito.index.jdbc.mapper; -import org.kie.kogito.index.service.test.InMemoryMessageTestProfile; +import org.kie.kogito.index.jpa.mapper.AbstractProcessDefinitionEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.TestProfile; @QuarkusTest -@TestProfile(InMemoryMessageTestProfile.class) -class OracleMessagingHttpConsumerIT extends AbstractMessagingHttpConsumerIT { - +class ProcessDefinitionEntityMapperIT extends AbstractProcessDefinitionEntityMapperIT { } diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/OracleIndexingServiceIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/ProcessInstanceEntityMapperIT.java similarity index 76% rename from data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/OracleIndexingServiceIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/ProcessInstanceEntityMapperIT.java index 436ba483ca..5c3230ddbe 100644 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/OracleIndexingServiceIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/ProcessInstanceEntityMapperIT.java @@ -16,15 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.service; +package org.kie.kogito.index.jdbc.mapper; -import org.kie.kogito.index.service.test.InMemoryMessageTestProfile; +import org.kie.kogito.index.jpa.mapper.AbstractProcessInstanceEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.TestProfile; @QuarkusTest -@TestProfile(InMemoryMessageTestProfile.class) -class OracleIndexingServiceIT extends AbstractIndexingServiceIT { +class ProcessInstanceEntityMapperIT extends AbstractProcessInstanceEntityMapperIT { } diff --git a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/KeycloakOracleIndexingServiceIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/UserTaskInstanceEntityMapperIT.java similarity index 75% rename from data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/KeycloakOracleIndexingServiceIT.java rename to data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/UserTaskInstanceEntityMapperIT.java index d5b17e14b8..64131ffe24 100644 --- a/data-index/data-index-service/data-index-service-oracle/src/test/java/org/kie/kogito/index/service/KeycloakOracleIndexingServiceIT.java +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/mapper/UserTaskInstanceEntityMapperIT.java @@ -16,15 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.index.service; +package org.kie.kogito.index.jdbc.mapper; -import org.kie.kogito.index.service.test.KeycloakTestProfile; +import org.kie.kogito.index.jpa.mapper.AbstractUserTaskInstanceEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.TestProfile; @QuarkusTest -@TestProfile(KeycloakTestProfile.class) -class KeycloakOracleIndexingServiceIT extends AbstractKeycloakIntegrationIndexingServiceIT { +class UserTaskInstanceEntityMapperIT extends AbstractUserTaskInstanceEntityMapperIT { } 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/JobEntityQueryIT.java new file mode 100644 index 0000000000..a99c7eeabd --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/JobEntityQueryIT.java @@ -0,0 +1,31 @@ +/* + * 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.jpa.query.AbstractJobEntityQueryIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +class JobEntityQueryIT 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/ProcessDefinitionEntityQueryIT.java new file mode 100644 index 0000000000..c99803b83a --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessDefinitionEntityQueryIT.java @@ -0,0 +1,31 @@ +/* + * 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.jpa.query.AbstractProcessDefinitionEntityQueryIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +class ProcessDefinitionEntityQueryIT 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/ProcessInstanceEntityQueryIT.java new file mode 100644 index 0000000000..10bd679b53 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/ProcessInstanceEntityQueryIT.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.query; + +import org.kie.kogito.index.jpa.query.AbstractProcessInstanceEntityQueryIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +class ProcessInstanceEntityQueryIT 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/UserTaskInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java new file mode 100644 index 0000000000..abaffc8741 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/query/UserTaskInstanceEntityQueryIT.java @@ -0,0 +1,31 @@ +/* + * 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.jpa.query.AbstractUserTaskInstanceEntityQueryIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +class UserTaskInstanceEntityQueryIT 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/JobStorageIT.java new file mode 100644 index 0000000000..88c5db0fbb --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/JobStorageIT.java @@ -0,0 +1,31 @@ +/* + * 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.jpa.storage.AbstractJobStorageIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +public class JobStorageIT 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/ProcessDefinitionStorageIT.java new file mode 100644 index 0000000000..b0369d8369 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessDefinitionStorageIT.java @@ -0,0 +1,31 @@ +/* + * 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.jpa.storage.AbstractProcessDefinitionStorageIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +class ProcessDefinitionStorageIT 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/ProcessInstanceStorageIT.java new file mode 100644 index 0000000000..9f40d50928 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/ProcessInstanceStorageIT.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.storage; + +import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +public class ProcessInstanceStorageIT 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/UserTaskInstanceStorageIT.java new file mode 100644 index 0000000000..4a6b9921e5 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/java/org/kie/kogito/index/jdbc/storage/UserTaskInstanceStorageIT.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.storage; + +import org.kie.kogito.index.jpa.storage.AbstractUserTaskInstanceStorageIT; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +public class UserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { +} diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/resources/application.properties b/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties similarity index 84% rename from data-index/data-index-storage/data-index-storage-oracle/src/test/resources/application.properties rename to data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties index 6dbb374445..5cf2dfb3a2 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/resources/application.properties +++ b/data-index/data-index-storage/data-index-storage-jpa/src/test/resources/application.properties @@ -18,12 +18,10 @@ # # Kogito -kogito.apps.persistence.type=oracle +kogito.apps.persistence.type=jdbc # Data source -quarkus.datasource.db-kind=oracle -quarkus.datasource.username=kogito -quarkus.datasource.password=kogito -quarkus.datasource.jdbc.url=jdbc:oracle://localhost:1521/kogito +quarkus.datasource.db-kind=h2 +quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test;NON_KEYWORDS=VALUE,KEY # Hibernate quarkus.hibernate-orm.database.generation=create quarkus.hibernate-orm.database.generation.halt-on-error=true diff --git a/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessDefinitionEntityMapper.java b/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessDefinitionEntityMapper.java index 6dfc5573db..ea91176fbd 100644 --- a/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessDefinitionEntityMapper.java +++ b/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessDefinitionEntityMapper.java @@ -40,7 +40,7 @@ public ProcessDefinitionEntity mapToEntity(String key, ProcessDefinition pd) { } ProcessDefinitionEntity entity = new ProcessDefinitionEntity(); - entity.setKey(pd.getKey()); + entity.setKey(key); entity.setId(pd.getId()); entity.setVersion(pd.getVersion()); entity.setName(pd.getName()); diff --git a/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/query/ProcessDefinitionQueryIT.java b/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/query/ProcessDefinitionQueryIT.java index b2d18d3928..1f126d801d 100644 --- a/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/query/ProcessDefinitionQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/query/ProcessDefinitionQueryIT.java @@ -20,8 +20,10 @@ import org.junit.jupiter.api.BeforeEach; import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; import org.kie.kogito.index.mongodb.model.ProcessDefinitionEntity; import org.kie.kogito.index.mongodb.model.ProcessDefinitionEntityMapper; +import org.kie.kogito.index.storage.ModelProcessDefinitionStorage; import org.kie.kogito.index.test.query.AbstractProcessDefinitionQueryIT; import org.kie.kogito.persistence.api.Storage; import org.kie.kogito.persistence.mongodb.client.MongoClientManager; @@ -42,16 +44,16 @@ class ProcessDefinitionQueryIT extends AbstractProcessDefinitionQueryIT { @Inject MongoClientManager mongoClientManager; - Storage storage; + Storage storage; @BeforeEach void setUp() { - this.storage = new MongoStorage<>(mongoClientManager.getCollection(PROCESS_DEFINITIONS_STORAGE, ProcessDefinitionEntity.class), - ProcessDefinition.class.getName(), new ProcessDefinitionEntityMapper()); + this.storage = new ModelProcessDefinitionStorage(new MongoStorage<>(mongoClientManager.getCollection(PROCESS_DEFINITIONS_STORAGE, ProcessDefinitionEntity.class), + ProcessDefinition.class.getName(), new ProcessDefinitionEntityMapper())); } @Override - public Storage getStorage() { + public Storage getStorage() { return storage; } } diff --git a/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/storage/ProcessDefinitionStorageIT.java b/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/storage/ProcessDefinitionStorageIT.java index ec88ef525f..4aec97a2c5 100644 --- a/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/storage/ProcessDefinitionStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/storage/ProcessDefinitionStorageIT.java @@ -25,8 +25,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; import org.kie.kogito.index.mongodb.model.ProcessDefinitionEntity; import org.kie.kogito.index.mongodb.model.ProcessDefinitionEntityMapper; +import org.kie.kogito.index.storage.ModelProcessDefinitionStorage; import org.kie.kogito.index.test.TestUtils; import org.kie.kogito.persistence.api.Storage; import org.kie.kogito.persistence.mongodb.client.MongoClientManager; @@ -42,17 +44,17 @@ @QuarkusTest @QuarkusTestResource(MongoDBQuarkusTestResource.class) -class ProcessDefinitionStorageIT extends StorageTestBase { +class ProcessDefinitionStorageIT extends StorageTestBase { @Inject MongoClientManager mongoClientManager; - Storage storage; + Storage storage; @BeforeEach void setUp() { - this.storage = new MongoStorage<>(mongoClientManager.getCollection(PROCESS_DEFINITIONS_STORAGE, ProcessDefinitionEntity.class), - ProcessDefinition.class.getName(), new ProcessDefinitionEntityMapper()); + this.storage = new ModelProcessDefinitionStorage(new MongoStorage<>(mongoClientManager.getCollection(PROCESS_DEFINITIONS_STORAGE, ProcessDefinitionEntity.class), + ProcessDefinition.class.getName(), new ProcessDefinitionEntityMapper())); } @AfterEach @@ -66,6 +68,6 @@ void testCache() { String version = "1.0"; ProcessDefinition pdv1 = TestUtils.createProcessDefinition(processId, version, Set.of("admin", "kogito")); ProcessDefinition pdv2 = TestUtils.createProcessDefinition(processId, version, Set.of("kogito")); - testStorage(storage, pdv1.getKey(), pdv1, pdv2); + testStorage(storage, new ProcessDefinitionKey(processId, version), pdv1, pdv2); } } diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/OracleStorageServiceProducer.java b/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/OracleStorageServiceProducer.java deleted file mode 100644 index f14dde82e9..0000000000 --- a/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/OracleStorageServiceProducer.java +++ /dev/null @@ -1,49 +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. - */ -package org.kie.kogito.index.oracle; - -import org.kie.kogito.index.jpa.storage.JPAStorageService; -import org.kie.kogito.index.jpa.storage.JobEntityStorage; -import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage; -import org.kie.kogito.index.jpa.storage.ProcessInstanceEntityStorage; -import org.kie.kogito.index.jpa.storage.UserTaskInstanceEntityStorage; -import org.kie.kogito.persistence.api.StorageService; - -import io.quarkus.arc.properties.IfBuildProperty; - -import jakarta.annotation.Priority; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.inject.Alternative; -import jakarta.enterprise.inject.Produces; - -import static org.kie.kogito.persistence.api.factory.Constants.PERSISTENCE_TYPE_PROPERTY; - -public class OracleStorageServiceProducer { - @Produces - @Alternative - @Priority(1) - @ApplicationScoped - @IfBuildProperty(name = PERSISTENCE_TYPE_PROPERTY, stringValue = "oracle") - StorageService PostgreSqlStorageService(final ProcessDefinitionEntityStorage definitionStorage, - final ProcessInstanceEntityStorage processStorage, - final JobEntityStorage jobStorage, - final UserTaskInstanceEntityStorage taskStorage) { - return new JPAStorageService(definitionStorage, processStorage, jobStorage, taskStorage); - } -} diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/META-INF/beans.xml b/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/META-INF/beans.xml deleted file mode 100644 index a0eb9fbf8c..0000000000 --- a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/META-INF/beans.xml +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/schema/DDLSchemaExporter.java b/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/schema/DDLSchemaExporter.java deleted file mode 100644 index 6e2c2dfde5..0000000000 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/schema/DDLSchemaExporter.java +++ /dev/null @@ -1,81 +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. - */ -package org.kie.kogito.index.oracle.schema; - -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; - -import org.hibernate.boot.Metadata; -import org.hibernate.boot.MetadataSources; -import org.hibernate.boot.registry.StandardServiceRegistry; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.Environment; -import org.hibernate.tool.hbm2ddl.SchemaExport; -import org.hibernate.tool.schema.TargetType; -import org.kie.kogito.index.jpa.model.AttachmentEntity; -import org.kie.kogito.index.jpa.model.CommentEntity; -import org.kie.kogito.index.jpa.model.JobEntity; -import org.kie.kogito.index.jpa.model.MilestoneEntity; -import org.kie.kogito.index.jpa.model.NodeEntity; -import org.kie.kogito.index.jpa.model.NodeInstanceEntity; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntity; -import org.kie.kogito.index.jpa.model.ProcessInstanceEntity; -import org.kie.kogito.index.jpa.model.ProcessInstanceErrorEntity; -import org.kie.kogito.index.jpa.model.UserTaskInstanceEntity; -import org.kie.kogito.testcontainers.KogitoOracleSqlContainer; - -public class DDLSchemaExporter { - - public static void main(String[] args) { - try (KogitoOracleSqlContainer oracleSql = new KogitoOracleSqlContainer()) { - oracleSql.start(); - Map settings = new HashMap<>(); - settings.put(Environment.URL, oracleSql.getJdbcUrl()); - settings.put(Environment.USER, oracleSql.getUsername()); - settings.put(Environment.PASS, oracleSql.getPassword()); - settings.put(Environment.PHYSICAL_NAMING_STRATEGY, "org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy"); - - StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(settings).build(); - - MetadataSources metadataSources = new MetadataSources(serviceRegistry); - metadataSources.addAnnotatedClass(NodeEntity.class); - metadataSources.addAnnotatedClass(ProcessDefinitionEntity.class); - metadataSources.addAnnotatedClass(JobEntity.class); - metadataSources.addAnnotatedClass(MilestoneEntity.class); - metadataSources.addAnnotatedClass(NodeInstanceEntity.class); - metadataSources.addAnnotatedClass(ProcessInstanceEntity.class); - metadataSources.addAnnotatedClass(ProcessInstanceErrorEntity.class); - metadataSources.addAnnotatedClass(AttachmentEntity.class); - metadataSources.addAnnotatedClass(CommentEntity.class); - metadataSources.addAnnotatedClass(UserTaskInstanceEntity.class); - Metadata metadata = metadataSources.buildMetadata(); - - SchemaExport schemaExport = new SchemaExport(); - schemaExport.setDelimiter(";"); - schemaExport.setFormat(true); - schemaExport.setOverrideOutputFileContent(); - schemaExport.setOutputFile("src/main/resources/data_index_create.sql"); - schemaExport.createOnly(EnumSet.of(TargetType.SCRIPT), metadata); - schemaExport.getExceptions().forEach(System.err::println); - } catch (Exception ex) { - ex.printStackTrace(); - } - } -} diff --git a/data-index/data-index-storage/data-index-storage-postgresql/pom.xml b/data-index/data-index-storage/data-index-storage-postgresql/pom.xml index 6b75513be0..2f552ad5fb 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/pom.xml +++ b/data-index/data-index-storage/data-index-storage-postgresql/pom.xml @@ -39,7 +39,7 @@ org.kie.kogito - data-index-storage-jpa + data-index-storage-jpa-common org.kie.kogito @@ -51,6 +51,13 @@ test-jar test + + org.kie.kogito + data-index-storage-jpa-common + test-jar + test + ${project.version} + io.quarkus quarkus-junit5-mockito diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/PostgreSqlStorageServiceProducer.java b/data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/PostgreSqlStorageServiceProducer.java deleted file mode 100644 index 4e495f1071..0000000000 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/PostgreSqlStorageServiceProducer.java +++ /dev/null @@ -1,50 +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. - */ -package org.kie.kogito.index.postgresql; - -import org.kie.kogito.index.jpa.storage.JPAStorageService; -import org.kie.kogito.index.jpa.storage.JobEntityStorage; -import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage; -import org.kie.kogito.index.jpa.storage.ProcessInstanceEntityStorage; -import org.kie.kogito.index.jpa.storage.UserTaskInstanceEntityStorage; -import org.kie.kogito.persistence.api.StorageService; - -import io.quarkus.arc.properties.IfBuildProperty; - -import jakarta.annotation.Priority; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.inject.Alternative; -import jakarta.enterprise.inject.Produces; - -import static org.kie.kogito.persistence.api.factory.Constants.PERSISTENCE_TYPE_PROPERTY; -import static org.kie.kogito.persistence.postgresql.Constants.POSTGRESQL_STORAGE; - -public class PostgreSqlStorageServiceProducer { - @Produces - @Alternative - @Priority(1) - @ApplicationScoped - @IfBuildProperty(name = PERSISTENCE_TYPE_PROPERTY, stringValue = POSTGRESQL_STORAGE) - StorageService PostgreSqlStorageService(final ProcessDefinitionEntityStorage definitionStorage, - final ProcessInstanceEntityStorage processStorage, - final JobEntityStorage jobStorage, - final UserTaskInstanceEntityStorage taskStorage) { - return new JPAStorageService(definitionStorage, processStorage, jobStorage, taskStorage); - } -} diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/db/migration/V1.45.0.3__add_fk_index.sql b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/db/migration/V1.45.0.3__add_fk_index.sql new file mode 100644 index 0000000000..72e909ac55 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/db/migration/V1.45.0.3__add_fk_index.sql @@ -0,0 +1,17 @@ +create index if not exists idx_attachments_tid on attachments(task_id); +create index if not exists idx_comments_tid on comments(task_id); +create index if not exists idx_definitions_addons_pid_pv on definitions_addons(process_id, process_version); +create index if not exists idx_definitions_annotations_pid_pv on definitions_annotations(process_id, process_version); +create index if not exists idx_definitions_metadata_pid_pv on definitions_metadata(process_id, process_version); +create index if not exists idx_definitions_nodes_pid_pv on definitions_nodes(process_id, process_version); +create index if not exists idx_definitions_nodes_metadata_pid_pv on definitions_nodes_metadata(process_id, process_version); +create index if not exists idx_definitions_roles_pid_pv on definitions_roles(process_id, process_version); +create index if not exists idx_milestones_piid on milestones(process_instance_id); +create index if not exists idx_nodes_piid on nodes(process_instance_id); +create index if not exists idx_processes_addons_pid on processes_addons(process_id); +create index if not exists idx_processes_roles_pid on processes_roles(process_id); +create index if not exists idx_tasks_admin_groups_tid on tasks_admin_groups(task_id); +create index if not exists idx_tasks_admin_users_tid on tasks_admin_users(task_id); +create index if not exists idx_tasks_excluded_users_tid on tasks_excluded_users(task_id); +create index if not exists idx_tasks_potential_groups_tid on tasks_potential_groups(task_id); +create index if not exists idx_tasks_potential_users_tid on tasks_potential_users(task_id); diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/JobEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/JobEntityMapperIT.java index 8b18c82c38..42a74c5b9b 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/JobEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/JobEntityMapperIT.java @@ -18,89 +18,10 @@ */ package org.kie.kogito.index.postgresql.mapper; -import java.time.ZonedDateTime; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.JobEntityMapper; -import org.kie.kogito.index.jpa.model.JobEntity; -import org.kie.kogito.index.model.Job; +import org.kie.kogito.index.jpa.mapper.AbstractJobEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - -import static org.assertj.core.api.Assertions.assertThat; - @QuarkusTest -class JobEntityMapperIT { - - @Inject - JobEntityMapper mapper; - - Job job = new Job(); - - JobEntity jobEntity = new JobEntity(); - - @BeforeEach - void setup() { - String testId = "testId"; - ZonedDateTime time = ZonedDateTime.now(); - String status = "ACTIVE"; - String processId = "testProcessId"; - String processInstanceId = "testProcessInstanceId"; - String rootProcessId = "testRootProcessId"; - String rootProcessInstanceId = "testRootProcessInstanceId"; - Integer priority = 79; - String callbackEndpoint = "testCallbackEndpoint"; - Long repeatInterval = 70L; - Integer repeatLimit = 89; - String scheduledId = "testScheduleId"; - Integer retries = 25; - Integer executionCounter = 17; - - job.setId(testId); - job.setStatus(status); - job.setLastUpdate(time); - job.setProcessId(processId); - job.setProcessInstanceId(processInstanceId); - job.setRootProcessId(rootProcessId); - job.setRootProcessInstanceId(rootProcessInstanceId); - job.setExpirationTime(time); - job.setPriority(priority); - job.setCallbackEndpoint(callbackEndpoint); - job.setRepeatInterval(repeatInterval); - job.setRepeatLimit(repeatLimit); - job.setScheduledId(scheduledId); - job.setRetries(retries); - job.setExecutionCounter(executionCounter); - - jobEntity.setId(testId); - jobEntity.setStatus(status); - jobEntity.setLastUpdate(time); - jobEntity.setProcessId(processId); - jobEntity.setProcessInstanceId(processInstanceId); - jobEntity.setRootProcessId(rootProcessId); - jobEntity.setRootProcessInstanceId(rootProcessInstanceId); - jobEntity.setExpirationTime(time); - jobEntity.setPriority(priority); - jobEntity.setCallbackEndpoint(callbackEndpoint); - jobEntity.setRepeatInterval(repeatInterval); - jobEntity.setRepeatLimit(repeatLimit); - jobEntity.setScheduledId(scheduledId); - jobEntity.setRetries(retries); - jobEntity.setExecutionCounter(executionCounter); - } - - @Test - void testMapToEntity() { - JobEntity result = mapper.mapToEntity(job); - assertThat(result).isEqualToIgnoringGivenFields(jobEntity, "$$_hibernate_tracker"); - } - - @Test - void testMapToModel() { - Job result = mapper.mapToModel(jobEntity); - assertThat(result).isEqualToComparingFieldByField(job); - } +class JobEntityMapperIT extends AbstractJobEntityMapperIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessDefinitionEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessDefinitionEntityMapperIT.java index 35634f9713..eb7cef3d14 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessDefinitionEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessDefinitionEntityMapperIT.java @@ -18,88 +18,10 @@ */ package org.kie.kogito.index.postgresql.mapper; -import java.util.Set; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.ProcessDefinitionEntityMapper; -import org.kie.kogito.index.jpa.model.NodeEntity; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntity; -import org.kie.kogito.index.model.Node; -import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.jpa.mapper.AbstractProcessDefinitionEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; -import static org.assertj.core.api.Assertions.assertThat; - @QuarkusTest -class ProcessDefinitionEntityMapperIT { - - ProcessDefinition pd = new ProcessDefinition(); - ProcessDefinitionEntity entity = new ProcessDefinitionEntity(); - - @Inject - ProcessDefinitionEntityMapper mapper; - - @BeforeEach - void setup() { - String version = "1.0"; - String processId = "testProcessId"; - Set roles = singleton("testRoles"); - String type = "testType"; - Set addons = singleton("testAddons"); - - String nodeId = "testNodeId"; - String nodeName = "testNodeName"; - String nodeUniqueId = "testNodeUniqueId"; - String nodeMetadataUniqueId = "testMetadataUniqueId"; - String nodeType = "testNodeType"; - - Node node = new Node(); - node.setId(nodeId); - node.setName(nodeName); - node.setType(nodeType); - node.setUniqueId(nodeUniqueId); - node.setMetadata(singletonMap("UniqueId", nodeMetadataUniqueId)); - - pd.setId(processId); - pd.setVersion(version); - pd.setRoles(roles); - pd.setAddons(addons); - pd.setType(type); - pd.setNodes(singletonList(node)); - - NodeEntity nodeEntity = new NodeEntity(); - nodeEntity.setId(nodeId); - nodeEntity.setName(nodeName); - nodeEntity.setType(nodeType); - nodeEntity.setUniqueId(nodeUniqueId); - nodeEntity.setMetadata(singletonMap("UniqueId", nodeMetadataUniqueId)); - nodeEntity.setProcessDefinition(entity); - - entity.setId(processId); - entity.setVersion(version); - entity.setRoles(roles); - entity.setAddons(addons); - entity.setType(type); - entity.setNodes(singletonList(nodeEntity)); - } - - @Test - void testMapToEntity() { - ProcessDefinitionEntity result = mapper.mapToEntity(pd); - assertThat(result).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*\\$\\$_hibernate_tracker").isEqualTo(entity); - } - - @Test - void testMapToModel() { - ProcessDefinition result = mapper.mapToModel(entity); - assertThat(result).usingRecursiveComparison().isEqualTo(pd); - } - +class ProcessDefinitionEntityMapperIT extends AbstractProcessDefinitionEntityMapperIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java index ea0b9fdba8..949bd0c010 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java @@ -18,169 +18,10 @@ */ package org.kie.kogito.index.postgresql.mapper; -import java.time.ZonedDateTime; -import java.util.Set; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.ProcessInstanceEntityMapper; -import org.kie.kogito.index.jpa.model.MilestoneEntity; -import org.kie.kogito.index.jpa.model.MilestoneEntityId; -import org.kie.kogito.index.jpa.model.NodeInstanceEntity; -import org.kie.kogito.index.jpa.model.ProcessInstanceEntity; -import org.kie.kogito.index.jpa.model.ProcessInstanceErrorEntity; -import org.kie.kogito.index.model.Milestone; -import org.kie.kogito.index.model.NodeInstance; -import org.kie.kogito.index.model.ProcessInstance; -import org.kie.kogito.index.model.ProcessInstanceError; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; +import org.kie.kogito.index.jpa.mapper.AbstractProcessInstanceEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; - @QuarkusTest -class ProcessInstanceEntityMapperIT { - - ObjectMapper jsonMapper = new ObjectMapper(); - ProcessInstance processInstance = new ProcessInstance(); - ProcessInstanceEntity processInstanceEntity = new ProcessInstanceEntity(); - - @Inject - ProcessInstanceEntityMapper mapper; - - @BeforeEach - void setup() { - String nodeInstanceId = "testNodeInstanceId"; - String nodeInstanceName = "testNodeInstanceName"; - String nodeInstanceNodeId = "testNodeInstanceNodeId"; - String nodeInstanceType = "testNodeInstanceType"; - String nodeInstanceDefinitionId = "testNodeInstanceDefinitionId"; - - String processInstanceErrorMessage = "testProcessInstanceErrorMessage"; - String processInstanceErrorNodeDefinitionId = "testProcessInstanceErrorNodeDefinitionId"; - - String milestoneId = "testMilestone"; - String milestoneName = "testMilestoneName"; - String milestoneStatus = "testMilestoneStatus"; - - String testId = "testId"; - String processId = "testProcessId"; - Set roles = singleton("testRoles"); - ObjectNode variables = jsonMapper.createObjectNode(); - variables.put("test", "testValue"); - String endpoint = "testEndpoint"; - Integer state = 2; - ZonedDateTime time = ZonedDateTime.now(); - String rootProcessId = "testRootProcessId"; - String rootProcessInstanceId = "testRootProcessInstanceId"; - String parentProcessInstanceId = "testParentProcessInstanceId"; - String processName = "testProcessName"; - Set addons = singleton("testAddons"); - String businessKey = "testBusinessKey"; - String createdBy = "initiatorUser"; - String updatedBy = "currentUser"; - - NodeInstance nodeInstance = new NodeInstance(); - nodeInstance.setId(nodeInstanceId); - nodeInstance.setDefinitionId(nodeInstanceDefinitionId); - nodeInstance.setExit(time); - nodeInstance.setEnter(time); - nodeInstance.setType(nodeInstanceType); - nodeInstance.setNodeId(nodeInstanceNodeId); - nodeInstance.setName(nodeInstanceName); - - ProcessInstanceError processInstanceError = new ProcessInstanceError(); - processInstanceError.setMessage(processInstanceErrorMessage); - processInstanceError.setNodeDefinitionId(processInstanceErrorNodeDefinitionId); - - Milestone milestone = new Milestone(); - milestone.setId(milestoneId); - milestone.setName(milestoneName); - milestone.setStatus(milestoneStatus); - - processInstance.setId(testId); - processInstance.setProcessId(processId); - processInstance.setRoles(roles); - processInstance.setVariables(variables); - processInstance.setEndpoint(endpoint); - processInstance.setNodes(singletonList(nodeInstance)); - processInstance.setState(state); - processInstance.setStart(time); - processInstance.setEnd(time); - processInstance.setRootProcessId(rootProcessId); - processInstance.setRootProcessInstanceId(rootProcessInstanceId); - processInstance.setParentProcessInstanceId(parentProcessInstanceId); - processInstance.setProcessName(processName); - processInstance.setError(processInstanceError); - processInstance.setAddons(addons); - processInstance.setLastUpdate(time); - processInstance.setBusinessKey(businessKey); - processInstance.setMilestones(singletonList(milestone)); - processInstance.setCreatedBy(createdBy); - processInstance.setUpdatedBy(updatedBy); - - NodeInstanceEntity nodeInstanceEntity = new NodeInstanceEntity(); - nodeInstanceEntity.setId(nodeInstanceId); - nodeInstanceEntity.setDefinitionId(nodeInstanceDefinitionId); - nodeInstanceEntity.setEnter(time); - nodeInstanceEntity.setExit(time); - nodeInstanceEntity.setName(nodeInstanceName); - nodeInstanceEntity.setNodeId(nodeInstanceNodeId); - nodeInstanceEntity.setType(nodeInstanceType); - nodeInstanceEntity.setProcessInstance(processInstanceEntity); - - ProcessInstanceErrorEntity processInstanceErrorEntity = new ProcessInstanceErrorEntity(); - processInstanceErrorEntity.setMessage(processInstanceErrorMessage); - processInstanceErrorEntity.setNodeDefinitionId(processInstanceErrorNodeDefinitionId); - - MilestoneEntity milestoneEntity = new MilestoneEntity(); - MilestoneEntityId milestoneEntityId = new MilestoneEntityId(); - milestoneEntityId.setId(milestoneId); - milestoneEntityId.setProcessInstance(testId); - milestoneEntity.setId(milestoneId); - milestoneEntity.setName(milestoneName); - milestoneEntity.setStatus(milestoneStatus); - milestoneEntity.setProcessInstance(processInstanceEntity); - - processInstanceEntity.setId(testId); - processInstanceEntity.setProcessId(processId); - processInstanceEntity.setRoles(roles); - processInstanceEntity.setVariables(variables); - processInstanceEntity.setEndpoint(endpoint); - processInstanceEntity.setNodes(singletonList(nodeInstanceEntity)); - processInstanceEntity.setState(state); - processInstanceEntity.setStart(time); - processInstanceEntity.setEnd(time); - processInstanceEntity.setRootProcessId(rootProcessId); - processInstanceEntity.setRootProcessInstanceId(rootProcessInstanceId); - processInstanceEntity.setParentProcessInstanceId(parentProcessInstanceId); - processInstanceEntity.setProcessName(processName); - processInstanceEntity.setError(processInstanceErrorEntity); - processInstanceEntity.setAddons(addons); - processInstanceEntity.setLastUpdate(time); - processInstanceEntity.setBusinessKey(businessKey); - processInstanceEntity.setMilestones(singletonList(milestoneEntity)); - processInstanceEntity.setCreatedBy(createdBy); - processInstanceEntity.setUpdatedBy(updatedBy); - } - - @Test - void testMapToEntity() { - ProcessInstanceEntity result = mapper.mapToEntity(processInstance); - assertThat(result).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*\\$\\$_hibernate_tracker").isEqualTo(processInstanceEntity); - } - - @Test - void testMapToModel() { - ProcessInstance result = mapper.mapToModel(processInstanceEntity); - assertThat(result).usingRecursiveComparison().isEqualTo(processInstance); - } - +class ProcessInstanceEntityMapperIT extends AbstractProcessInstanceEntityMapperIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/UserTaskInstanceEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/UserTaskInstanceEntityMapperIT.java index 39574a8020..65a1ef1a6c 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/UserTaskInstanceEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/UserTaskInstanceEntityMapperIT.java @@ -18,151 +18,10 @@ */ package org.kie.kogito.index.postgresql.mapper; -import java.time.ZonedDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.mapper.UserTaskInstanceEntityMapper; -import org.kie.kogito.index.jpa.model.AttachmentEntity; -import org.kie.kogito.index.jpa.model.CommentEntity; -import org.kie.kogito.index.jpa.model.UserTaskInstanceEntity; -import org.kie.kogito.index.model.Attachment; -import org.kie.kogito.index.model.Comment; -import org.kie.kogito.index.model.UserTaskInstance; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; +import org.kie.kogito.index.jpa.mapper.AbstractUserTaskInstanceEntityMapperIT; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - -import static java.util.Collections.singleton; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; - @QuarkusTest -class UserTaskInstanceEntityMapperIT { - - UserTaskInstance userTaskInstance = new UserTaskInstance(); - UserTaskInstanceEntity userTaskInstanceEntity = new UserTaskInstanceEntity(); - - @Inject - ObjectMapper jsonMapper; - - @Inject - UserTaskInstanceEntityMapper mapper; - - @BeforeEach - void setup() { - String testId = "testId"; - String description = "testDescription"; - String name = "testName"; - String priority = "10"; - String processInstanceId = "testProcessInstanceId"; - String state = "testState"; - String actualOwner = "testActualOwner"; - Set adminGroups = singleton("testAdminGroups"); - Set adminUsers = singleton("testAdminUsers"); - ZonedDateTime time = ZonedDateTime.now(); - Set excludedUsers = singleton("testExcludedUsers"); - Set potentialGroups = singleton("testPotentialGroups"); - Set potentialUsers = singleton("testPotentialUsers"); - String referenceName = "testReferenceName"; - String processId = "testProcessId"; - String rootProcessId = "testRootProcessId"; - String rootProcessInstanceId = "testRootProcessInstanceId"; - Map object = new HashMap<>(); - object.put("test", "testValue"); - ObjectNode inputs = jsonMapper.createObjectNode().put("testInput", "testValue"); - ObjectNode outputs = jsonMapper.createObjectNode().put("testOutput", "testValue"); - - String commentId = "testCommentId"; - String comment_content = "testCommentContent"; - String comment_updatedBy = "testCommentUpdatedBy"; - Comment comment = Comment.builder().id(commentId).updatedAt(time).updatedBy(comment_updatedBy).content(comment_content).build(); - CommentEntity commentEntity = new CommentEntity(); - commentEntity.setId(commentId); - commentEntity.setContent(comment_content); - commentEntity.setUpdatedAt(time); - commentEntity.setUpdatedBy(comment_updatedBy); - commentEntity.setUserTask(userTaskInstanceEntity); - - String attachmentId = "testAttachmentId"; - String attachment_name = "testAttachmentName"; - String attachment_content = "testAttachmentContent"; - String attachment_updatedBy = "testAttachmentUpdatedBy"; - Attachment attachment = Attachment.builder().id(attachmentId).updatedAt(time).updatedBy(attachment_updatedBy) - .content(attachment_content).name(attachment_name).build(); - AttachmentEntity attachmentEntity = new AttachmentEntity(); - attachmentEntity.setId(attachmentId); - attachmentEntity.setContent(attachment_content); - attachmentEntity.setName(attachment_name); - attachmentEntity.setUpdatedAt(time); - attachmentEntity.setUpdatedBy(attachment_updatedBy); - attachmentEntity.setUserTask(userTaskInstanceEntity); - - userTaskInstance.setId(testId); - userTaskInstance.setDescription(description); - userTaskInstance.setName(name); - userTaskInstance.setPriority(priority); - userTaskInstance.setProcessInstanceId(processInstanceId); - userTaskInstance.setState(state); - userTaskInstance.setActualOwner(actualOwner); - userTaskInstance.setAdminGroups(adminGroups); - userTaskInstance.setAdminUsers(adminUsers); - userTaskInstance.setCompleted(time); - userTaskInstance.setStarted(time); - userTaskInstance.setExcludedUsers(excludedUsers); - userTaskInstance.setPotentialGroups(potentialGroups); - userTaskInstance.setPotentialUsers(potentialUsers); - userTaskInstance.setReferenceName(referenceName); - userTaskInstance.setLastUpdate(time); - userTaskInstance.setProcessId(processId); - userTaskInstance.setRootProcessId(rootProcessId); - userTaskInstance.setRootProcessInstanceId(rootProcessInstanceId); - userTaskInstance.setInputs(inputs); - userTaskInstance.setOutputs(outputs); - userTaskInstance.setComments(singletonList(comment)); - userTaskInstance.setAttachments(singletonList(attachment)); - - userTaskInstanceEntity.setId(testId); - userTaskInstanceEntity.setDescription(description); - userTaskInstanceEntity.setName(name); - userTaskInstanceEntity.setPriority(priority); - userTaskInstanceEntity.setProcessInstanceId(processInstanceId); - userTaskInstanceEntity.setState(state); - userTaskInstanceEntity.setActualOwner(actualOwner); - userTaskInstanceEntity.setAdminGroups(adminGroups); - userTaskInstanceEntity.setAdminUsers(adminUsers); - userTaskInstanceEntity.setCompleted(time); - userTaskInstanceEntity.setStarted(time); - userTaskInstanceEntity.setExcludedUsers(excludedUsers); - userTaskInstanceEntity.setPotentialGroups(potentialGroups); - userTaskInstanceEntity.setPotentialUsers(potentialUsers); - userTaskInstanceEntity.setReferenceName(referenceName); - userTaskInstanceEntity.setLastUpdate(time); - userTaskInstanceEntity.setProcessId(processId); - userTaskInstanceEntity.setRootProcessId(rootProcessId); - userTaskInstanceEntity.setRootProcessInstanceId(rootProcessInstanceId); - userTaskInstanceEntity.setInputs(inputs); - userTaskInstanceEntity.setOutputs(outputs); - userTaskInstanceEntity.setComments(singletonList(commentEntity)); - userTaskInstanceEntity.setAttachments(singletonList(attachmentEntity)); - } - - @Test - void testMapToEntity() { - UserTaskInstanceEntity result = mapper.mapToEntity(userTaskInstance); - assertThat(result).isEqualToIgnoringGivenFields(userTaskInstanceEntity, "$$_hibernate_tracker"); - } - - @Test - void testMapToModel() { - UserTaskInstance result = mapper.mapToModel(userTaskInstanceEntity); - assertThat(result).isEqualToComparingFieldByField(userTaskInstance); - } +class UserTaskInstanceEntityMapperIT extends AbstractUserTaskInstanceEntityMapperIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/JobEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/JobEntityQueryIT.java index b97a783fbf..90502e9075 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/JobEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/JobEntityQueryIT.java @@ -18,27 +18,13 @@ */ package org.kie.kogito.index.postgresql.query; -import org.kie.kogito.index.jpa.storage.JobEntityStorage; -import org.kie.kogito.index.model.Job; -import org.kie.kogito.index.test.query.AbstractJobQueryIT; -import org.kie.kogito.persistence.api.Storage; +import org.kie.kogito.index.jpa.query.AbstractJobEntityQueryIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -class JobEntityQueryIT extends AbstractJobQueryIT { - - @Inject - JobEntityStorage storage; - - @Override - public Storage getStorage() { - return storage; - } - +class JobEntityQueryIT extends AbstractJobEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessDefinitionEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessDefinitionEntityQueryIT.java index 28384df31a..0f304623be 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessDefinitionEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessDefinitionEntityQueryIT.java @@ -18,31 +18,13 @@ */ package org.kie.kogito.index.postgresql.query; -import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage; -import org.kie.kogito.index.model.ProcessDefinition; -import org.kie.kogito.index.test.query.AbstractProcessDefinitionQueryIT; -import org.kie.kogito.persistence.api.Storage; +import org.kie.kogito.index.jpa.query.AbstractProcessDefinitionEntityQueryIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -class ProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionQueryIT { - - @Inject - ProcessDefinitionEntityStorage storage; - - @Override - public Storage getStorage() { - return storage; - } - - @Override - protected Boolean isDateTimeAsLong() { - return false; - } +class ProcessDefinitionEntityQueryIT extends AbstractProcessDefinitionEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessInstanceEntityQueryIT.java index 5e963cee98..254bca48f2 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/ProcessInstanceEntityQueryIT.java @@ -18,30 +18,13 @@ */ package org.kie.kogito.index.postgresql.query; -import org.kie.kogito.index.jpa.storage.ProcessInstanceEntityStorage; -import org.kie.kogito.index.storage.ProcessInstanceStorage; -import org.kie.kogito.index.test.query.AbstractProcessInstanceQueryIT; +import org.kie.kogito.index.jpa.query.AbstractProcessInstanceEntityQueryIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -class ProcessInstanceEntityQueryIT extends AbstractProcessInstanceQueryIT { - - @Inject - ProcessInstanceEntityStorage storage; - - @Override - public ProcessInstanceStorage getStorage() { - return storage; - } - - @Override - protected Boolean isDateTimeAsLong() { - return false; - } +class ProcessInstanceEntityQueryIT extends AbstractProcessInstanceEntityQueryIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/UserTaskInstanceEntityQueryIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/UserTaskInstanceEntityQueryIT.java index f0e2a6fc9b..399e5ecf2d 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/UserTaskInstanceEntityQueryIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/query/UserTaskInstanceEntityQueryIT.java @@ -18,30 +18,14 @@ */ package org.kie.kogito.index.postgresql.query; -import org.kie.kogito.index.jpa.storage.UserTaskInstanceEntityStorage; -import org.kie.kogito.index.storage.UserTaskInstanceStorage; -import org.kie.kogito.index.test.query.AbstractUserTaskInstanceQueryIT; +import org.kie.kogito.index.jpa.query.AbstractUserTaskInstanceEntityQueryIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -class UserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceQueryIT { - - @Inject - UserTaskInstanceEntityStorage storage; - - @Override - public UserTaskInstanceStorage getStorage() { - return storage; - } +class UserTaskInstanceEntityQueryIT extends AbstractUserTaskInstanceEntityQueryIT { - @Override - protected Boolean isDateTimeAsLong() { - return false; - } } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/AbstractStorageIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/AbstractStorageIT.java deleted file mode 100644 index 427e8d3d2a..0000000000 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/AbstractStorageIT.java +++ /dev/null @@ -1,59 +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. - */ -package org.kie.kogito.index.postgresql.storage; - -import org.kie.kogito.index.jpa.model.AbstractEntity; -import org.kie.kogito.persistence.api.Storage; -import org.kie.kogito.persistence.api.StorageService; - -import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; - -import static org.assertj.core.api.Assertions.assertThat; - -public abstract class AbstractStorageIT { - - Class type; - - public AbstractStorageIT(Class type) { - this.type = type; - } - - abstract StorageService getStorage(); - - abstract PanacheRepositoryBase getRepository(); - - void testStorage(String key, T value1, T value2) { - Storage cache = getStorage().getCache("cache", type); - assertThat(cache.get(key)).isNull(); - assertThat(cache.containsKey(key)).isFalse(); - - cache.put(key, value1); - assertThat(cache.get(key)).isEqualTo(value1); - assertThat(cache.containsKey(key)).isTrue(); - - cache.put(key, value2); - assertThat(cache.get(key)).isEqualTo(value2); - assertThat(cache.containsKey(key)).isTrue(); - - cache.remove(key); - assertThat(cache.get(key)).isNull(); - assertThat(cache.containsKey(key)).isFalse(); - } - -} diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/DomainQueryTest.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/DomainQueryTest.java deleted file mode 100644 index 20d85db1b1..0000000000 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/DomainQueryTest.java +++ /dev/null @@ -1,170 +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. - */ -package org.kie.kogito.index.postgresql.storage; - -import java.util.List; -import java.util.function.Function; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.kie.kogito.index.jpa.model.ProcessInstanceEntity; -import org.kie.kogito.index.jpa.storage.JPAQuery; -import org.kie.kogito.index.model.ProcessInstance; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; - -import jakarta.persistence.EntityManager; -import jakarta.persistence.TypedQuery; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.CriteriaQuery; -import jakarta.persistence.criteria.Order; -import jakarta.persistence.criteria.Path; -import jakarta.persistence.criteria.Predicate; -import jakarta.persistence.criteria.Root; - -import static java.util.Arrays.asList; -import static java.util.Collections.emptyList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.kie.kogito.persistence.api.query.QueryFilterFactory.orderBy; -import static org.kie.kogito.persistence.api.query.SortDirection.ASC; -import static org.kie.kogito.persistence.api.query.SortDirection.DESC; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@ExtendWith(MockitoExtension.class) -class DomainQueryTest { - - private static final Class rootType = ProcessInstanceEntity.class; - - @Mock - PanacheRepositoryBase repository; - - @Mock - EntityManager entityManager; - - @Mock - CriteriaBuilder criteriaBuilder; - - @Mock - CriteriaQuery criteriaQuery; - - @Mock - TypedQuery mockQuery; - - @BeforeEach - public void setup() { - when(repository.getEntityManager()).thenReturn(entityManager); - when(entityManager.getCriteriaBuilder()).thenReturn(criteriaBuilder); - when(criteriaBuilder.createQuery(rootType)).thenReturn(criteriaQuery); - when(entityManager.createQuery(criteriaQuery)).thenReturn(mockQuery); - } - - @Test - void testNoParameters() { - JPAQuery query = new JPAQuery(repository, Function.identity(), rootType); - - query.execute(); - - verify(criteriaQuery).from(rootType); - verify(criteriaQuery, never()).where(any(Predicate.class)); - verify(criteriaQuery, never()).orderBy(any(List.class)); - verify(entityManager).createQuery(criteriaQuery); - verify(mockQuery).getResultList(); - } - - @Test - void testEmptyParameters() { - JPAQuery query = new JPAQuery(repository, Function.identity(), rootType); - query.filter(emptyList()); - query.sort(emptyList()); - - query.execute(); - - verify(criteriaQuery).from(rootType); - verify(criteriaQuery, never()).where(any(Predicate.class)); - verify(criteriaQuery, never()).orderBy(any(List.class)); - verify(entityManager).createQuery(criteriaQuery); - verify(mockQuery).getResultList(); - } - - @Test - void testPagination() { - JPAQuery query = new JPAQuery(repository, Function.identity(), rootType); - query.limit(10); - query.offset(0); - - query.execute(); - - verify(criteriaQuery).from(rootType); - verify(criteriaQuery, never()).where(any(Predicate.class)); - verify(criteriaQuery, never()).orderBy(any(List.class)); - verify(entityManager).createQuery(criteriaQuery); - verify(mockQuery).setFirstResult(0); - verify(mockQuery).setMaxResults(10); - verify(mockQuery).getResultList(); - } - - @Test - void testOrderBy() { - Root root = mock(Root.class); - when(root.get(any(String.class))).thenAnswer(inv -> { - Path path = mock(Path.class); - when(path.getAlias()).thenReturn(inv.getArgument(0)); - return path; - }); - when(criteriaQuery.from(rootType)).thenReturn(root); - when(criteriaBuilder.asc(any())).thenAnswer(inv -> { - Order order = mock(Order.class); - when(order.isAscending()).thenReturn(true); - when(order.getExpression()).thenReturn(inv.getArgument(0)); - return order; - }); - when(criteriaBuilder.desc(any())).thenAnswer(inv -> { - Order order = mock(Order.class); - when(order.isAscending()).thenReturn(false); - when(order.getExpression()).thenReturn(inv.getArgument(0)); - return order; - }); - - JPAQuery query = new JPAQuery(repository, Function.identity(), rootType); - query.sort(asList(orderBy("name", DESC), orderBy("date", ASC))); - - query.execute(); - - verify(criteriaQuery).from(rootType); - verify(criteriaQuery, never()).where(any(Predicate.class)); - ArgumentCaptor> captor = ArgumentCaptor.forClass(List.class); - verify(criteriaQuery).orderBy(captor.capture()); - assertThat(captor.getValue()).hasSize(2); - assertThat(captor.getValue().get(0).isAscending()).isFalse(); - assertThat(captor.getValue().get(0).getExpression().getAlias()).isEqualTo("name"); - assertThat(captor.getValue().get(1).isAscending()).isTrue(); - assertThat(captor.getValue().get(1).getExpression().getAlias()).isEqualTo("date"); - verify(entityManager).createQuery(criteriaQuery); - verify(mockQuery).getResultList(); - } - -} diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/JobStorageIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/JobStorageIT.java index 91b5488eaa..168041a92d 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/JobStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/JobStorageIT.java @@ -18,58 +18,13 @@ */ package org.kie.kogito.index.postgresql.storage; -import java.util.UUID; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.model.JobEntity; -import org.kie.kogito.index.jpa.model.JobEntityRepository; -import org.kie.kogito.index.model.Job; -import org.kie.kogito.index.test.TestUtils; -import org.kie.kogito.persistence.api.StorageService; +import org.kie.kogito.index.jpa.storage.AbstractJobStorageIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -public class JobStorageIT extends AbstractStorageIT { - - @Inject - JobEntityRepository repository; - - @Inject - StorageService storage; - - public JobStorageIT() { - super(Job.class); - } - - @Override - public JobEntityRepository getRepository() { - return repository; - } - - @Override - public StorageService getStorage() { - return storage; - } - - @Test - public void testJobEntity() { - String jobId = UUID.randomUUID().toString(); - String processInstanceId = UUID.randomUUID().toString(); - - Job job1 = TestUtils - .createJob(jobId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), "EXPECTED", 0L); - Job job2 = TestUtils - .createJob(jobId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), "SCHEDULED", 1000L); - testStorage(jobId, job1, job2); - } - +public class JobStorageIT extends AbstractJobStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessDefinitionStorageIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessDefinitionStorageIT.java index 5fe6e69c8d..627733c823 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessDefinitionStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/ProcessDefinitionStorageIT.java @@ -18,54 +18,13 @@ */ package org.kie.kogito.index.postgresql.storage; -import java.util.Set; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntity; -import org.kie.kogito.index.jpa.model.ProcessDefinitionEntityRepository; -import org.kie.kogito.index.jpa.storage.ProcessDefinitionEntityStorage; -import org.kie.kogito.index.model.ProcessDefinition; -import org.kie.kogito.index.test.TestUtils; -import org.kie.kogito.persistence.api.StorageService; +import org.kie.kogito.index.jpa.storage.AbstractProcessDefinitionStorageIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -class ProcessDefinitionStorageIT extends AbstractStorageIT { - - @Inject - ProcessDefinitionEntityRepository repository; - - @Inject - StorageService storage; - - public ProcessDefinitionStorageIT() { - super(ProcessDefinition.class); - } - - @Override - public ProcessDefinitionEntityStorage.RepositoryAdapter getRepository() { - return new ProcessDefinitionEntityStorage.RepositoryAdapter(repository); - } - - @Override - public StorageService getStorage() { - return storage; - } - - @Test - void testProcessDefinitionEntity() { - String processId = RandomStringUtils.randomAlphabetic(10); - String version = "1.0"; - ProcessDefinition pdv1 = TestUtils.createProcessDefinition(processId, version, Set.of("admin", "kogito")); - ProcessDefinition pdv2 = TestUtils.createProcessDefinition(processId, version, Set.of("kogito")); - testStorage(pdv1.getKey(), pdv1, pdv2); - } - +class ProcessDefinitionStorageIT extends AbstractProcessDefinitionStorageIT { } 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 6b6b43d8fe..0ad8baf9b6 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 @@ -18,37 +18,13 @@ */ package org.kie.kogito.index.postgresql.storage; -import java.util.UUID; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.model.ProcessInstanceEntityRepository; -import org.kie.kogito.index.model.ProcessInstanceState; -import org.kie.kogito.index.test.TestUtils; +import org.kie.kogito.index.jpa.storage.AbstractProcessInstanceStorageIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -public class ProcessInstanceStorageIT { - - @Inject - ProcessInstanceEntityRepository repository; - - @Test - public void testProcessInstanceEntity() { - 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); - - } - +public class ProcessInstanceStorageIT extends AbstractProcessInstanceStorageIT { } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/UserTaskInstanceStorageIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/UserTaskInstanceStorageIT.java index 33e06afd01..4ada5a0753 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/UserTaskInstanceStorageIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/storage/UserTaskInstanceStorageIT.java @@ -18,38 +18,13 @@ */ package org.kie.kogito.index.postgresql.storage; -import java.util.UUID; - -import org.apache.commons.lang3.RandomStringUtils; -import org.junit.jupiter.api.Test; -import org.kie.kogito.index.jpa.model.UserTaskInstanceEntityRepository; -import org.kie.kogito.index.test.TestUtils; +import org.kie.kogito.index.jpa.storage.AbstractUserTaskInstanceStorageIT; import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; - @QuarkusTest @QuarkusTestResource(PostgreSqlQuarkusTestResource.class) -public class UserTaskInstanceStorageIT { - - @Inject - UserTaskInstanceEntityRepository repository; - - @Test - public void testUserTaskInstanceEntity() { - String taskId = UUID.randomUUID().toString(); - String processInstanceId = UUID.randomUUID().toString(); - TestUtils - .createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), - UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), "InProgress", 0L); - TestUtils - .createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), - UUID.randomUUID().toString(), - RandomStringUtils.randomAlphabetic(10), "Completed", 1000L); - } - +public class UserTaskInstanceStorageIT extends AbstractUserTaskInstanceStorageIT { } diff --git a/data-index/data-index-storage/pom.xml b/data-index/data-index-storage/pom.xml index f6a06bb1fc..9c758c084d 100644 --- a/data-index/data-index-storage/pom.xml +++ b/data-index/data-index-storage/pom.xml @@ -36,6 +36,6 @@ data-index-storage-api data-index-storage-protobuf data-index-storage-postgresql - data-index-storage-jpa + data-index-storage-jpa-common \ No newline at end of file diff --git a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/containers/DataIndexOracleContainer.java b/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/containers/DataIndexOracleContainer.java deleted file mode 100644 index c6b7cc143a..0000000000 --- a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/containers/DataIndexOracleContainer.java +++ /dev/null @@ -1,44 +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. - */ -package org.kie.kogito.index.test.containers; - -/** - * This container wraps Data Index Service container - */ -public class DataIndexOracleContainer extends AbstractDataIndexContainer { - public static final String NAME = "data-index-service-oracle"; - - public DataIndexOracleContainer() { - super(NAME); - } - - public void setDatabaseURL(String oracleURL, String username, String password) { - addEnv("QUARKUS_DATASOURCE_JDBC_URL", oracleURL); - addEnv("QUARKUS_DATASOURCE_USERNAME", username); - addEnv("QUARKUS_DATASOURCE_PASSWORD", password); - addEnv("QUARKUS_FLYWAY_MIGRATE_AT_START", "true"); - addEnv("QUARKUS_FLYWAY_BASELINE_ON_MIGRATE", "true"); - } - - @Override - public String getResourceName() { - return NAME; - } - -} diff --git a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/http/DataIndexOracleHttpQuarkusTestResource.java b/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/http/DataIndexOracleHttpQuarkusTestResource.java deleted file mode 100644 index e72a31e8e8..0000000000 --- a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/http/DataIndexOracleHttpQuarkusTestResource.java +++ /dev/null @@ -1,38 +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. - */ -package org.kie.kogito.index.test.quarkus.http; - -import java.util.HashMap; -import java.util.Map; - -public class DataIndexOracleHttpQuarkusTestResource extends AbstractDataIndexHttpQuarkusTestResource { - - public DataIndexOracleHttpQuarkusTestResource() { - super(new DataIndexOracleHttpResource()); - } - - @Override - protected Map getProperties() { - Map properties = new HashMap<>(); - properties.putAll(getDataIndexConnectionProperties()); - properties.putAll(getTestResource().getProperties()); - return properties; - } - -} diff --git a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/http/DataIndexOracleHttpResource.java b/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/http/DataIndexOracleHttpResource.java deleted file mode 100644 index fc8f666f14..0000000000 --- a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/http/DataIndexOracleHttpResource.java +++ /dev/null @@ -1,79 +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. - */ -package org.kie.kogito.index.test.quarkus.http; - -import java.util.HashMap; -import java.util.Map; - -import org.kie.kogito.index.test.containers.DataIndexOracleContainer; -import org.kie.kogito.test.resources.TestResource; -import org.kie.kogito.testcontainers.KogitoOracleSqlContainer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testcontainers.containers.Network; - -public class DataIndexOracleHttpResource implements TestResource { - - private static final Logger LOGGER = LoggerFactory.getLogger(DataIndexOracleHttpResource.class); - - KogitoOracleSqlContainer oracle = new KogitoOracleSqlContainer(); - DataIndexOracleContainer dataIndex = new DataIndexOracleContainer(); - Map properties = new HashMap<>(); - - @Override - public String getResourceName() { - return dataIndex.getResourceName(); - } - - @Override - public void start() { - LOGGER.debug("Starting Oracle Quarkus test resource"); - properties.clear(); - Network network = Network.newNetwork(); - oracle.withNetwork(network); - oracle.withNetworkAliases("oracle"); - oracle.withUsername("kogito"); - oracle.withPassword("kogito"); - oracle.start(); - - dataIndex.addProtoFileFolder(); - dataIndex.withNetwork(network); - dataIndex.setDatabaseURL("jdbc:oracle:thin:@oracle:1521/" + oracle.getDatabaseName(), - oracle.getUsername(), oracle.getPassword()); - dataIndex.addEnv("QUARKUS_PROFILE", "http-events-support"); - dataIndex.start(); - LOGGER.debug("Oracle Quarkus test resource started"); - } - - @Override - public void stop() { - dataIndex.stop(); - oracle.stop(); - LOGGER.debug("Oracle Quarkus test resource stopped"); - } - - @Override - public int getMappedPort() { - return dataIndex.getMappedPort(); - } - - public Map getProperties() { - return properties; - } -} diff --git a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/kafka/DataIndexOracleKafkaResource.java b/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/kafka/DataIndexOracleKafkaResource.java deleted file mode 100644 index 968ad34f5e..0000000000 --- a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/kafka/DataIndexOracleKafkaResource.java +++ /dev/null @@ -1,92 +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. - */ -package org.kie.kogito.index.test.quarkus.kafka; - -import java.util.HashMap; -import java.util.Map; - -import org.kie.kogito.index.test.containers.DataIndexOracleContainer; -import org.kie.kogito.index.test.containers.KogitoKafkaContainerWithoutBridge; -import org.kie.kogito.test.resources.TestResource; -import org.kie.kogito.testcontainers.Constants; -import org.kie.kogito.testcontainers.KogitoOracleSqlContainer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; - -public class DataIndexOracleKafkaResource implements TestResource { - - private static final Logger LOGGER = LoggerFactory.getLogger(DataIndexOracleKafkaResource.class); - - KogitoKafkaContainerWithoutBridge kafka = new KogitoKafkaContainerWithoutBridge(); - KogitoOracleSqlContainer oracle = new KogitoOracleSqlContainer(); - DataIndexOracleContainer dataIndex = new DataIndexOracleContainer(); - Map properties = new HashMap<>(); - - @Override - public String getResourceName() { - return dataIndex.getResourceName(); - } - - @Override - public void start() { - LOGGER.debug("Starting Oracle Quarkus test resource"); - properties.clear(); - Network network = Network.newNetwork(); - oracle.withNetwork(network); - oracle.withNetworkAliases("oracle"); - oracle.withUsername("kogito"); - oracle.withPassword("kogito"); - oracle.start(); - kafka.withNetwork(network); - kafka.withNetworkAliases("kafka"); - kafka.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT); - kafka.start(); - String kafkaURL = kafka.getBootstrapServers(); - properties.put("kafka.bootstrap.servers", kafkaURL); - properties.put("spring.kafka.bootstrap-servers", kafkaURL); - - dataIndex.addProtoFileFolder(); - dataIndex.withNetwork(network); - dataIndex.setDatabaseURL("jdbc:oracle:thin:@oracle:1521/" + oracle.getDatabaseName(), - oracle.getUsername(), oracle.getPassword()); - dataIndex.setKafkaURL("kafka:29092"); - dataIndex.addEnv("QUARKUS_PROFILE", "kafka-events-support"); - dataIndex.start(); - LOGGER.debug("Oracle Quarkus test resource started"); - } - - @Override - public void stop() { - dataIndex.stop(); - oracle.stop(); - kafka.stop(); - LOGGER.debug("Oracle Quarkus test resource stopped"); - } - - @Override - public int getMappedPort() { - return dataIndex.getMappedPort(); - } - - public Map getProperties() { - return properties; - } -} diff --git a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/kafka/DataIndexOracleQuarkusKafkaTestResource.java b/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/kafka/DataIndexOracleQuarkusKafkaTestResource.java deleted file mode 100644 index 1466378146..0000000000 --- a/data-index/data-index-test-utils/src/main/java/org/kie/kogito/index/test/quarkus/kafka/DataIndexOracleQuarkusKafkaTestResource.java +++ /dev/null @@ -1,41 +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. - */ -package org.kie.kogito.index.test.quarkus.kafka; - -import java.util.HashMap; -import java.util.Map; - -import org.kie.kogito.test.resources.ConditionalQuarkusTestResource; - -import static org.kie.kogito.index.test.Constants.KOGITO_DATA_INDEX_SERVICE_URL; - -public class DataIndexOracleQuarkusKafkaTestResource extends ConditionalQuarkusTestResource { - public DataIndexOracleQuarkusKafkaTestResource() { - super(new DataIndexOracleKafkaResource()); - } - - @Override - protected Map getProperties() { - Map properties = new HashMap<>(); - properties.put(KOGITO_DATA_INDEX_SERVICE_URL, "http://localhost:" + getTestResource().getMappedPort()); - properties.putAll(getTestResource().getProperties()); - return properties; - } - -} diff --git a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java index d3f34c8c23..b291feb5dc 100644 --- a/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java +++ b/data-index/kogito-addons-quarkus-data-index-persistence/kogito-addons-quarkus-data-index-persistence-common/runtime/src/main/java/org/kie/kogito/index/addon/ProcessDefinitionRegister.java @@ -26,6 +26,7 @@ import org.kie.kogito.Application; import org.kie.kogito.index.api.KogitoRuntimeClient; import org.kie.kogito.index.model.ProcessDefinition; +import org.kie.kogito.index.model.ProcessDefinitionKey; import org.kie.kogito.index.service.DataIndexServiceException; import org.kie.kogito.index.storage.DataIndexStorageService; import org.kie.kogito.process.Process; @@ -57,7 +58,7 @@ void startup(@Observes StartupEvent event, Instance processesInstance .map(mapProcessDefinition(app.config().addons().availableAddons(), kogitoServiceUrl.orElse(null), client)) .forEach(process -> { LOGGER.debug("Registering process definition with id: {}", process.getId()); - storage.getProcessDefinitionStorage().put(process.getKey(), process); + storage.getProcessDefinitionStorage().put(new ProcessDefinitionKey(process.getId(), process.getVersion()), process); }); } else { LOGGER.info("No process definitions to register."); diff --git a/kogito-apps-bom/pom.xml b/kogito-apps-bom/pom.xml index 9bdc29b0d9..044ba56f01 100644 --- a/kogito-apps-bom/pom.xml +++ b/kogito-apps-bom/pom.xml @@ -1,4 +1,3 @@ -