Skip to content

Commit c9cb5bd

Browse files
committed
HHH-19846 Drop JUnit 4 usage
1 parent e5c8274 commit c9cb5bd

File tree

13 files changed

+201
-190
lines changed

13 files changed

+201
-190
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/quote/resultsetmappings/ExplicitSqlResultSetMappingTest.java

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,61 @@
44
*/
55
package org.hibernate.orm.test.annotations.quote.resultsetmappings;
66

7-
import org.hibernate.cfg.Configuration;
87
import org.hibernate.cfg.Environment;
8+
import org.hibernate.dialect.Dialect;
9+
import org.hibernate.testing.orm.junit.DomainModel;
10+
import org.hibernate.testing.orm.junit.ServiceRegistry;
11+
import org.hibernate.testing.orm.junit.SessionFactory;
12+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
13+
import org.hibernate.testing.orm.junit.Setting;
14+
import org.junit.jupiter.api.AfterEach;
15+
import org.junit.jupiter.api.BeforeEach;
16+
import org.junit.jupiter.api.Test;
917

10-
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
11-
import org.junit.Test;
1218

1319
/**
1420
* @author Steve Ebersole
1521
*/
16-
public class ExplicitSqlResultSetMappingTest extends BaseCoreFunctionalTestCase {
22+
@DomainModel(
23+
annotatedClasses = {
24+
MyEntity.class
25+
}
26+
)
27+
@SessionFactory
28+
@ServiceRegistry(
29+
settings = @Setting(name = Environment.GLOBALLY_QUOTED_IDENTIFIERS, value = "true")
30+
)
31+
public class ExplicitSqlResultSetMappingTest {
1732
private String queryString = null;
1833

19-
@Override
20-
protected Class<?>[] getAnnotatedClasses() {
21-
return new Class<?>[] { MyEntity.class };
22-
}
23-
24-
@Override
25-
protected void configure(Configuration cfg) {
26-
cfg.setProperty( Environment.GLOBALLY_QUOTED_IDENTIFIERS, true );
27-
}
2834

29-
private void prepareTestData() {
30-
char open = getDialect().openQuote();
31-
char close = getDialect().closeQuote();
32-
queryString="select t."+open+"NAME"+close+" as "+open+"QuotEd_nAMe"+close+" from "+open+"MY_ENTITY_TABLE"+close+" t";
33-
inTransaction(
35+
@BeforeEach
36+
public void prepareTestData(SessionFactoryScope scope) {
37+
Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
38+
char open = dialect.openQuote();
39+
char close = dialect.closeQuote();
40+
queryString = "select t." + open + "NAME" + close + " as " + open + "QuotEd_nAMe" + close + " from " + open + "MY_ENTITY_TABLE" + close + " t";
41+
scope.inTransaction(
3442
s -> s.persist( new MyEntity( "mine" ) )
3543

3644
);
3745
}
3846

39-
@Override
40-
protected boolean isCleanupTestDataRequired() {
41-
return true;
47+
@AfterEach
48+
public void cleanup(SessionFactoryScope scope) {
49+
scope.getSessionFactory().getSchemaManager().truncateMappedObjects();
4250
}
4351

4452
@Test
45-
public void testCompleteScalarAutoDiscovery() {
46-
prepareTestData();
47-
48-
inTransaction(
53+
public void testCompleteScalarAutoDiscovery(SessionFactoryScope scope) {
54+
scope.inTransaction(
4955
s -> s.createNativeQuery( queryString ).list()
5056
);
5157
}
5258

5359
@Test
54-
public void testPartialScalarAutoDiscovery() {
55-
prepareTestData();
56-
57-
inTransaction(
60+
public void testPartialScalarAutoDiscovery(SessionFactoryScope scope) {
61+
scope.inTransaction(
5862
s -> s.createNativeQuery( queryString, "explicitScalarResultSetMapping" ).list()
5963
);
6064
}

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/Bag.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import jakarta.persistence.Column;
78
import jakarta.persistence.Entity;
89
import jakarta.persistence.GeneratedValue;

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/Clothes.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import jakarta.persistence.Entity;
78
import jakarta.persistence.Column;
89
import jakarta.persistence.GeneratedValue;
@@ -54,14 +55,10 @@ public void setFlavor(String flavor) {
5455

5556
public boolean equals(Object o) {
5657
if ( this == o ) return true;
57-
if ( !( o instanceof Clothes ) ) return false;
58-
59-
final Clothes clothes = (Clothes) o;
58+
if ( !(o instanceof Clothes clothes) ) return false;
6059

6160
if ( !flavor.equals( clothes.flavor ) ) return false;
62-
if ( !type.equals( clothes.type ) ) return false;
63-
64-
return true;
61+
return type.equals( clothes.type );
6562
}
6663

6764
public int hashCode() {

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/House.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import java.io.Serializable;
78
import java.util.HashSet;
89
import java.util.Set;
@@ -23,7 +24,7 @@ public class House implements Serializable {
2324
private Integer id;
2425
private String address;
2526
private Postman postman;
26-
private Set<Inhabitant> hasInhabitants = new HashSet<Inhabitant>();
27+
private Set<Inhabitant> hasInhabitants = new HashSet<>();
2728

2829
@ManyToOne
2930
@JoinColumn(referencedColumnName = "name")
@@ -67,13 +68,9 @@ public void setHasInhabitants(Set<Inhabitant> hasInhabitants) {
6768

6869
public boolean equals(Object o) {
6970
if ( this == o ) return true;
70-
if ( !( o instanceof House ) ) return false;
71-
72-
final House house = (House) o;
73-
74-
if ( address != null ? !address.equals( house.address ) : house.address != null ) return false;
71+
if ( !(o instanceof House house) ) return false;
7572

76-
return true;
73+
return address != null ? address.equals( house.address ) : house.address == null;
7774
}
7875

7976
public int hashCode() {

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/Inhabitant.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import java.io.Serializable;
78
import java.util.HashSet;
89
import java.util.Set;
@@ -18,7 +19,7 @@
1819
public class Inhabitant implements Serializable {
1920
private Integer id;
2021
private String name;
21-
private Set<House> livesIn = new HashSet<House>();
22+
private Set<House> livesIn = new HashSet<>();
2223

2324
@Id
2425
@GeneratedValue
@@ -49,13 +50,9 @@ public void setLivesIn(Set<House> livesIn) {
4950

5051
public boolean equals(Object o) {
5152
if ( this == o ) return true;
52-
if ( !( o instanceof Inhabitant ) ) return false;
53-
54-
final Inhabitant inhabitant = (Inhabitant) o;
55-
56-
if ( name != null ? !name.equals( inhabitant.name ) : inhabitant.name != null ) return false;
53+
if ( !(o instanceof Inhabitant inhabitant) ) return false;
5754

58-
return true;
55+
return name != null ? name.equals( inhabitant.name ) : inhabitant.name == null;
5956
}
6057

6158
public int hashCode() {

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/Item.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import jakarta.persistence.Entity;
78
import jakarta.persistence.Id;
89

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/ItemCost.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import java.io.Serializable;
78
import java.math.BigDecimal;
89
import jakarta.persistence.Entity;

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/Luggage.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import java.io.Serializable;
78
import java.util.HashSet;
89
import java.util.Set;
@@ -23,7 +24,7 @@ public class Luggage implements Serializable {
2324
private String owner;
2425
@Column(name = "`type`")
2526
private String type;
26-
private Set<Clothes> hasInside = new HashSet<Clothes>();
27+
private Set<Clothes> hasInside = new HashSet<>();
2728

2829
public Luggage() {
2930
}
@@ -72,14 +73,10 @@ public void setHasInside(Set<Clothes> hasInside) {
7273

7374
public boolean equals(Object o) {
7475
if ( this == o ) return true;
75-
if ( !( o instanceof Luggage ) ) return false;
76-
77-
final Luggage luggage = (Luggage) o;
76+
if ( !(o instanceof Luggage luggage) ) return false;
7877

7978
if ( !owner.equals( luggage.owner ) ) return false;
80-
if ( !type.equals( luggage.type ) ) return false;
81-
82-
return true;
79+
return type.equals( luggage.type );
8380
}
8481

8582
public int hashCode() {

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/Postman.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import java.io.Serializable;
78
import jakarta.persistence.Entity;
89
import jakarta.persistence.Id;

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/referencedcolumnname/Rambler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.annotations.referencedcolumnname;
6+
67
import java.io.Serializable;
78
import java.util.HashSet;
89
import java.util.Set;
@@ -20,7 +21,7 @@
2021
public class Rambler implements Serializable {
2122
private Integer id;
2223
private String name;
23-
private Set<Bag> bags = new HashSet<Bag>();
24+
private Set<Bag> bags = new HashSet<>();
2425

2526
public Rambler() {
2627
}

0 commit comments

Comments
 (0)