HHH-18693 Test case with inner classes
Test case for Jakarta Data processing with inner classes Changed existing test class to properly check generated metamodel class @Exclude-ing "troublemakers" with illegal URI character(s) in entity name
This commit is contained in:
parent
5cc79fbd38
commit
dcdeb04a13
|
@ -14,6 +14,7 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.processing.Exclude;
|
||||
import org.hibernate.testing.orm.junit.JiraKey;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
|
@ -34,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
}
|
||||
)
|
||||
@SessionFactory
|
||||
@Exclude
|
||||
public class PersistentBagContainsTest {
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,7 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.annotations.processing.Exclude;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostInsertEvent;
|
||||
|
@ -31,6 +32,7 @@ import static org.junit.Assert.assertEquals;
|
|||
* @author Gail Badner
|
||||
*/
|
||||
@JiraKey( value = "HHH-9979")
|
||||
@Exclude
|
||||
public class MergeListPreAndPostPersistTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.hibernate.orm.test.hql;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.processing.Exclude;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -24,6 +25,7 @@ import static org.junit.Assert.assertEquals;
|
|||
/**
|
||||
* @author Christian Beikov
|
||||
*/
|
||||
@Exclude
|
||||
public class QuotedIdentifierTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
private Person person;
|
||||
|
|
|
@ -14,6 +14,7 @@ import jakarta.persistence.Column;
|
|||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
import org.hibernate.annotations.processing.Exclude;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
|
@ -36,6 +37,7 @@ import static org.hamcrest.core.Is.is;
|
|||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@JiraKey(value = "HHH-13788")
|
||||
@Exclude
|
||||
public class SchemaUpdateWithUseJdbcMetadataDefaultsSettingToFalseAndQuotedNameTest {
|
||||
|
||||
private File updateOutputFile;
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.innerclass;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
|
||||
public class Dummy {
|
||||
@Entity(name = "Inner")
|
||||
@NamedQuery(name = "allInner", query = "from Inner")
|
||||
public static class Inner extends Persona {
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
public static class DummyEmbeddable {
|
||||
private String name;
|
||||
private int value;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract static class Persona {
|
||||
private String city;
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public abstract void setId(Integer id);
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract void setName(String name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.innerclass;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
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 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;
|
||||
|
||||
public class InnerClassTest extends CompilationTest {
|
||||
|
||||
@WithClasses({Person.class, Dummy.class, Inner.class, Two.class})
|
||||
@Test
|
||||
public void test() {
|
||||
System.out.println( getMetaModelSourceAsString( InnerClassTest.class ) );
|
||||
System.out.println( getMetaModelSourceAsString( Dummy.class ) );
|
||||
System.out.println( getMetaModelSourceAsString( Person.class ) );
|
||||
System.out.println( getMetaModelSourceAsString( InnerClassTest.class, true ) );
|
||||
System.out.println( getMetaModelSourceAsString( Dummy.class, true ) );
|
||||
System.out.println( getMetaModelSourceAsString( Person.class, true ) );
|
||||
assertEquals(
|
||||
getMetaModelSourceAsString( Inner.class ),
|
||||
getMetaModelSourceAsString( Two.class )
|
||||
);
|
||||
assertEquals(
|
||||
getMetaModelSourceAsString( Inner.class, true ),
|
||||
getMetaModelSourceAsString( Two.class, true )
|
||||
);
|
||||
assertMetamodelClassGeneratedFor( Inner.class );
|
||||
assertMetamodelClassGeneratedFor( Inner.class, true );
|
||||
assertMetamodelClassGeneratedFor( Two.class );
|
||||
assertMetamodelClassGeneratedFor( Two.class, true );
|
||||
assertMetamodelClassGeneratedFor( Dummy.Inner.class );
|
||||
assertMetamodelClassGeneratedFor( Dummy.Inner.class, true );
|
||||
assertMetamodelClassGeneratedFor( Person.class );
|
||||
assertMetamodelClassGeneratedFor( Person.class, true );
|
||||
assertMetamodelClassGeneratedFor( Person.PersonId.class );
|
||||
assertNoMetamodelClassGeneratedFor( Dummy.class );
|
||||
assertMetamodelClassGeneratedFor( Dummy.DummyEmbeddable.class );
|
||||
/*assertNoMetamodelClassGeneratedFor( Dummy.class );*/
|
||||
}
|
||||
|
||||
@Entity(name = "Inner")
|
||||
@NamedQuery(name = "allInner", query = "from Inner")
|
||||
public static class Inner {
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String address;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
|
||||
static class One {
|
||||
@Entity
|
||||
static class Two {
|
||||
@Id
|
||||
Integer id;
|
||||
String value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.data.innerclass;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
@Entity
|
||||
public class Person {
|
||||
@EmbeddedId
|
||||
private PersonId id;
|
||||
|
||||
private String address;
|
||||
|
||||
@Embeddable
|
||||
public static class PersonId {
|
||||
private String name;
|
||||
private String snn;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSnn() {
|
||||
return snn;
|
||||
}
|
||||
|
||||
public void setSnn(String snn) {
|
||||
this.snn = snn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.innerclass;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
|
||||
public class Dummy {
|
||||
@Entity(name = "Inner")
|
||||
@NamedQuery(name = "allInner", query = "from Inner")
|
||||
public static class Inner extends Persona {
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
public static class DummyEmbeddable {
|
||||
private String name;
|
||||
private int value;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract static class Persona {
|
||||
private String city;
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public abstract void setId(Integer id);
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract void setName(String name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.innerclass;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
import org.hibernate.processor.test.innerclass.InnerClassTest.One.Two;
|
||||
import org.hibernate.processor.test.util.CompilationTest;
|
||||
import org.hibernate.processor.test.util.WithClasses;
|
||||
import org.junit.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;
|
||||
|
||||
public class InnerClassTest extends CompilationTest {
|
||||
|
||||
@WithClasses({Person.class, Dummy.class, Inner.class, Two.class})
|
||||
@Test
|
||||
public void test() {
|
||||
System.out.println( getMetaModelSourceAsString( InnerClassTest.class ) );
|
||||
System.out.println( getMetaModelSourceAsString( Dummy.class ) );
|
||||
System.out.println( getMetaModelSourceAsString( Person.class ) );
|
||||
assertEquals(
|
||||
getMetaModelSourceAsString( Inner.class ),
|
||||
getMetaModelSourceAsString( Two.class )
|
||||
);
|
||||
assertMetamodelClassGeneratedFor( Inner.class );
|
||||
assertMetamodelClassGeneratedFor( Two.class );
|
||||
assertMetamodelClassGeneratedFor( Dummy.Inner.class );
|
||||
assertMetamodelClassGeneratedFor( Person.class );
|
||||
assertMetamodelClassGeneratedFor( Person.PersonId.class );
|
||||
assertNoMetamodelClassGeneratedFor( Dummy.class );
|
||||
assertMetamodelClassGeneratedFor( Dummy.DummyEmbeddable.class );
|
||||
System.out.println( getMetaModelSourceAsString( Dummy.DummyEmbeddable.class ) );
|
||||
}
|
||||
|
||||
@Entity(name = "Inner")
|
||||
@NamedQuery(name = "allInner", query = "from Inner")
|
||||
public static class Inner {
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String address;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
|
||||
static class One {
|
||||
@Entity
|
||||
static class Two {
|
||||
@Id
|
||||
Integer id;
|
||||
String value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
* Copyright Red Hat Inc. and Hibernate Authors
|
||||
*/
|
||||
package org.hibernate.processor.test.innerclass;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
@Entity
|
||||
public class Person {
|
||||
@EmbeddedId
|
||||
private PersonId id;
|
||||
|
||||
private String address;
|
||||
|
||||
@Embeddable
|
||||
public static class PersonId {
|
||||
private String name;
|
||||
private String snn;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSnn() {
|
||||
return snn;
|
||||
}
|
||||
|
||||
public void setSnn(String snn) {
|
||||
this.snn = snn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -28,7 +28,12 @@ public class SeparateCompilationUnitsTest extends CompilationTest {
|
|||
String entityMetaModel = getMetaModelSourceAsString( Entity.class );
|
||||
assertTrue(
|
||||
entityMetaModel.contains(
|
||||
"extends org.hibernate.processor.test.separatecompilationunits.superclass.MappedSuperclass"
|
||||
"import org.hibernate.processor.test.separatecompilationunits.superclass.MappedSuperclass_;"
|
||||
)
|
||||
);
|
||||
assertTrue(
|
||||
entityMetaModel.contains(
|
||||
"extends MappedSuperclass_"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue