Skip to content

Commit f5271ad

Browse files
committed
HHH-19846 - Remove JUnit4: org.hibernate.orm.test.mapping.identifier/*
Signed-off-by: Jan Schatteman <[email protected]>
1 parent dc8cdff commit f5271ad

31 files changed

+349
-528
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/AssignedIdentifierTest.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,20 @@
77
import jakarta.persistence.Entity;
88
import jakarta.persistence.Id;
99

10-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
11-
12-
import org.junit.Before;
13-
import org.junit.Test;
14-
15-
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
10+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
11+
import org.hibernate.testing.orm.junit.Jpa;
12+
import org.junit.jupiter.api.BeforeEach;
13+
import org.junit.jupiter.api.Test;
1614

1715
/**
1816
* @author Vlad Mihalcea
1917
*/
20-
public class AssignedIdentifierTest extends BaseEntityManagerFunctionalTestCase {
21-
22-
@Override
23-
protected Class<?>[] getAnnotatedClasses() {
24-
return new Class<?>[] {
25-
Book.class
26-
};
27-
}
18+
@Jpa(annotatedClasses = {AssignedIdentifierTest.Book.class})
19+
public class AssignedIdentifierTest {
2820

29-
@Before
30-
public void init() {
31-
doInJPA(this::entityManagerFactory, entityManager -> {
21+
@BeforeEach
22+
public void init(EntityManagerFactoryScope scope) {
23+
scope.inTransaction( entityManager -> {
3224
Book book = new Book();
3325
book.setId(1L);
3426
book.setTitle("High-Performance Java Persistence");

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/CompositeNaturalIdTest.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,22 @@
1313

1414
import org.hibernate.Session;
1515
import org.hibernate.annotations.NaturalId;
16-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
1716

18-
import org.junit.Test;
17+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
18+
import org.hibernate.testing.orm.junit.Jpa;
19+
import org.junit.jupiter.api.Test;
1920

20-
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
21-
import static org.junit.Assert.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
2222

2323
/**
2424
* @author Vlad Mihalcea
2525
*/
26-
public class CompositeNaturalIdTest extends BaseEntityManagerFunctionalTestCase {
27-
28-
@Override
29-
protected Class<?>[] getAnnotatedClasses() {
30-
return new Class<?>[] {
31-
Book.class
32-
};
33-
}
26+
@Jpa(annotatedClasses = {CompositeNaturalIdTest.Book.class})
27+
public class CompositeNaturalIdTest {
3428

3529
@Test
36-
public void test() {
37-
doInJPA(this::entityManagerFactory, entityManager -> {
30+
public void test(EntityManagerFactoryScope scope) {
31+
scope.inTransaction( entityManager -> {
3832
Book book = new Book();
3933
book.setId(1L);
4034
book.setTitle("High-Performance Java Persistence");
@@ -46,7 +40,7 @@ public void test() {
4640

4741
entityManager.persist(book);
4842
});
49-
doInJPA(this::entityManagerFactory, entityManager -> {
43+
scope.inTransaction( entityManager -> {
5044
//tag::naturalid-simple-load-access-example[]
5145

5246
Book book = entityManager
@@ -62,7 +56,7 @@ public void test() {
6256

6357
assertEquals("High-Performance Java Persistence", book.getTitle());
6458
});
65-
doInJPA(this::entityManagerFactory, entityManager -> {
59+
scope.inTransaction( entityManager -> {
6660
//tag::naturalid-load-access-example[]
6761

6862
Book book = entityManager

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/EmbeddedIdManyToOneTest.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,25 @@
1313
import jakarta.persistence.Id;
1414
import jakarta.persistence.ManyToOne;
1515

16-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
16+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
17+
import org.hibernate.testing.orm.junit.Jpa;
18+
import org.junit.jupiter.api.BeforeEach;
19+
import org.junit.jupiter.api.Test;
1720

18-
import org.junit.Before;
19-
import org.junit.Test;
20-
21-
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
22-
import static org.junit.Assert.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
2322

2423
/**
2524
* @author Vlad Mihalcea
2625
*/
27-
public class EmbeddedIdManyToOneTest extends BaseEntityManagerFunctionalTestCase {
28-
29-
@Override
30-
protected Class<?>[] getAnnotatedClasses() {
31-
return new Class<?>[] {
32-
SystemUser.class,
33-
Subsystem.class
34-
};
35-
}
36-
37-
@Before
38-
public void init() {
39-
doInJPA(this::entityManagerFactory, entityManager -> {
26+
@Jpa(annotatedClasses = {
27+
EmbeddedIdManyToOneTest.SystemUser.class,
28+
EmbeddedIdManyToOneTest.Subsystem.class}
29+
)
30+
public class EmbeddedIdManyToOneTest {
31+
32+
@BeforeEach
33+
public void init(EntityManagerFactoryScope scope) {
34+
scope.inTransaction( entityManager -> {
4035
Subsystem subsystem = new Subsystem();
4136
subsystem.setId("Hibernate Forum");
4237
subsystem.setDescription("Hibernate projects forum");
@@ -55,8 +50,8 @@ public void init() {
5550

5651

5752
@Test
58-
public void test() {
59-
doInJPA(this::entityManagerFactory, entityManager -> {
53+
public void test(EntityManagerFactoryScope scope) {
54+
scope.inTransaction( entityManager -> {
6055
Subsystem subsystem = entityManager.find(
6156
Subsystem.class,
6257
"Hibernate Forum"

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/EmbeddedIdTest.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,22 @@
1010
import jakarta.persistence.EmbeddedId;
1111
import jakarta.persistence.Entity;
1212

13-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
13+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
14+
import org.hibernate.testing.orm.junit.Jpa;
15+
import org.junit.jupiter.api.BeforeEach;
16+
import org.junit.jupiter.api.Test;
1417

15-
import org.junit.Before;
16-
import org.junit.Test;
17-
18-
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
19-
import static org.junit.Assert.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
2019

2120
/**
2221
* @author Vlad Mihalcea
2322
*/
24-
public class EmbeddedIdTest extends BaseEntityManagerFunctionalTestCase {
25-
26-
@Override
27-
protected Class<?>[] getAnnotatedClasses() {
28-
return new Class<?>[] {
29-
SystemUser.class
30-
};
31-
}
23+
@Jpa(annotatedClasses = {EmbeddedIdTest.SystemUser.class})
24+
public class EmbeddedIdTest {
3225

33-
@Before
34-
public void init() {
35-
doInJPA(this::entityManagerFactory, entityManager -> {
26+
@BeforeEach
27+
public void init(EntityManagerFactoryScope scope) {
28+
scope.inTransaction( entityManager -> {
3629
SystemUser systemUser = new SystemUser();
3730
systemUser.setPk(new PK(
3831
"Hibernate Forum",
@@ -46,8 +39,8 @@ public void init() {
4639

4740

4841
@Test
49-
public void test() {
50-
doInJPA(this::entityManagerFactory, entityManager -> {
42+
public void test(EntityManagerFactoryScope scope) {
43+
scope.inTransaction( entityManager -> {
5144
SystemUser systemUser = entityManager.find(
5245
SystemUser.class,
5346
new PK(

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/EntityTableCatalogTest.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,21 @@
99
import jakarta.persistence.Table;
1010

1111
import org.hibernate.dialect.MySQLDialect;
12-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
1312

14-
import org.hibernate.testing.RequiresDialect;
15-
import org.junit.Test;
13+
import org.hibernate.testing.orm.junit.RequiresDialect;
14+
import org.hibernate.testing.orm.junit.Jpa;
15+
import org.junit.jupiter.api.Test;
1616

1717

1818
/**
1919
* @author Vlad Mihalcea
2020
*/
21+
@Jpa(annotatedClasses = {EntityTableCatalogTest.Book.class})
2122
@RequiresDialect(MySQLDialect.class)
22-
public class EntityTableCatalogTest extends BaseEntityManagerFunctionalTestCase {
23-
24-
@Override
25-
protected Class<?>[] getAnnotatedClasses() {
26-
return new Class<?>[] {
27-
Book.class
28-
};
29-
}
23+
public class EntityTableCatalogTest {
3024

3125
@Test
3226
public void test() {
33-
3427
}
3528

3629
//tag::mapping-entity-table-catalog-mysql-example[]

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/EntityTableSchemaTest.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,20 @@
99
import jakarta.persistence.Table;
1010

1111
import org.hibernate.dialect.PostgreSQLDialect;
12-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
1312

14-
import org.hibernate.testing.RequiresDialect;
15-
import org.junit.Test;
13+
import org.hibernate.testing.orm.junit.RequiresDialect;
14+
import org.hibernate.testing.orm.junit.Jpa;
15+
import org.junit.jupiter.api.Test;
1616

1717
/**
1818
* @author Vlad Mihalcea
1919
*/
2020
@RequiresDialect(PostgreSQLDialect.class)
21-
public class EntityTableSchemaTest extends BaseEntityManagerFunctionalTestCase {
22-
23-
@Override
24-
protected Class<?>[] getAnnotatedClasses() {
25-
return new Class<?>[] {
26-
Book.class
27-
};
28-
}
21+
@Jpa(annotatedClasses = {EntityTableSchemaTest.Book.class})
22+
public class EntityTableSchemaTest {
2923

3024
@Test
3125
public void test() {
32-
3326
}
3427

3528
//tag::mapping-entity-table-schema-postgresql-example[]

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/GeneratedIdentifierTest.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,21 @@
88
import jakarta.persistence.GeneratedValue;
99
import jakarta.persistence.Id;
1010

11-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
11+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
12+
import org.hibernate.testing.orm.junit.Jpa;
13+
import org.junit.jupiter.api.BeforeEach;
14+
import org.junit.jupiter.api.Test;
1215

13-
import org.junit.Before;
14-
import org.junit.Test;
15-
16-
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
1716

1817
/**
1918
* @author Vlad Mihalcea
2019
*/
21-
public class GeneratedIdentifierTest extends BaseEntityManagerFunctionalTestCase {
22-
23-
@Override
24-
protected Class<?>[] getAnnotatedClasses() {
25-
return new Class<?>[] {
26-
Book.class
27-
};
28-
}
20+
@Jpa(annotatedClasses = {GeneratedIdentifierTest.Book.class})
21+
public class GeneratedIdentifierTest {
2922

30-
@Before
31-
public void init() {
32-
doInJPA(this::entityManagerFactory, entityManager -> {
23+
@BeforeEach
24+
public void init(EntityManagerFactoryScope scope) {
25+
scope.inTransaction( entityManager -> {
3326
Book book = new Book();
3427
book.setTitle("High-Performance Java Persistence");
3528
book.setAuthor("Vlad Mihalcea");

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/IdClassGeneratedValueTest.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,21 @@
1111
import jakarta.persistence.Id;
1212
import jakarta.persistence.IdClass;
1313

14-
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
14+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
15+
import org.hibernate.testing.orm.junit.Jpa;
16+
import org.junit.jupiter.api.Test;
1517

16-
import org.junit.Test;
17-
18-
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
19-
import static org.junit.Assert.assertEquals;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
2019

2120
/**
2221
* @author Vlad Mihalcea
2322
*/
24-
public class IdClassGeneratedValueTest extends BaseEntityManagerFunctionalTestCase {
25-
26-
@Override
27-
protected Class<?>[] getAnnotatedClasses() {
28-
return new Class<?>[] {
29-
SystemUser.class
30-
};
31-
}
23+
@Jpa(annotatedClasses = {IdClassGeneratedValueTest.SystemUser.class})
24+
public class IdClassGeneratedValueTest {
3225

3326
@Test
34-
public void test() {
35-
SystemUser _systemUser = doInJPA(this::entityManagerFactory, entityManager -> {
27+
public void test(EntityManagerFactoryScope scope) {
28+
SystemUser _systemUser = scope.fromTransaction( entityManager -> {
3629
SystemUser systemUser = new SystemUser();
3730
systemUser.setId(
3831
new PK(
@@ -47,12 +40,8 @@ public void test() {
4740
return systemUser;
4841
});
4942

50-
doInJPA(this::entityManagerFactory, entityManager -> {
51-
SystemUser systemUser = entityManager.find(
52-
SystemUser.class,
53-
_systemUser.getId()
54-
);
55-
43+
scope.inTransaction( entityManager -> {
44+
SystemUser systemUser = entityManager.find( SystemUser.class, _systemUser.getId() );
5645
assertEquals("Vlad Mihalcea", systemUser.getName());
5746
});
5847

0 commit comments

Comments
 (0)