diff --git a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmbeddedIdWithManyTest.java b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmbeddedIdWithManyTest.java index d77de6a4c..eed1e5846 100644 --- a/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmbeddedIdWithManyTest.java +++ b/hibernate-reactive-core/src/test/java/org/hibernate/reactive/EmbeddedIdWithManyTest.java @@ -24,8 +24,18 @@ import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import static org.assertj.core.api.Assertions.assertThat; + public class EmbeddedIdWithManyTest extends BaseReactiveTest { + Fruit cherry; + Fruit apple; + Fruit banana; + + Flower sunflower; + Flower chrysanthemum; + Flower rose; + @Override protected Collection> annotatedEntities() { return List.of( Flower.class, Fruit.class ); @@ -34,21 +44,21 @@ protected Collection> annotatedEntities() { @BeforeEach public void populateDb(VertxTestContext context) { Seed seed1 = new Seed( 1 ); - Flower rose = new Flower( seed1, "Rose" ); + rose = new Flower( seed1, "Rose" ); - Fruit cherry = new Fruit( seed1, "Cherry" ); + cherry = new Fruit( seed1, "Cherry" ); cherry.addFriend( rose ); Seed seed2 = new Seed( 2 ); - Flower sunflower = new Flower( seed2, "Sunflower" ); + sunflower = new Flower( seed2, "Sunflower" ); - Fruit apple = new Fruit( seed2, "Apple" ); + apple = new Fruit( seed2, "Apple" ); apple.addFriend( sunflower ); Seed seed3 = new Seed( 3 ); - Flower chrysanthemum = new Flower( seed3, "Chrysanthemum" ); + chrysanthemum = new Flower( seed3, "Chrysanthemum" ); - Fruit banana = new Fruit( seed3, "Banana" ); + banana = new Fruit( seed3, "Banana" ); banana.addFriend( chrysanthemum ); test( @@ -60,11 +70,28 @@ public void populateDb(VertxTestContext context) { } @Test - public void test(VertxTestContext context) { + public void testFindWithEmbeddedId(VertxTestContext context) { + test( + context, getMutinySessionFactory().withTransaction( s -> s + .find( Flower.class, chrysanthemum.getSeed() ) + .invoke( flower -> assertThat( flower.getName() ).isEqualTo( chrysanthemum.getName() ) ) + ) + ); + } + + @Test + public void testSelectQueryWithEmbeddedId(VertxTestContext context) { test( context, getMutinySessionFactory().withTransaction( s -> s .createSelectionQuery( "from Flower", Flower.class ) .getResultList() + .invoke( list -> assertThat( list.stream().map( Flower::getName ) ) + .containsExactlyInAnyOrder( + sunflower.getName(), + chrysanthemum.getName(), + rose.getName() + ) + ) ) ); }