Skip to content

Commit 12364d0

Browse files
committed
HHH-19846 Drop JUnit 4 usage
1 parent f18f6e1 commit 12364d0

File tree

6 files changed

+248
-246
lines changed

6 files changed

+248
-246
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/merge/BidirectionalOneToManyMergeTest.java

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
*/
55
package org.hibernate.orm.test.merge;
66

7-
import org.hibernate.testing.orm.junit.JiraKey;
8-
import org.junit.Before;
9-
import org.junit.Test;
10-
117
import jakarta.persistence.CascadeType;
128
import jakarta.persistence.Entity;
139
import jakarta.persistence.FetchType;
@@ -17,42 +13,45 @@
1713
import jakarta.persistence.JoinColumn;
1814
import jakarta.persistence.ManyToOne;
1915
import jakarta.persistence.OneToMany;
16+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
17+
import org.hibernate.testing.orm.junit.JiraKey;
18+
import org.hibernate.testing.orm.junit.Jpa;
19+
import org.junit.jupiter.api.BeforeAll;
20+
import org.junit.jupiter.api.Test;
21+
2022
import java.util.ArrayList;
2123
import java.util.List;
2224

23-
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
24-
2525
/**
2626
* @author Lisandro Fernandez (kelechul at gmail dot com)
2727
*/
2828
@JiraKey("HHH-13815")
29-
public class BidirectionalOneToManyMergeTest extends org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase {
30-
31-
@Override
32-
protected Class<?>[] getAnnotatedClasses() {
33-
return new Class<?>[]{
34-
Post.class,
35-
PostComment.class,
36-
};
37-
}
29+
@Jpa(
30+
annotatedClasses = {
31+
BidirectionalOneToManyMergeTest.Post.class,
32+
BidirectionalOneToManyMergeTest.PostComment.class,
33+
}
34+
)
35+
public class BidirectionalOneToManyMergeTest {
36+
3837

39-
@Before
40-
public void setUp() {
41-
doInJPA(this::entityManagerFactory, entityManager -> {
38+
@BeforeAll
39+
public void setUp(EntityManagerFactoryScope scope) {
40+
scope.inTransaction( entityManager -> {
4241
entityManager.persist(
43-
new Post("High-Performance Java Persistence").setId(1L)
42+
new Post( "High-Performance Java Persistence" ).setId( 1L )
4443
);
45-
});
44+
} );
4645
}
4746

4847
@Test
49-
public void testMerge() {
50-
doInJPA(this::entityManagerFactory, entityManager -> {
51-
Post post = entityManager.find(Post.class, 1L);
52-
post.addComment(new PostComment("This post rocks!", post));
48+
public void testMerge(EntityManagerFactoryScope scope) {
49+
scope.inTransaction( entityManager -> {
50+
Post post = entityManager.find( Post.class, 1L );
51+
post.addComment( new PostComment( "This post rocks!", post ) );
5352
post.getComments().isEmpty();
54-
entityManager.merge(post);
55-
});
53+
entityManager.merge( post );
54+
} );
5655
}
5756

5857
@Entity
@@ -101,15 +100,15 @@ private Post setComments(List<PostComment> comments) {
101100
}
102101

103102
public Post addComment(PostComment comment) {
104-
comments.add(comment);
105-
comment.setPost(this);
103+
comments.add( comment );
104+
comment.setPost( this );
106105

107106
return this;
108107
}
109108

110109
public Post removeComment(PostComment comment) {
111-
comments.remove(comment);
112-
comment.setPost(null);
110+
comments.remove( comment );
111+
comment.setPost( null );
113112

114113
return this;
115114
}
@@ -165,9 +164,13 @@ public PostComment setPost(Post post) {
165164

166165
@Override
167166
public boolean equals(Object o) {
168-
if (this == o) return true;
169-
if (!(o instanceof PostComment)) return false;
170-
return id != null && id.equals(((PostComment) o).getId());
167+
if ( this == o ) {
168+
return true;
169+
}
170+
if ( !(o instanceof PostComment) ) {
171+
return false;
172+
}
173+
return id != null && id.equals( ((PostComment) o).getId() );
171174
}
172175

173176
@Override

0 commit comments

Comments
 (0)