Skip to content

Commit 08c1559

Browse files
committed
HHH-19916 - Drop JUnit 4 usage
Not converted... * org.hibernate.orm.test.type.AbstractJavaTimeTypeTest subtypes - crazy parameterization (see org.hibernate.orm.test.tm.InterceptorTransactionTest)
1 parent da281e5 commit 08c1559

File tree

6 files changed

+25
-30
lines changed

6 files changed

+25
-30
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/json/PostgreSQLMultipleTypesContributorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void tearDown(SessionFactoryScope factoryScope) {
6565
@Test
6666
public void testMultipleTypeContributions(SessionFactoryScope factoryScope) {
6767
factoryScope.inTransaction( entityManager -> {
68+
//noinspection removal
6869
var inets = entityManager.createNativeQuery(
6970
"select e.ip " +
7071
"from Event e " +
@@ -80,6 +81,7 @@ public void testMultipleTypeContributions(SessionFactoryScope factoryScope) {
8081
@Test
8182
public void testMultipleTypeContributionsExplicitBinding(SessionFactoryScope factoryScope) {
8283
factoryScope.inTransaction( entityManager -> {
84+
//noinspection unchecked,deprecation
8385
List<Inet> inets = entityManager.createNativeQuery(
8486
"select e.ip " +
8587
"from Event e " +
@@ -96,7 +98,7 @@ public void testMultipleTypeContributionsExplicitBinding(SessionFactoryScope fac
9698

9799
@Entity(name = "Event")
98100
@Table(name = "event")
99-
public class Event {
101+
public static class Event {
100102

101103
@Id
102104
private Long id;

hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package org.hibernate.orm.test.schemaupdate.foreignkeys.crossschema;
66

7+
import org.hamcrest.MatcherAssert;
78
import org.hibernate.engine.config.spi.ConfigurationService;
89
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
910
import org.hibernate.engine.jdbc.spi.JdbcServices;
@@ -50,11 +51,11 @@
5051

5152
import static org.hamcrest.core.Is.is;
5253
import static org.hibernate.cfg.SchemaToolingSettings.JAKARTA_HBM2DDL_CREATE_SCHEMAS;
53-
import static org.junit.Assert.assertThat;
5454

5555
/**
5656
* @author Andrea Boriero
5757
*/
58+
@SuppressWarnings("JUnitMalformedDeclaration")
5859
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportSchemaCreation.class)
5960
@ServiceRegistry(settings = @Setting(name = JAKARTA_HBM2DDL_CREATE_SCHEMAS, value = "true"))
6061
@DomainModel(annotatedClasses = {SchemaOneEntity.class, SchemaTwoEntity.class})
@@ -78,11 +79,8 @@ public void testSchemaExportForeignKeysAreGeneratedAfterAllTheTablesAreCreated(
7879
.create( EnumSet.of( TargetType.SCRIPT, TargetType.STDOUT ), modelScope.getDomainModel() );
7980

8081
final List<String> sqlLines = Files.readAllLines( scriptFile.toPath(), Charset.defaultCharset() );
81-
assertThat(
82-
"Expected alter table SCHEMA1.Child add constraint but is : " + sqlLines.get( 4 ),
83-
sqlLines.get( sqlLines.size() - 1 ).startsWith( "alter table " ),
84-
is( true )
85-
);
82+
MatcherAssert.assertThat( "Expected alter table SCHEMA1.Child add constraint but is : " + sqlLines.get( 4 ),
83+
sqlLines.get( sqlLines.size() - 1 ).startsWith( "alter table " ), is( true ) );
8684
}
8785

8886
@Test
@@ -112,8 +110,7 @@ public void testSchemaUpdateDoesNotFailResolvingCrossSchemaForeignKey(
112110
@JiraKey(value = "HHH-10420")
113111
public void testSchemaMigrationForeignKeysAreGeneratedAfterAllTheTablesAreCreated(
114112
ServiceRegistryScope registryScope,
115-
DomainModelScope modelScope,
116-
@TempDir File tmpDir) throws Exception {
113+
DomainModelScope modelScope) throws Exception {
117114
final var metadata = modelScope.getDomainModel();
118115

119116
final HibernateSchemaManagementTool tool = (HibernateSchemaManagementTool) registryScope

hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ public void testUniqueConstraintIsDropped(
8585

8686
if ( !(dialect.getUniqueDelegate() instanceof SkipNullableUniqueDelegate) ) {
8787
if ( dialect.getUniqueDelegate() instanceof AlterTableUniqueIndexDelegate) {
88-
assertTrue( checkDropIndex( "test_entity_item", "item", scriptFile ) );
88+
assertTrue( checkDropIndex( scriptFile ) );
8989
}
9090
else if ( dialect.getUniqueDelegate() instanceof AlterTableUniqueDelegate ) {
9191
MatcherAssert.assertThat( "The test_entity_item table unique constraint has not been dropped",
92-
checkDropConstraint( "test_entity_item", "item", dialect, scriptFile ),
92+
checkDropConstraint( "test_entity_item", dialect, scriptFile ),
9393
is( true )
9494
);
9595
}
9696
}
9797

9898
MatcherAssert.assertThat(
99-
checkDropConstraint( "test_entity_children", "child", dialect, scriptFile ),
99+
checkDropConstraint( "test_entity_children", dialect, scriptFile ),
100100
is( true )
101101
);
102102
}
@@ -123,7 +123,6 @@ public ExceptionHandler getExceptionHandler() {
123123

124124
private boolean checkDropConstraint(
125125
String tableName,
126-
String columnName,
127126
Dialect dialect,
128127
File scriptFile) throws IOException {
129128
String regex = dialect.getAlterTableString( tableName ) + ' ' + dialect.getDropUniqueKeyString();
@@ -138,8 +137,8 @@ private boolean checkDropConstraint(
138137
return isMatching( regex, scriptFile );
139138
}
140139

141-
private boolean checkDropIndex(String tableName, String columnName, File scriptFile) throws IOException {
142-
String regex = "drop index " + tableName + ".uk.*";
140+
private boolean checkDropIndex(File scriptFile) throws IOException {
141+
String regex = "drop index test_entity_item.uk.*";
143142
return isMatching( regex, scriptFile );
144143
}
145144

hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/EnumValidationTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,16 @@ public StandardServiceRegistry produceServiceRegistry(StandardServiceRegistryBui
7474
}
7575

7676
@BeforeEach
77-
void setUp(ServiceRegistryScope registryScope, DomainModelScope modelScope) {
77+
void setUp(DomainModelScope modelScope) {
7878
final var model = modelScope.getDomainModel();
7979
model.orderColumns( false );
8080
model.validate();
8181

8282
dropSchema( model );
83-
84-
final var registry = registryScope.getRegistry();
85-
createSchema( model, registry );
83+
createSchema( model );
8684
}
8785

88-
private void createSchema(MetadataImplementor model, StandardServiceRegistry registry) {
86+
private void createSchema(MetadataImplementor model) {
8987
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), model );
9088
}
9189

hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/InstantValidationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,20 @@ public StandardServiceRegistry produceServiceRegistry(StandardServiceRegistryBui
7171
}
7272

7373
@BeforeEach
74-
void setUp(ServiceRegistryScope registryScope, DomainModelScope modelScope) {
74+
void setUp(DomainModelScope modelScope) {
7575
final var model = modelScope.getDomainModel();
7676
model.orderColumns( false );
7777
model.validate();
7878

7979
dropSchema( model );
80-
81-
final var registry = registryScope.getRegistry();
82-
createSchema( model, registry );
80+
createSchema( model );
8381
}
8482

8583
private void dropSchema(MetadataImplementor model) {
8684
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), model );
8785
}
8886

89-
private void createSchema(MetadataImplementor model, StandardServiceRegistry registry) {
87+
private void createSchema(MetadataImplementor model) {
9088
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), model );
9189
}
9290

@@ -131,6 +129,7 @@ public ExceptionHandler getExceptionHandler() {
131129
tool.getSchemaValidator( null ).doValidation( newModel, execOptions, ContributableMatcher.ALL );
132130
}
133131

132+
@SuppressWarnings("unused")
134133
@Entity(name = "TestEntity")
135134
public static class TestEntityOld {
136135
@Id
@@ -140,6 +139,7 @@ public static class TestEntityOld {
140139
Instant instantVal;
141140
}
142141

142+
@SuppressWarnings("unused")
143143
@Entity(name = "TestEntity")
144144
public static class TestEntity {
145145
@Id

hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/NumericValidationTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,20 @@ public StandardServiceRegistry produceServiceRegistry(StandardServiceRegistryBui
7070
}
7171

7272
@BeforeEach
73-
void setUp(ServiceRegistryScope registryScope, DomainModelScope modelScope) {
73+
void setUp(DomainModelScope modelScope) {
7474
final var model = modelScope.getDomainModel();
7575
model.orderColumns( false );
7676
model.validate();
7777

7878
dropSchema( model );
79-
80-
final var registry = registryScope.getRegistry();
81-
createSchema( model, registry );
79+
createSchema( model );
8280
}
8381

8482
private void dropSchema(MetadataImplementor model) {
8583
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE ), model );
8684
}
8785

88-
private void createSchema(MetadataImplementor model, StandardServiceRegistry registry) {
86+
private void createSchema(MetadataImplementor model) {
8987
new SchemaExport().create( EnumSet.of( TargetType.DATABASE ), model );
9088
}
9189

@@ -125,6 +123,7 @@ public ExceptionHandler getExceptionHandler() {
125123
}
126124

127125

126+
@SuppressWarnings("unused")
128127
@Entity(name = "TestEntity")
129128
public static class TestEntity {
130129
@Id

0 commit comments

Comments
 (0)