From 3ee180a96c561b5293a4550bd5587b567ca2a340 Mon Sep 17 00:00:00 2001 From: Davide D'Alto Date: Thu, 18 Mar 2021 09:49:39 +0000 Subject: [PATCH] [#15839] Test Hibernate Reactive fetch with getReference It has been fixed by one of the latest Hibernate Reactive upgrades. Probably by https://github.com/hibernate/hibernate-reactive/issues/975 --- .../HibernateReactiveTestEndpointFetchLazy.java | 8 ++++++++ .../postgresql/HibernateReactiveFetchLazyTest.java | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/integration-tests/hibernate-reactive-postgresql/src/main/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveTestEndpointFetchLazy.java b/integration-tests/hibernate-reactive-postgresql/src/main/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveTestEndpointFetchLazy.java index ff1b103592e0a..c0dcda200b2f5 100644 --- a/integration-tests/hibernate-reactive-postgresql/src/main/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveTestEndpointFetchLazy.java +++ b/integration-tests/hibernate-reactive-postgresql/src/main/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveTestEndpointFetchLazy.java @@ -34,6 +34,14 @@ public Uni> findBooksWithMutiny(@PathParam("authorId") Integer .chain(author -> Mutiny.fetch(author.getBooks())); } + @GET + @Path("/getReferenceBooksWithMutiny/{authorId}") + public Uni> getReferenceBooksWithMutiny(@PathParam("authorId") Integer authorId) { + return mutinySession + .fetch(mutinySession.getReference(Author.class, authorId)) + .chain(author -> Mutiny.fetch(author.getBooks())); + } + @POST @Path("/prepareDb") public Uni prepareDb() { diff --git a/integration-tests/hibernate-reactive-postgresql/src/test/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveFetchLazyTest.java b/integration-tests/hibernate-reactive-postgresql/src/test/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveFetchLazyTest.java index 1cb288ff8602f..f2ee76ed68657 100644 --- a/integration-tests/hibernate-reactive-postgresql/src/test/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveFetchLazyTest.java +++ b/integration-tests/hibernate-reactive-postgresql/src/test/java/io/quarkus/it/hibernate/reactive/postgresql/HibernateReactiveFetchLazyTest.java @@ -18,6 +18,20 @@ @TestHTTPEndpoint(HibernateReactiveTestEndpointFetchLazy.class) public class HibernateReactiveFetchLazyTest { + @Test + public void fetchAfterGetReferenceWithMutiny() { + RestAssured.when() + .post("/prepareDb") + .then() + .body(is("Neal Stephenson")); + + Response response = RestAssured.when() + .get("/getReferenceBooksWithMutiny/567") + .then() + .extract().response(); + assertTitles(response, "Cryptonomicon", "Snow Crash"); + } + @Test public void fetchAfterFindWithMutiny() { RestAssured.when()