2424import jakarta .persistence .OneToMany ;
2525import jakarta .persistence .Table ;
2626
27+ import static org .assertj .core .api .Assertions .assertThat ;
28+
2729public class EmbeddedIdWithManyTest extends BaseReactiveTest {
2830
31+ Fruit cherry ;
32+ Fruit apple ;
33+ Fruit banana ;
34+
35+ Flower sunflower ;
36+ Flower chrysanthemum ;
37+ Flower rose ;
38+
2939 @ Override
3040 protected Collection <Class <?>> annotatedEntities () {
3141 return List .of ( Flower .class , Fruit .class );
@@ -34,21 +44,21 @@ protected Collection<Class<?>> annotatedEntities() {
3444 @ BeforeEach
3545 public void populateDb (VertxTestContext context ) {
3646 Seed seed1 = new Seed ( 1 );
37- Flower rose = new Flower ( seed1 , "Rose" );
47+ rose = new Flower ( seed1 , "Rose" );
3848
39- Fruit cherry = new Fruit ( seed1 , "Cherry" );
49+ cherry = new Fruit ( seed1 , "Cherry" );
4050 cherry .addFriend ( rose );
4151
4252 Seed seed2 = new Seed ( 2 );
43- Flower sunflower = new Flower ( seed2 , "Sunflower" );
53+ sunflower = new Flower ( seed2 , "Sunflower" );
4454
45- Fruit apple = new Fruit ( seed2 , "Apple" );
55+ apple = new Fruit ( seed2 , "Apple" );
4656 apple .addFriend ( sunflower );
4757
4858 Seed seed3 = new Seed ( 3 );
49- Flower chrysanthemum = new Flower ( seed3 , "Chrysanthemum" );
59+ chrysanthemum = new Flower ( seed3 , "Chrysanthemum" );
5060
51- Fruit banana = new Fruit ( seed3 , "Banana" );
61+ banana = new Fruit ( seed3 , "Banana" );
5262 banana .addFriend ( chrysanthemum );
5363
5464 test (
@@ -60,11 +70,28 @@ public void populateDb(VertxTestContext context) {
6070 }
6171
6272 @ Test
63- public void test (VertxTestContext context ) {
73+ public void testFindWithEmbeddedId (VertxTestContext context ) {
74+ test (
75+ context , getMutinySessionFactory ().withTransaction ( s -> s
76+ .find ( Flower .class , chrysanthemum .getSeed () )
77+ .invoke ( flower -> assertThat ( flower .getName () ).isEqualTo ( chrysanthemum .getName () ) )
78+ )
79+ );
80+ }
81+
82+ @ Test
83+ public void testSelectQueryWithEmbeddedId (VertxTestContext context ) {
6484 test (
6585 context , getMutinySessionFactory ().withTransaction ( s -> s
6686 .createSelectionQuery ( "from Flower" , Flower .class )
6787 .getResultList ()
88+ .invoke ( list -> assertThat ( list .stream ().map ( Flower ::getName ) )
89+ .containsExactlyInAnyOrder (
90+ sunflower .getName (),
91+ chrysanthemum .getName (),
92+ rose .getName ()
93+ )
94+ )
6895 )
6996 );
7097 }
0 commit comments