diff --git a/jobs-service/jobs-service-storage-jpa/pom.xml b/jobs-service/jobs-service-storage-jpa/pom.xml index 99de150744..4e1594188e 100644 --- a/jobs-service/jobs-service-storage-jpa/pom.xml +++ b/jobs-service/jobs-service-storage-jpa/pom.xml @@ -78,6 +78,11 @@ quarkus-test-h2 test + + io.quarkus + quarkus-jdbc-postgresql + test + org.kie.kogito kogito-quarkus-test-utils diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/profiles/H2QuarkusTestProfile.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/profiles/H2QuarkusTestProfile.java new file mode 100644 index 0000000000..9b5c1296fe --- /dev/null +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/profiles/H2QuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.kogito.jobs.service.profiles; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class H2QuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-h2"; + } +} diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/profiles/PostgreSQLQuarkusTestProfile.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/profiles/PostgreSQLQuarkusTestProfile.java new file mode 100644 index 0000000000..4301d1322c --- /dev/null +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/profiles/PostgreSQLQuarkusTestProfile.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.kogito.jobs.service.profiles; + +import io.quarkus.test.junit.QuarkusTestProfile; + +public class PostgreSQLQuarkusTestProfile implements QuarkusTestProfile { + + @Override + public String getConfigProfile() { + return "test-postgresql"; + } +} diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/JPAReactiveJobServiceManagementRepositoryTest.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/BaseJPAReactiveJobServiceManagementRepositoryTest.java similarity index 74% rename from jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/JPAReactiveJobServiceManagementRepositoryTest.java rename to jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/BaseJPAReactiveJobServiceManagementRepositoryTest.java index 4ca80a3df7..8cb774ef2a 100644 --- a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/JPAReactiveJobServiceManagementRepositoryTest.java +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/BaseJPAReactiveJobServiceManagementRepositoryTest.java @@ -1,51 +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.jobs.service.repository.jpa; import java.time.OffsetDateTime; import java.util.concurrent.atomic.AtomicReference; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.kie.kogito.jobs.service.model.JobServiceManagementInfo; import org.kie.kogito.jobs.service.repository.JobServiceManagementRepository; import org.kie.kogito.jobs.service.utils.DateUtil; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.h2.H2DatabaseTestResource; -import io.quarkus.test.junit.QuarkusTest; - import jakarta.inject.Inject; import static org.assertj.core.api.Assertions.assertThat; -@QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -class JPAReactiveJobServiceManagementRepositoryTest { - +public abstract class BaseJPAReactiveJobServiceManagementRepositoryTest { @Inject JobServiceManagementRepository tested; - @BeforeEach - void setUp() { - } - @Test void testGetAndUpdate() { String id = "instance-id-1"; diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/JPAReactiveJobRepositoryTest.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/H2JPAReactiveJobRepositoryTest.java similarity index 82% rename from jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/JPAReactiveJobRepositoryTest.java rename to jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/H2JPAReactiveJobRepositoryTest.java index d1fe3cafee..ceefab3aa0 100644 --- a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/JPAReactiveJobRepositoryTest.java +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/H2JPAReactiveJobRepositoryTest.java @@ -19,18 +19,21 @@ package org.kie.kogito.jobs.service.repository.jpa; import org.junit.jupiter.api.BeforeEach; +import org.kie.kogito.jobs.service.profiles.H2QuarkusTestProfile; import org.kie.kogito.jobs.service.repository.ReactiveJobRepository; import org.kie.kogito.jobs.service.repository.impl.BaseJobRepositoryTest; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; import jakarta.inject.Inject; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) -public class JPAReactiveJobRepositoryTest extends BaseJobRepositoryTest { +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +public class H2JPAReactiveJobRepositoryTest extends BaseJobRepositoryTest { @Inject JPAReactiveJobRepository tested; diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/H2JPAReactiveJobServiceManagementRepositoryTest.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/H2JPAReactiveJobServiceManagementRepositoryTest.java new file mode 100644 index 0000000000..3a6fd1dd32 --- /dev/null +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/H2JPAReactiveJobServiceManagementRepositoryTest.java @@ -0,0 +1,33 @@ +/* + * 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.jobs.service.repository.jpa; + +import org.kie.kogito.jobs.service.profiles.H2QuarkusTestProfile; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) +class H2JPAReactiveJobServiceManagementRepositoryTest extends BaseJPAReactiveJobServiceManagementRepositoryTest { + +} diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/PostgresSqlJPAReactiveJobRepositoryTest.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/PostgresSqlJPAReactiveJobRepositoryTest.java new file mode 100644 index 0000000000..e83abe5ac0 --- /dev/null +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/PostgresSqlJPAReactiveJobRepositoryTest.java @@ -0,0 +1,51 @@ +/* + * 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.jobs.service.repository.jpa; + +import org.junit.jupiter.api.BeforeEach; +import org.kie.kogito.jobs.service.profiles.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.jobs.service.repository.ReactiveJobRepository; +import org.kie.kogito.jobs.service.repository.impl.BaseJobRepositoryTest; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +import jakarta.inject.Inject; + +@QuarkusTest +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +public class PostgresSqlJPAReactiveJobRepositoryTest extends BaseJobRepositoryTest { + + @Inject + JPAReactiveJobRepository tested; + + @BeforeEach + public void setUp() throws Exception { + + super.setUp(); + } + + @Override + public ReactiveJobRepository tested() { + return tested; + } +} diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/PostgresSqlJPAReactiveJobServiceManagementRepositoryTest.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/PostgresSqlJPAReactiveJobServiceManagementRepositoryTest.java new file mode 100644 index 0000000000..a28de96cd7 --- /dev/null +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/repository/jpa/PostgresSqlJPAReactiveJobServiceManagementRepositoryTest.java @@ -0,0 +1,33 @@ +/* + * 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.jobs.service.repository.jpa; + +import org.kie.kogito.jobs.service.profiles.PostgreSQLQuarkusTestProfile; +import org.kie.kogito.testcontainers.quarkus.PostgreSqlQuarkusTestResource; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@QuarkusTestResource(value = PostgreSqlQuarkusTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(PostgreSQLQuarkusTestProfile.class) +class PostgresSqlJPAReactiveJobServiceManagementRepositoryTest extends BaseJPAReactiveJobServiceManagementRepositoryTest { + +} diff --git a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/resource/JPAJobResourceTest.java b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/resource/JPAJobResourceTest.java index 0fdc67d712..dd374d1a08 100644 --- a/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/resource/JPAJobResourceTest.java +++ b/jobs-service/jobs-service-storage-jpa/src/test/java/org/kie/kogito/jobs/service/resource/JPAJobResourceTest.java @@ -18,12 +18,16 @@ */ package org.kie.kogito.jobs.service.resource; +import org.kie.kogito.jobs.service.profiles.H2QuarkusTestProfile; + import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; @QuarkusTest -@QuarkusTestResource(H2DatabaseTestResource.class) +@QuarkusTestResource(value = H2DatabaseTestResource.class, restrictToAnnotatedClass = true) +@TestProfile(H2QuarkusTestProfile.class) public class JPAJobResourceTest extends BaseJobResourceTest { } diff --git a/jobs-service/jobs-service-storage-jpa/src/test/resources/application.properties b/jobs-service/jobs-service-storage-jpa/src/test/resources/application.properties index 2098cb5581..2ea054d823 100644 --- a/jobs-service/jobs-service-storage-jpa/src/test/resources/application.properties +++ b/jobs-service/jobs-service-storage-jpa/src/test/resources/application.properties @@ -19,12 +19,14 @@ # Kogito kogito.apps.persistence.type=jdbc # Data source -quarkus.datasource.db-kind=h2 -quarkus.datasource.username=kogito -quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY +%test-h2.quarkus.datasource.db-kind=h2 +%test-h2.quarkus.datasource.username=kogito +%test-h2.quarkus.datasource.jdbc.url=jdbc:h2:mem:default;NON_KEYWORDS=VALUE,KEY +%test-postgresql.quarkus.datasource.db-kind=postgresql +%test-postgresql.quarkus.datasource.devservices.enabled=false kie.flyway.enabled=true # Disabling Security for tests quarkus.oidc.enabled=false quarkus.oidc.tenant-enabled=false quarkus.oidc.auth-server-url=none -quarkus.keycloak.devservices.enabled=false \ No newline at end of file +quarkus.keycloak.devservices.enabled=false diff --git a/persistence-commons/persistence-commons-protobuf/src/test/java/org/kie/kogito/persistence/protobuf/ProtobufServiceTest.java b/persistence-commons/persistence-commons-protobuf/src/test/java/org/kie/kogito/persistence/protobuf/ProtobufServiceTest.java index 6cd674fd3b..daf3a1130d 100644 --- a/persistence-commons/persistence-commons-protobuf/src/test/java/org/kie/kogito/persistence/protobuf/ProtobufServiceTest.java +++ b/persistence-commons/persistence-commons-protobuf/src/test/java/org/kie/kogito/persistence/protobuf/ProtobufServiceTest.java @@ -95,7 +95,7 @@ void registerProtoBufferTypeWithInvalidKogitoDescriptors() { exceptionMessage = e.getMessage(); } - assertTrue(exceptionMessage.contains("java.lang.IllegalStateException")); + assertTrue(exceptionMessage.contains("Syntax error in test")); verify(schemaEvent, never()).fire(any(SchemaRegisteredEvent.class)); verify(domainModelEvent, never()).fire(any(FileDescriptorRegisteredEvent.class));