Skip to content

Commit c11cf78

Browse files
committed
Fix warnings in test
1 parent 29d84cd commit c11cf78

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/JoinedSubclassInheritanceTest.java

+37-24
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import jakarta.persistence.TemporalType;
2929

3030
import static java.util.concurrent.TimeUnit.MINUTES;
31+
import static org.assertj.core.api.Assertions.assertThat;
3132
import static org.junit.jupiter.api.Assertions.assertEquals;
32-
import static org.junit.jupiter.api.Assertions.assertFalse;
3333
import static org.junit.jupiter.api.Assertions.assertNotNull;
3434
import static org.junit.jupiter.api.Assertions.assertTrue;
3535

@@ -56,9 +56,8 @@ public void testRootClassViaAssociation(VertxTestContext context) {
5656
.thenCompose( v -> openSession() )
5757
.thenCompose( s2 -> s2.find( Author.class, author.getId() ) )
5858
.thenAccept( auth -> {
59-
assertNotNull( auth );
60-
assertEquals( author, auth );
61-
assertEquals( book.getTitle(), auth.getBook().getTitle() );
59+
assertThat( auth ).isEqualTo( author );
60+
assertThat( auth.getBook().getTitle() ).isEqualTo( book.getTitle() );
6261
} )
6362
)
6463
);
@@ -77,17 +76,15 @@ public void testSubclassViaAssociation(VertxTestContext context) {
7776
.thenCompose( v -> s.flush() )
7877
.thenCompose( v -> s.find( Author.class, author.getId() ) )
7978
.thenAccept( auth -> {
80-
assertNotNull( auth );
81-
assertEquals( author, auth );
82-
assertEquals( book.getTitle(), auth.getBook().getTitle() );
79+
assertThat( auth ).isEqualTo( author );
80+
assertThat( auth.getBook().getTitle() ).isEqualTo( book.getTitle() );
8381
} )
8482
)
8583
);
8684
}
8785

8886
@Test
8987
public void testRootClassViaFind(VertxTestContext context) {
90-
9188
final Book novel = new Book( 6, "The Boy, The Mole, The Fox and The Horse", new Date());
9289
final Author author = new Author( "Charlie Mackesy", novel );
9390

@@ -99,9 +96,8 @@ public void testRootClassViaFind(VertxTestContext context) {
9996
.thenCompose( v -> openSession()
10097
.thenCompose( s -> s.find(Book.class, 6) ) )
10198
.thenAccept(book -> {
102-
assertNotNull(book);
103-
assertFalse(book instanceof SpellBook);
104-
assertEquals(book.getTitle(), "The Boy, The Mole, The Fox and The Horse");
99+
assertThat( book ).isNotInstanceOf( SpellBook.class );
100+
assertThat( book.getTitle() ).isEqualTo( "The Boy, The Mole, The Fox and The Horse" );
105101
}));
106102
}
107103

@@ -126,26 +122,33 @@ public void testSubclassViaFind(VertxTestContext context) {
126122
@Test
127123
public void testQueryUpdate(VertxTestContext context) {
128124
final SpellBook spells = new SpellBook( 6, "Necronomicon", true, new Date() );
129-
// final Author author = new Author( "Abdul Alhazred", spells );
130125

131-
test( context,
126+
test(
127+
context,
132128
openSession()
133-
.thenCompose( s -> s.persist(spells).thenCompose( v -> s.flush() ) )
129+
.thenCompose( s -> s.persist( spells ).thenCompose( v -> s.flush() ) )
134130
.thenCompose( vv -> openSession()
135-
.thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set title='x' where forbidden=false").executeUpdate() )
136-
.thenCompose( v -> s.withTransaction( t -> s.createMutationQuery("update SpellBook set forbidden=false where title='Necronomicon'").executeUpdate() ) )
137-
.thenCompose( v -> s.withTransaction( t -> s.createMutationQuery("update Book set title=title||' II' where title='Necronomicon'").executeUpdate() ) )
138-
.thenCompose( v -> s.find(Book.class, 6) )
131+
.thenCompose( s -> s.withTransaction( t -> s
132+
.createMutationQuery( "update SpellBook set title='x' where forbidden=false" )
133+
.executeUpdate() )
134+
.thenCompose( v -> s.withTransaction( t -> s
135+
.createMutationQuery( "update SpellBook set forbidden=false where title='Necronomicon'" )
136+
.executeUpdate() ) )
137+
.thenCompose( v -> s.withTransaction( t -> s
138+
.createMutationQuery( "update Book set title=title||' II' where title='Necronomicon'" )
139+
.executeUpdate() ) )
140+
.thenCompose( v -> s.find( Book.class, 6 ) )
139141
.thenAccept( book -> {
140-
assertNotNull(book);
141-
assertTrue(book instanceof SpellBook);
142-
assertEquals(book.getTitle(), "Necronomicon II");
142+
assertThat( book ).isInstanceOf( SpellBook.class );
143+
assertThat( book.getTitle() ).isEqualTo( "Necronomicon II" );
143144
} )
144-
) )
145+
) )
145146
.thenCompose( vv -> openSession()
146-
.thenCompose( s -> s.withTransaction( t -> s.createMutationQuery("delete Book where title='Necronomicon II'").executeUpdate() ) )
147+
.thenCompose( s -> s.withTransaction( t -> s
148+
.createMutationQuery( "delete Book where title='Necronomicon II'" )
149+
.executeUpdate() ) )
147150
.thenCompose( v -> openSession() )
148-
.thenCompose( s -> s.find(Book.class, 6) )
151+
.thenCompose( s -> s.find( Book.class, 6 ) )
149152
.thenAccept( Assertions::assertNull )
150153
)
151154
);
@@ -207,6 +210,11 @@ public SpellBook(Integer id, String title, boolean forbidden, Date published) {
207210
public boolean getForbidden() {
208211
return forbidden;
209212
}
213+
214+
@Override
215+
public String toString() {
216+
return "SpellBook{" + super.toString() + ",forbidden=" + forbidden + '}';
217+
}
210218
}
211219

212220
@Entity(name="Book")
@@ -268,6 +276,11 @@ public boolean equals(Object o) {
268276
public int hashCode() {
269277
return Objects.hash( title );
270278
}
279+
280+
@Override
281+
public String toString() {
282+
return id + ", " + title + ", " + published;
283+
}
271284
}
272285

273286
@Entity(name = "Author")

0 commit comments

Comments
 (0)