Skip to content

Commit

Permalink
[#2007] Minor test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD committed Jan 8, 2025
1 parent 69875aa commit 37d57f6
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Collection;
import java.util.List;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -40,26 +39,21 @@ public void populateDb(VertxTestContext context) {
SystemUser systemUser = new SystemUser( subsystem, USER_NAME, "system 1" );
test(
context, getMutinySessionFactory()
.withTransaction( (s, t) -> s.persistAll( subsystem, systemUser ) )
.withTransaction( s -> s.persistAll( subsystem, systemUser ) )
);
}

@AfterEach
public void after(VertxTestContext context) {
test( context, cleanDb() );
}

@Test
public void testQuery(VertxTestContext context) {
test(
context, openSession()
.thenAccept( session -> session.createQuery( "SELECT s FROM SystemUser s", SystemUser.class )
.getResultList().thenAccept( list -> {
assertThat( list.size() ).isEqualTo( 1 );
SystemUser systemUser = list.get( 0 );
assertThat( systemUser.getSubsystem().getId() ).isEqualTo( SUBSYSTEM_ID );
assertThat( systemUser.getUsername() ).isEqualTo( USER_NAME );
} ) )
context, openSession().thenAccept( session -> session
.createQuery( "FROM SystemUser s", SystemUser.class )
.getResultList().thenAccept( list -> {
assertThat( list ).hasSize( 1 );
SystemUser systemUser = list.get( 0 );
assertThat( systemUser.getSubsystem().getId() ).isEqualTo( SUBSYSTEM_ID );
assertThat( systemUser.getUsername() ).isEqualTo( USER_NAME );
} ) )
);
}

Expand Down

0 comments on commit 37d57f6

Please sign in to comment.