Skip to content

Update processor tests to use JUnit 5 #10379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tooling/metamodel-generator/hibernate-processor.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ configurations {
def quarkusOrmPanacheTestTask = tasks.register( 'quarkusOrmPanacheTest', Test ) {
description = 'Runs the Quarkus ORM Panache tests.'
group = 'verification'
useJUnitPlatform()

testClassesDirs = sourceSets.quarkusOrmPanache.output.classesDirs
classpath = sourceSets.quarkusOrmPanache.runtimeClasspath
Expand All @@ -89,6 +90,7 @@ def quarkusOrmPanacheTestTask = tasks.register( 'quarkusOrmPanacheTest', Test )
def quarkusHrPanacheTestTask = tasks.register( 'quarkusHrPanacheTest', Test ) {
description = 'Runs the Quarkus HR Panache tests.'
group = 'verification'
useJUnitPlatform()

testClassesDirs = sourceSets.quarkusHrPanache.output.classesDirs
classpath = sourceSets.quarkusHrPanache.runtimeClasspath
Expand All @@ -98,6 +100,7 @@ def quarkusHrPanacheTestTask = tasks.register( 'quarkusHrPanacheTest', Test ) {
def jakartaDataTestTask = tasks.register( 'jakartaDataTest', Test ) {
description = 'Runs the Jakarta Data tests.'
group = 'verification'
useJUnitPlatform()

testClassesDirs = sourceSets.jakartaData.output.classesDirs
classpath = sourceSets.jakartaData.runtimeClasspath
Expand Down Expand Up @@ -160,4 +163,4 @@ tasks.forbiddenApisQuarkusOrmPanache {

tasks.forbiddenApisQuarkusHrPanache {
enabled = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertNoMetamodelClassGeneratedFor;
Expand All @@ -15,10 +15,11 @@
/**
* @author Gavin King
*/
public class DataTest extends CompilationTest {
@CompilationTest
class DataTest {
@Test
@WithClasses({ Author.class, Book.class, BookAuthorRepository.class, IdOperations.class, Concrete.class, Thing.class })
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( Author.class ) );
System.out.println( getMetaModelSourceAsString( Book.class ) );
System.out.println( getMetaModelSourceAsString( Author.class, true ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

/**
* @author Gavin King
*/
public class EgTest extends CompilationTest {
@CompilationTest
class EgTest {
@Test
@WithClasses({ Publisher.class, Author.class, Address.class, Book.class, Library.class, Bookshop.class, Publishers.class })
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( Author.class ) );
System.out.println( getMetaModelSourceAsString( Book.class ) );
System.out.println( getMetaModelSourceAsString( Author.class, true ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

/**
* @author Gavin King
*/
public class EmbeddedIdTest extends CompilationTest {
@CompilationTest
class EmbeddedIdTest {
@Test
@WithClasses({ Thing.class, ThingRepo.class })
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( ThingRepo.class ) );
assertMetamodelClassGeneratedFor( Thing.class, true );
assertMetamodelClassGeneratedFor( Thing.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
import jakarta.persistence.EntityManager;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfMethodInMetamodelFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

public class FqcnInQueryTest extends CompilationTest {
@CompilationTest
class FqcnInQueryTest {
@Test
@WithClasses({MyEntity.class, MyRepository.class})
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( MyRepository.class ) );
System.out.println( getMetaModelSourceAsString( MyEntity.class ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
import org.hibernate.processor.test.data.idclass.MyEntity.MyEntityId;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfMethodInMetamodelFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

public class CompositeIdClassTest extends CompilationTest {
@CompilationTest
class CompositeIdClassTest {
@Test
@WithClasses({
MyRepository.class,
YourRepository.class,
MyEntity.class,
})
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( MyEntity.class ) );
System.out.println( getMetaModelSourceAsString( MyEntity.class, true ) );
System.out.println( getMetaModelSourceAsString( MyRepository.class ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
import org.hibernate.processor.test.data.innerclass.InnerClassTest.One.Two;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertNoMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InnerClassTest extends CompilationTest {
@CompilationTest
class InnerClassTest {

@WithClasses({Person.class, Dummy.class, Inner.class, Two.class})
@Test
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( InnerClassTest.class ) );
System.out.println( getMetaModelSourceAsString( Dummy.class ) );
System.out.println( getMetaModelSourceAsString( Person.class ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
import jakarta.persistence.Id;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

public class InnerRepositoryTest extends CompilationTest {
@CompilationTest
class InnerRepositoryTest {

@Test
@WithClasses({Thing.class, ThingRepo.class})
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( ThingRepo.class ) );
assertMetamodelClassGeneratedFor( ThingRepo.class );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import jakarta.persistence.EntityManager;
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
Expand All @@ -21,10 +21,11 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

public class TopicPostTest extends CompilationTest {
@CompilationTest
class TopicPostTest {
@Test
@WithClasses({Post.class, PostRepository.class})
public void test() {
void test() {
assertMetamodelClassGeneratedFor( Post.class, true );
assertMetamodelClassGeneratedFor( Post.class );
assertMetamodelClassGeneratedFor( PostRepository.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.assertNoMetamodelClassGeneratedFor;
Expand All @@ -15,10 +15,11 @@
/**
* @author Gavin King
*/
public class NamedQueryTest extends CompilationTest {
@CompilationTest
class NamedQueryTest {
@Test
@WithClasses({ Author.class, Book.class, BookAuthorRepository.class, BookAuthorRepository$.class })
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( Author.class ) );
System.out.println( getMetaModelSourceAsString( Book.class ) );
System.out.println( getMetaModelSourceAsString( Author.class, true ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
Expand All @@ -18,10 +18,11 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

public class ProcessingOrderTest extends CompilationTest {
@CompilationTest
class ProcessingOrderTest {
@Test
@WithClasses({Post.class, PostRepository.class, Topic.class})
public void test() {
void test() {
assertMetamodelClassGeneratedFor( PostRepository.class );

assertPresenceOfMethodInMetamodelFor( PostRepository.class, "getPostsByTopic", Topic.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.TestUtil;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

import jakarta.inject.Inject;
Expand All @@ -22,11 +22,12 @@
/**
* @author Gavin King
*/
public class QuarkusOrmPanacheTest extends CompilationTest {
@CompilationTest
class QuarkusOrmPanacheTest {

@Test
@WithClasses({ PanacheBook.class, JakartaDataBookRepository.class })
public void testJakartaDataRepositoryMetamodel() throws Exception {
void testJakartaDataRepositoryMetamodel() throws Exception {
// JD repository
System.out.println( TestUtil.getMetaModelSourceAsString( JakartaDataBookRepository.class ) );
Class<?> repositoryClass = getMetamodelClassFor( JakartaDataBookRepository.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

/**
* @author Gavin King
*/
public class ReactiveTest extends CompilationTest {
@CompilationTest
class ReactiveTest {
@Test
@WithClasses({ Publisher.class, Author.class, Address.class, Book.class, Library.class, Library2.class, RepoWithPrimary.class })
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( Author.class ) );
System.out.println( getMetaModelSourceAsString( Book.class ) );
System.out.println( getMetaModelSourceAsString( Author.class, true ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

public class TopicTypeEnumTest extends CompilationTest {
@CompilationTest
class TopicTypeEnumTest {
@Test
@WithClasses({Topic.class, TopicRepository.class})
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( Topic.class ) );
System.out.println( getMetaModelSourceAsString( Topic.class, true ) );
System.out.println( getMetaModelSourceAsString( TopicRepository.class ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.TestUtil;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;

/**
* @author Gavin King
*/
public class SuperRepoTest extends CompilationTest {
@CompilationTest
class SuperRepoTest {
@Test
@WithClasses({ Book.class, SuperRepo.class, Repo.class })
public void testQueryMethod() {
void testQueryMethod() {
System.out.println( TestUtil.getMetaModelSourceAsString( SuperRepo.class ) );
System.out.println( TestUtil.getMetaModelSourceAsString( Repo.class ) );
assertMetamodelClassGeneratedFor( Book.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.TestUtil;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;

/**
* @author Gavin King
*/
public class SuperRepoTest extends CompilationTest {
@CompilationTest
class SuperRepoTest {
@Test
@WithClasses({ Book.class, SuperRepo.class, Repo.class })
public void testQueryMethod() {
void testQueryMethod() {
// System.out.println( TestUtil.getMetaModelSourceAsString( SuperRepo.class ) );
System.out.println( TestUtil.getMetaModelSourceAsString( Repo.class ) );
assertMetamodelClassGeneratedFor( Book.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

import org.hibernate.processor.test.util.CompilationTest;
import org.hibernate.processor.test.util.WithClasses;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
import static org.hibernate.processor.test.util.TestUtil.getMetaModelSourceAsString;

/**
* @author Gavin King
*/
public class VersionedTest extends CompilationTest {
@CompilationTest
class VersionedTest {
@Test
@WithClasses({ Versioned.class, VersionedRepo.class, SpecialVersioned.class, SpecialVersionedRepo.class })
public void test() {
void test() {
System.out.println( getMetaModelSourceAsString( VersionedRepo.class ) );
assertMetamodelClassGeneratedFor( Versioned.class, true );
assertMetamodelClassGeneratedFor( Versioned.class );
Expand Down
Loading