FailureExpectedWithNewMetamodel cleanup

This commit is contained in:
Steve Ebersole 2014-04-03 20:56:46 -05:00
parent d8e4f9e8f8
commit 2a0b9825f1
5 changed files with 41 additions and 16 deletions

View File

@ -495,6 +495,14 @@ public final class StringHelper {
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) {
for ( int i = startindex, size = sqlString.length(); i < size; i++ ) {
if ( keys.get( sqlString.charAt( i ) ) ) {

View File

@ -232,13 +232,12 @@ public class IndexBuilder {
Class clazz = null;
try {
clazz = serviceRegistry.getService( ClassLoaderService.class ).classForName( className );
clazz = classLoaderService.classForName( className );
}
catch ( ClassLoadingException e ) {
if ( StringHelper.isNotEmpty( optionalPerfix ) ) {
className = StringHelper.qualify( optionalPerfix, className );
clazz = serviceRegistry.getService( ClassLoaderService.class )
.classForName( className );
clazz = classLoaderService.classForName( className );
}
}
DotName classDotName = DotName.createSimple( className );

View File

@ -26,6 +26,7 @@ package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
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.PersistentAttribute;
@ -52,7 +53,10 @@ public class OneToOneMocker extends PropertyMocker {
protected void processExtra() {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
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.booleanValue( "optional", oneToOne.isOptional(), annotationValueList );

View File

@ -64,11 +64,21 @@ public abstract class PropertyMocker extends AnnotationMocker {
}
protected void resolveTarget() {
//attribute in orm.xml has access sub-element
AccessType accessType = getPersistentAttribute().getAccess();
if ( accessType == null ) {
AccessType xmlDefinedAccessType = getPersistentAttribute().getAccess();
if ( xmlDefinedAccessType == 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
accessType = AccessHelper.getAccessFromAttributeAnnotation( getTargetName(), getPersistentAttribute().getName(), indexBuilder );
AccessType accessType = AccessHelper.getAccessFromAttributeAnnotation(
getTargetName(),
getPersistentAttribute().getName(),
indexBuilder
);
if ( accessType == null ) {
accessType = AccessHelper.getEntityAccess( getTargetName(), indexBuilder );
}
@ -85,7 +95,12 @@ public abstract class PropertyMocker extends AnnotationMocker {
}
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

View File

@ -47,7 +47,6 @@ import org.junit.Test;
*/
public class XmlAccessTest extends BaseUnitTestCase {
@Test
@FailureExpectedWithNewMetamodel
public void testAccessOnBasicXmlElement() throws Exception {
Class<?> classUnderTest = Tourist.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
@ -68,7 +67,12 @@ public class XmlAccessTest extends BaseUnitTestCase {
}
@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 {
Class<?> classUnderTest = Tourist.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
@ -88,7 +92,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testAccessOnEntityMappingsXmlElement() throws Exception {
Class<?> classUnderTest = Tourist.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
@ -108,7 +111,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testAccessOnEntityXmlElement() throws Exception {
Class<?> classUnderTest = Tourist.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
@ -141,7 +143,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testAccessOnAssociationXmlElement() throws Exception {
Class<?> classUnderTest = RentalCar.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
@ -155,7 +156,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testAccessOnEmbeddedXmlElement() throws Exception {
Class<?> classUnderTest = Cook.class;
List<Class<?>> classes = new ArrayList<Class<?>>();
@ -169,7 +169,6 @@ public class XmlAccessTest extends BaseUnitTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testAccessOnElementCollectionXmlElement() throws Exception {
Class<?> classUnderTest = Boy.class;
List<Class<?>> classes = new ArrayList<Class<?>>();