Skip to content

Add assertions to the test #2069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Class<?>> annotatedEntities() {
return List.of( Flower.class, Fruit.class );
Expand All @@ -34,21 +44,21 @@ protected Collection<Class<?>> 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(
Expand All @@ -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()
)
)
)
);
}
Expand Down
Loading