diff --git a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/custompu/CustomPuEntity.java b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/custompu/CustomPuEntity.java new file mode 100644 index 0000000000000..edb22ff1614de --- /dev/null +++ b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/custompu/CustomPuEntity.java @@ -0,0 +1,10 @@ +package io.quarkus.it.panache.custompu; + +import jakarta.persistence.Entity; + +import io.quarkus.hibernate.orm.panache.PanacheEntity; + +@Entity +public class CustomPuEntity extends PanacheEntity { + public String string; +} diff --git a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/resources/CustomPuResource.java b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/resources/CustomPuResource.java new file mode 100644 index 0000000000000..d4e8c61fafe68 --- /dev/null +++ b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/resources/CustomPuResource.java @@ -0,0 +1,33 @@ +package io.quarkus.it.panache.resources; + +import java.util.List; + +import jakarta.transaction.Transactional; +import jakarta.ws.rs.PATCH; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; + +import io.quarkus.it.panache.custompu.CustomPuEntity; + +@Path("/custom-pu") +public class CustomPuResource { + + @Transactional + @POST + @Path("/{string}") + public CustomPuEntity create(@PathParam("string") String string) { + CustomPuEntity entity = new CustomPuEntity(); + entity.string = string; + entity.persist(); + return entity; + } + + @Transactional + @PATCH + @Path("/{string}") + public List updateAll(@PathParam("string") String string) { + CustomPuEntity.update("set string = ?1 where 1 = 1", string); + return CustomPuEntity.findAll().list(); + } +} diff --git a/integration-tests/hibernate-orm-panache/src/main/resources/application.properties b/integration-tests/hibernate-orm-panache/src/main/resources/application.properties index a4f7671b502a3..c3d3b34f727d6 100644 --- a/integration-tests/hibernate-orm-panache/src/main/resources/application.properties +++ b/integration-tests/hibernate-orm-panache/src/main/resources/application.properties @@ -7,3 +7,12 @@ quarkus.hibernate-orm.database.generation=drop-and-create quarkus.hibernate-orm.statistics=true quarkus.hibernate-orm.metrics.enabled=true + +quarkus.datasource."custom".db-kind=h2 +quarkus.datasource."custom".jdbc.url=jdbc:h2:tcp://localhost/mem:test +quarkus.datasource."custom".jdbc.max-size=8 + +quarkus.hibernate-orm."custom".datasource=custom +quarkus.hibernate-orm."custom".packages=io.quarkus.it.panache.custompu +quarkus.hibernate-orm."custom".database.generation=drop-and-create +quarkus.hibernate-orm."custom".database.generation.create-schemas=true diff --git a/integration-tests/hibernate-orm-panache/src/test/java/io/quarkus/it/panache/custompu/SmokeTest.java b/integration-tests/hibernate-orm-panache/src/test/java/io/quarkus/it/panache/custompu/SmokeTest.java new file mode 100644 index 0000000000000..bb050e5ab7d38 --- /dev/null +++ b/integration-tests/hibernate-orm-panache/src/test/java/io/quarkus/it/panache/custompu/SmokeTest.java @@ -0,0 +1,18 @@ +package io.quarkus.it.panache.custompu; + +import static org.hamcrest.Matchers.containsString; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; + +@QuarkusTest +class SmokeTest { + + @Test + void testPanacheFunctionality() throws Exception { + RestAssured.when().post("/custom-pu/someValue").then().body(containsString("someValue")); + RestAssured.when().patch("/custom-pu/someUpdatedValue").then().body(containsString("someUpdatedValue")); + } +}