1313import jakarta .persistence .MapsId ;
1414import jakarta .persistence .OneToOne ;
1515import jakarta .persistence .PrimaryKeyJoinColumn ;
16-
1716import org .hibernate .boot .model .relational .Namespace ;
1817import org .hibernate .mapping .Table ;
19-
18+ import org . hibernate . testing . orm . junit . DomainModel ;
2019import org .hibernate .testing .orm .junit .JiraKey ;
21- import org .hibernate .testing .junit4 .BaseNonConfigCoreFunctionalTestCase ;
22- import org .junit .Test ;
20+ import org .hibernate .testing .orm .junit .SessionFactory ;
21+ import org .hibernate .testing .orm .junit .SessionFactoryScope ;
22+ import org .junit .jupiter .api .Test ;
2323
24- import static org .junit . Assert . assertEquals ;
24+ import static org .assertj . core . api . Assertions . assertThat ;
2525
2626/**
2727 * @author Chris Cranford
2828 */
29- public class ForeignKeyNoConstraintTest extends BaseNonConfigCoreFunctionalTestCase {
30- @ Override
31- protected Class [] getAnnotatedClasses () {
32- return new Class <?>[] {
33- Car .class ,
34- VehicleNumber . class ,
35- Post . class ,
36- PostDetails . class
37- };
38- }
29+ @ DomainModel (
30+ annotatedClasses = {
31+ ForeignKeyNoConstraintTest . Car . class ,
32+ ForeignKeyNoConstraintTest . VehicleNumber . class ,
33+ ForeignKeyNoConstraintTest . Post .class ,
34+ ForeignKeyNoConstraintTest . PostDetails . class
35+ }
36+ )
37+ @ SessionFactory
38+ public class ForeignKeyNoConstraintTest {
3939
4040 @ Test
4141 @ JiraKey (value = "HHH-12975" )
42- public void testPrimaryKeyJoinColumnForeignKeyNoConstraint () {
43- for ( Namespace namespace : metadata ().getDatabase ().getNamespaces () ) {
42+ public void testPrimaryKeyJoinColumnForeignKeyNoConstraint (SessionFactoryScope scope ) {
43+ for ( Namespace namespace : scope . getMetadataImplementor ().getDatabase ().getNamespaces () ) {
4444 for ( Table table : namespace .getTables () ) {
4545 if ( "Car" .equals ( table .getName () ) ) {
46- assertEquals ( 0 , table .getForeignKeyCollection (). size () );
46+ assertThat ( table .getForeignKeyCollection () ). hasSize ( 0 );
4747 }
4848 }
4949 }
5050 }
5151
5252 @ Test
5353 @ JiraKey (value = "HHH-12975" )
54- public void testMapsIdJoinColumnForeignKeyNoConstraint () {
55- for ( Namespace namespace : metadata ().getDatabase ().getNamespaces () ) {
54+ public void testMapsIdJoinColumnForeignKeyNoConstraint (SessionFactoryScope scope ) {
55+ for ( Namespace namespace : scope . getMetadataImplementor ().getDatabase ().getNamespaces () ) {
5656 for ( Table table : namespace .getTables () ) {
5757 if ( "Post" .equals ( table .getName () ) ) {
58- assertEquals ( 0 , table .getForeignKeyCollection (). size () );
58+ assertThat ( table .getForeignKeyCollection () ). hasSize ( 0 );
5959 }
6060 }
6161 }
@@ -68,7 +68,7 @@ public static class Car {
6868
6969 @ PrimaryKeyJoinColumn
7070 @ OneToOne (optional = false )
71- @ JoinColumn (name = "V_ID" , foreignKey = @ ForeignKey ( ConstraintMode .NO_CONSTRAINT ) )
71+ @ JoinColumn (name = "V_ID" , foreignKey = @ ForeignKey (ConstraintMode .NO_CONSTRAINT ) )
7272 private VehicleNumber vehicleNumber ;
7373
7474 public Integer getId () {
0 commit comments