From b25dc774ead3384ce32bcdf5e27478b2b1f32ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Cedomir=20Igaly?= Date: Sun, 18 Aug 2024 11:19:54 +0200 Subject: [PATCH] HHH-18500 Added slightly modifed existing test case with addition of module-info.java and set extend enhancement flag --- .../gradle/ModuleInfoProjectTests.java | 53 +++++++++++ .../projects/simple-moduleinfo/build.gradle | 40 +++++++++ .../simple-moduleinfo/settings.gradle | 0 .../src/main/java/TheEmbeddable.java | 29 ++++++ .../src/main/java/TheEntity.java | 88 +++++++++++++++++++ .../src/main/java/module-info.java | 5 ++ 6 files changed, 215 insertions(+) create mode 100644 tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/ModuleInfoProjectTests.java create mode 100644 tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/build.gradle create mode 100644 tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/settings.gradle create mode 100644 tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEmbeddable.java create mode 100644 tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEntity.java create mode 100644 tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/module-info.java diff --git a/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/ModuleInfoProjectTests.java b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/ModuleInfoProjectTests.java new file mode 100644 index 0000000000..a926488862 --- /dev/null +++ b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/ModuleInfoProjectTests.java @@ -0,0 +1,53 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html. + */ +package org.hibernate.orm.tooling.gradle; + +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + + +/** + * Basic functional tests + * + * @author Steve Ebersole + */ +class ModuleInfoProjectTests extends TestsBase { + + @Override + protected String getProjectName() { + return "simple-moduleinfo"; + } + + @Override + protected String getSourceSetName() { + return "main"; + } + + @Override + protected String getLanguageName() { + return "java"; + } + + @Override + protected String getCompileTaskName() { + return "compileJava"; + } + + @Test + @Override + public void testEnhancement(@TempDir Path projectDir) throws Exception { + super.testEnhancement( projectDir ); + } + + @Test + @Override + public void testEnhancementUpToDate(@TempDir Path projectDir) throws Exception { + super.testEnhancementUpToDate( projectDir ); + } +} diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/build.gradle b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/build.gradle new file mode 100644 index 0000000000..33a514518a --- /dev/null +++ b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/build.gradle @@ -0,0 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ + +plugins { + id 'java' + id 'org.hibernate.orm' +} + +repositories { + mavenCentral() + + maven { + name 'jboss-snapshots-repository' + url 'https://repository.jboss.org/nexus/content/repositories/snapshots' + } +} + +dependencies { + // NOTE : The version used here is irrelevant in terms of testing the plugin. + // We just need a resolvable version + implementation 'org.hibernate.orm:hibernate-core:6.1.0.Final' + implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1' +} + +hibernate { + useSameVersion = false + enhancement { + enableLazyInitialization.set(true) + lazyInitialization = true + + enableDirtyTracking.set(true) + dirtyTracking = true + + enableExtendedEnhancement.set(true) + } +} diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/settings.gradle b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/settings.gradle new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEmbeddable.java b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEmbeddable.java new file mode 100644 index 0000000000..25b8849aac --- /dev/null +++ b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEmbeddable.java @@ -0,0 +1,29 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html. + */ +import jakarta.persistence.Embeddable; + +@Embeddable +public class TheEmbeddable { + private String valueOne; + private String valueTwo; + + public String getValueOne() { + return valueOne; + } + + public void setValueOne(String valueOne) { + this.valueOne = valueOne; + } + + public String getValueTwo() { + return valueTwo; + } + + public void setValueTwo(String valueTwo) { + this.valueTwo = valueTwo; + } +} diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEntity.java b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEntity.java new file mode 100644 index 0000000000..b5d9eb5eea --- /dev/null +++ b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/TheEntity.java @@ -0,0 +1,88 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html. + */ +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; + +import org.hibernate.annotations.BatchSize; + +import java.util.Set; + +@Entity +@BatchSize( size = 20 ) +public class TheEntity { + @Id + private Integer id; + private String name; + + @Embedded + private TheEmbeddable theEmbeddable; + + @ManyToOne + @JoinColumn + private TheEntity theManyToOne; + + @OneToMany( mappedBy = "theManyToOne" ) + private Set theOneToMany; + + @ElementCollection + @JoinColumn( name = "owner_id" ) + private Set theEmbeddableCollection; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public TheEmbeddable getTheEmbeddable() { + return theEmbeddable; + } + + public void setTheEmbeddable(TheEmbeddable theEmbeddable) { + this.theEmbeddable = theEmbeddable; + } + + public TheEntity getTheManyToOne() { + return theManyToOne; + } + + public void setTheManyToOne(TheEntity theManyToOne) { + this.theManyToOne = theManyToOne; + } + + public Set getTheOneToMany() { + return theOneToMany; + } + + public void setTheOneToMany(Set theOneToMany) { + this.theOneToMany = theOneToMany; + } + + public Set getTheEmbeddableCollection() { + return theEmbeddableCollection; + } + + public void setTheEmbeddableCollection(Set theEmbeddableCollection) { + this.theEmbeddableCollection = theEmbeddableCollection; + } +} diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/module-info.java b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/module-info.java new file mode 100644 index 0000000000..ea488cd33f --- /dev/null +++ b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-moduleinfo/src/main/java/module-info.java @@ -0,0 +1,5 @@ +module test { + requires org.hibernate.orm.core; + requires jakarta.persistence; + requires jakarta.annotation; +}