FailureExpectedWithNewMetamodel cleanup
This commit is contained in:
parent
d8e4f9e8f8
commit
2a0b9825f1
|
@ -495,6 +495,14 @@ public final class StringHelper {
|
||||||
return qualified;
|
return qualified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String qualifyIfNot(String qualifier, String name) {
|
||||||
|
if ( name.indexOf( '.' ) > 0 ) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qualify( qualifier, name );
|
||||||
|
}
|
||||||
|
|
||||||
public static int firstIndexOfChar(String sqlString, BitSet keys, int startindex) {
|
public static int firstIndexOfChar(String sqlString, BitSet keys, int startindex) {
|
||||||
for ( int i = startindex, size = sqlString.length(); i < size; i++ ) {
|
for ( int i = startindex, size = sqlString.length(); i < size; i++ ) {
|
||||||
if ( keys.get( sqlString.charAt( i ) ) ) {
|
if ( keys.get( sqlString.charAt( i ) ) ) {
|
||||||
|
|
|
@ -232,13 +232,12 @@ public class IndexBuilder {
|
||||||
|
|
||||||
Class clazz = null;
|
Class clazz = null;
|
||||||
try {
|
try {
|
||||||
clazz = serviceRegistry.getService( ClassLoaderService.class ).classForName( className );
|
clazz = classLoaderService.classForName( className );
|
||||||
}
|
}
|
||||||
catch ( ClassLoadingException e ) {
|
catch ( ClassLoadingException e ) {
|
||||||
if ( StringHelper.isNotEmpty( optionalPerfix ) ) {
|
if ( StringHelper.isNotEmpty( optionalPerfix ) ) {
|
||||||
className = StringHelper.qualify( optionalPerfix, className );
|
className = StringHelper.qualify( optionalPerfix, className );
|
||||||
clazz = serviceRegistry.getService( ClassLoaderService.class )
|
clazz = classLoaderService.classForName( className );
|
||||||
.classForName( className );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DotName classDotName = DotName.createSimple( className );
|
DotName classDotName = DotName.createSimple( className );
|
||||||
|
|
|
@ -26,6 +26,7 @@ package org.hibernate.metamodel.source.internal.jandex;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToOne;
|
import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToOne;
|
||||||
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
|
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
|
||||||
|
|
||||||
|
@ -52,7 +53,10 @@ public class OneToOneMocker extends PropertyMocker {
|
||||||
protected void processExtra() {
|
protected void processExtra() {
|
||||||
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
|
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
|
||||||
MockHelper.classValue(
|
MockHelper.classValue(
|
||||||
"targetEntity", oneToOne.getTargetEntity(), annotationValueList, indexBuilder.getServiceRegistry()
|
"targetEntity",
|
||||||
|
StringHelper.qualifyIfNot( getDefaults().getPackageName(), oneToOne.getTargetEntity() ),
|
||||||
|
annotationValueList,
|
||||||
|
indexBuilder.getServiceRegistry()
|
||||||
);
|
);
|
||||||
MockHelper.enumValue( "fetch", FETCH_TYPE, oneToOne.getFetch(), annotationValueList );
|
MockHelper.enumValue( "fetch", FETCH_TYPE, oneToOne.getFetch(), annotationValueList );
|
||||||
MockHelper.booleanValue( "optional", oneToOne.isOptional(), annotationValueList );
|
MockHelper.booleanValue( "optional", oneToOne.isOptional(), annotationValueList );
|
||||||
|
|
|
@ -64,11 +64,21 @@ public abstract class PropertyMocker extends AnnotationMocker {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resolveTarget() {
|
protected void resolveTarget() {
|
||||||
//attribute in orm.xml has access sub-element
|
AccessType xmlDefinedAccessType = getPersistentAttribute().getAccess();
|
||||||
AccessType accessType = getPersistentAttribute().getAccess();
|
if ( xmlDefinedAccessType == null ) {
|
||||||
if ( accessType == null ) {
|
// could be PU default
|
||||||
|
xmlDefinedAccessType = getDefaults().getAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( xmlDefinedAccessType == null ) {
|
||||||
|
// attribute in orm.xml did not define access
|
||||||
|
|
||||||
//attribute in the entity class has @Access
|
//attribute in the entity class has @Access
|
||||||
accessType = AccessHelper.getAccessFromAttributeAnnotation( getTargetName(), getPersistentAttribute().getName(), indexBuilder );
|
AccessType accessType = AccessHelper.getAccessFromAttributeAnnotation(
|
||||||
|
getTargetName(),
|
||||||
|
getPersistentAttribute().getName(),
|
||||||
|
indexBuilder
|
||||||
|
);
|
||||||
if ( accessType == null ) {
|
if ( accessType == null ) {
|
||||||
accessType = AccessHelper.getEntityAccess( getTargetName(), indexBuilder );
|
accessType = AccessHelper.getEntityAccess( getTargetName(), indexBuilder );
|
||||||
}
|
}
|
||||||
|
@ -85,7 +95,12 @@ public abstract class PropertyMocker extends AnnotationMocker {
|
||||||
}
|
}
|
||||||
getPersistentAttribute().setAccess( accessType );
|
getPersistentAttribute().setAccess( accessType );
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// attribute in orm.xml did define access
|
||||||
|
List<AnnotationValue> accessTypeValueList = new ArrayList<AnnotationValue>();
|
||||||
|
MockHelper.enumValue( "value", ACCESS_TYPE, xmlDefinedAccessType, accessTypeValueList );
|
||||||
|
create( ACCESS, accessTypeValueList );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,7 +47,6 @@ import org.junit.Test;
|
||||||
*/
|
*/
|
||||||
public class XmlAccessTest extends BaseUnitTestCase {
|
public class XmlAccessTest extends BaseUnitTestCase {
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testAccessOnBasicXmlElement() throws Exception {
|
public void testAccessOnBasicXmlElement() throws Exception {
|
||||||
Class<?> classUnderTest = Tourist.class;
|
Class<?> classUnderTest = Tourist.class;
|
||||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
|
@ -68,7 +67,12 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
@FailureExpectedWithNewMetamodel(
|
||||||
|
message = "The problem here is that XML is attempting to apply PU-wide default AccessType, " +
|
||||||
|
"but mocker only understands (and overrides) attributes that are explicitly listed in the " +
|
||||||
|
"XML. Likely we need to link the XML defaults with the local-binding-context defaults as we" +
|
||||||
|
"start to process Jandex"
|
||||||
|
)
|
||||||
public void testAccessOnPersistenceUnitDefaultsXmlElement() throws Exception {
|
public void testAccessOnPersistenceUnitDefaultsXmlElement() throws Exception {
|
||||||
Class<?> classUnderTest = Tourist.class;
|
Class<?> classUnderTest = Tourist.class;
|
||||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
|
@ -88,7 +92,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testAccessOnEntityMappingsXmlElement() throws Exception {
|
public void testAccessOnEntityMappingsXmlElement() throws Exception {
|
||||||
Class<?> classUnderTest = Tourist.class;
|
Class<?> classUnderTest = Tourist.class;
|
||||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
|
@ -108,7 +111,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testAccessOnEntityXmlElement() throws Exception {
|
public void testAccessOnEntityXmlElement() throws Exception {
|
||||||
Class<?> classUnderTest = Tourist.class;
|
Class<?> classUnderTest = Tourist.class;
|
||||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
|
@ -141,7 +143,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testAccessOnAssociationXmlElement() throws Exception {
|
public void testAccessOnAssociationXmlElement() throws Exception {
|
||||||
Class<?> classUnderTest = RentalCar.class;
|
Class<?> classUnderTest = RentalCar.class;
|
||||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
|
@ -155,7 +156,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testAccessOnEmbeddedXmlElement() throws Exception {
|
public void testAccessOnEmbeddedXmlElement() throws Exception {
|
||||||
Class<?> classUnderTest = Cook.class;
|
Class<?> classUnderTest = Cook.class;
|
||||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
|
@ -169,7 +169,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testAccessOnElementCollectionXmlElement() throws Exception {
|
public void testAccessOnElementCollectionXmlElement() throws Exception {
|
||||||
Class<?> classUnderTest = Boy.class;
|
Class<?> classUnderTest = Boy.class;
|
||||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||||
|
|
Loading…
Reference in New Issue