use of jakarta.persistence.metamodel.ListAttribute in project hibernate-orm by hibernate.
the class AbstractManagedType method getDeclaredList.
@Override
@SuppressWarnings("unchecked")
public <E> ListAttribute<J, E> getDeclaredList(String name, Class<E> elementType) {
final PluralAttribute attribute = findDeclaredPluralAttribute(name);
checkListElementType(attribute, name, elementType);
return (ListAttribute<J, E>) attribute;
}
use of jakarta.persistence.metamodel.ListAttribute in project eclipselink by eclipse-ee4j.
the class MetamodelMetamodelTest method testManagedType_getDeclaredListAttribute_Method.
public void testManagedType_getDeclaredListAttribute_Method() {
EntityManager em = null;
boolean expectedIAExceptionThrown = false;
try {
em = privateTestSetup();
assertNotNull(em);
Metamodel metamodel = em.getMetamodel();
assertNotNull("The metamodel should never be null after an em.getMetamodel() call here.", metamodel);
EntityTypeImpl<Manufacturer> entityManufacturer_ = (EntityTypeImpl) metamodel.entity(Manufacturer.class);
assertNotNull(entityManufacturer_);
EntityTypeImpl<HardwareDesigner> entityHardwareDesigner_ = (EntityTypeImpl) metamodel.entity(HardwareDesigner.class);
assertNotNull(entityHardwareDesigner_);
// Test case
Attribute anAttribute = entityManufacturer_.getDeclaredAttribute("hardwareDesigners");
assertNotNull(anAttribute);
assertEquals(PersistentAttributeType.ONE_TO_MANY, anAttribute.getPersistentAttributeType());
assertTrue(((AttributeImpl) anAttribute).isPlural());
assertTrue(anAttribute instanceof ListAttribute);
assertEquals(entityHardwareDesigner_, ((ListAttribute) anAttribute).getElementType());
assertEquals(CollectionType.LIST, ((ListAttribute) anAttribute).getCollectionType());
assertTrue(((AttributeImpl) anAttribute).isPlural());
assertTrue(anAttribute instanceof PluralAttribute);
Bindable aPluralAttribute = entityManufacturer_.getDeclaredList("hardwareDesigners");
assertEquals(HardwareDesigner.class, aPluralAttribute.getBindableJavaType());
assertEquals(List.class, anAttribute.getJavaType());
assertEquals(PersistentAttributeType.ONE_TO_MANY, anAttribute.getPersistentAttributeType());
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
} finally {
cleanup(em);
assertFalse("An IAE exception should not occur here.", expectedIAExceptionThrown);
}
}
use of jakarta.persistence.metamodel.ListAttribute in project eclipselink by eclipse-ee4j.
the class MetamodelMetamodelTest method testManagedType_getAttributes_Method.
public void testManagedType_getAttributes_Method() {
EntityManager em = null;
boolean expectedIAExceptionThrown = false;
try {
em = privateTestSetup();
assertNotNull(em);
Metamodel metamodel = em.getMetamodel();
assertNotNull("The metamodel should never be null after an em.getMetamodel() call here.", metamodel);
EntityTypeImpl<Manufacturer> entityManufacturer_ = (EntityTypeImpl) metamodel.entity(Manufacturer.class);
assertNotNull(entityManufacturer_);
MappedSuperclassTypeImpl<Person> msPerson_ = (MappedSuperclassTypeImpl) metamodel.managedType(Person.class);
assertNotNull(msPerson_);
MappedSuperclassTypeImpl<Corporation> msCorporation_ = (MappedSuperclassTypeImpl) metamodel.managedType(Corporation.class);
assertNotNull(msCorporation_);
EntityTypeImpl<GalacticPosition> entityLocation_ = (EntityTypeImpl) metamodel.entity(GalacticPosition.class);
assertNotNull(entityLocation_);
EntityTypeImpl<Computer> entityComputer_ = (EntityTypeImpl) metamodel.entity(Computer.class);
assertNotNull(entityComputer_);
EntityTypeImpl<HardwareDesigner> entityHardwareDesigner_ = (EntityTypeImpl) metamodel.entity(HardwareDesigner.class);
assertNotNull(entityHardwareDesigner_);
// Actual Test Case
/**
* The following variant test cases are common to all functions
* 1) get*Attribute(name) = null (missing) --> IAE
* 2) get*Attribute(name, type) = null (missing, type=irrelevant) --> IAE
* 3) get*Attribute(name, type) = exists but type != returned type --> IAE
*/
/**
* Return the attributes of the managed type.
*/
// java.util.Set<Attribute<? super X, ?>> getAttributes();
Set<Attribute<? super Manufacturer, ?>> attributeSet = entityManufacturer_.getAttributes();
assertNotNull(attributeSet);
// We should see 30 attributes (3 List, 3 Singular, 17 basic (java.lang, java.math) for Manufacturer (computers, hardwareDesigners, id(from the mappedSuperclass),
// version, name(from the mappedSuperclass) and corporateComputers from the Corporation mappedSuperclass)
assertEquals(METAMODEL_MANUFACTURER_DECLARED_TYPES + 6, attributeSet.size());
// for each managed entity we will see 2 entries (one for the Id, one for the Version)
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("id")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("version")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("name")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("computers")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("hardwareDesigners")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("corporateComputers")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMap")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC1a")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC2")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC4")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC7")));
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC8")));
// ManyToMany Collection Attribute from Person MappedSuperclass
//
assertTrue(attributeSet.contains(entityManufacturer_.getCollection("historicalEmps")));
//
assertTrue(entityManufacturer_.getCollection("historicalEmps").isCollection());
// Basic java.lang and java.math primitive and primitive object types
// private Object anObject; - invalid
// assertTrue(attributeSet.contains(entityManufacturer.getAttribute("anObject"))); //
// assertNotNull(entityManufacturer.getAttribute("anObject"));
// assertTrue(entityManufacturer.getAttribute("anObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
// assertEquals(Object.class, entityManufacturer.getAttribute("anObject").getJavaType());
// private Boolean aBooleanObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aBooleanObject")));
assertNotNull(entityManufacturer_.getAttribute("aBooleanObject"));
assertTrue(entityManufacturer_.getAttribute("aBooleanObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Boolean.class, entityManufacturer_.getAttribute("aBooleanObject").getJavaType());
// private Byte aByteObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aByteObject")));
assertNotNull(entityManufacturer_.getAttribute("aByteObject"));
assertTrue(entityManufacturer_.getAttribute("aByteObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Byte.class, entityManufacturer_.getAttribute("aByteObject").getJavaType());
// private Short aShortObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aShortObject")));
assertNotNull(entityManufacturer_.getAttribute("aShortObject"));
assertTrue(entityManufacturer_.getAttribute("aShortObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Short.class, entityManufacturer_.getAttribute("aShortObject").getJavaType());
// private Integer anIntegerObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("anIntegerObject")));
assertNotNull(entityManufacturer_.getAttribute("anIntegerObject"));
assertTrue(entityManufacturer_.getAttribute("anIntegerObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Integer.class, entityManufacturer_.getAttribute("anIntegerObject").getJavaType());
// private Long aLongObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aLongObject")));
assertNotNull(entityManufacturer_.getAttribute("aLongObject"));
assertTrue(entityManufacturer_.getAttribute("aLongObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Long.class, entityManufacturer_.getAttribute("aLongObject").getJavaType());
// private BigInteger aBigIntegerObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aBigIntegerObject")));
assertNotNull(entityManufacturer_.getAttribute("aBigIntegerObject"));
assertTrue(entityManufacturer_.getAttribute("aBigIntegerObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(BigInteger.class, entityManufacturer_.getAttribute("aBigIntegerObject").getJavaType());
// private Float aFloatObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aFloatObject")));
assertNotNull(entityManufacturer_.getAttribute("aFloatObject"));
assertTrue(entityManufacturer_.getAttribute("aFloatObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Float.class, entityManufacturer_.getAttribute("aFloatObject").getJavaType());
// private Double aDoubleObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aDoubleObject")));
assertNotNull(entityManufacturer_.getAttribute("aDoubleObject"));
assertTrue(entityManufacturer_.getAttribute("aDoubleObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Double.class, entityManufacturer_.getAttribute("aDoubleObject").getJavaType());
// private Character aCharacterObject;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aCharacterObject")));
assertNotNull(entityManufacturer_.getAttribute("aCharacterObject"));
assertTrue(entityManufacturer_.getAttribute("aCharacterObject").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(Character.class, entityManufacturer_.getAttribute("aCharacterObject").getJavaType());
// private Enum anEnum;
// FUTURE: the following 4 lines are not implemented yet
// assertTrue(attributeSet.contains(entityManufacturer.getAttribute("anEnum"))); //
// assertNotNull(entityManufacturer.getAttribute("anEnum"));
// assertTrue(entityManufacturer.getAttribute("anEnum").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
// assertEquals(Enum.class, entityManufacturer.getAttribute("anEnum").getJavaType());
// private boolean aBoolean;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aBoolean")));
assertNotNull(entityManufacturer_.getAttribute("aBoolean"));
assertTrue(entityManufacturer_.getAttribute("aBoolean").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(boolean.class, entityManufacturer_.getAttribute("aBoolean").getJavaType());
// private byte aByte;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aByte")));
assertNotNull(entityManufacturer_.getAttribute("aByte"));
assertTrue(entityManufacturer_.getAttribute("aByte").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(byte.class, entityManufacturer_.getAttribute("aByte").getJavaType());
// private short aShort;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aShort")));
assertNotNull(entityManufacturer_.getAttribute("aShort"));
assertTrue(entityManufacturer_.getAttribute("aShort").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(short.class, entityManufacturer_.getAttribute("aShort").getJavaType());
// private int anInt;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("anInt")));
assertNotNull(entityManufacturer_.getAttribute("anInt"));
assertTrue(entityManufacturer_.getAttribute("anInt").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(int.class, entityManufacturer_.getAttribute("anInt").getJavaType());
// private long aLong;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aLong")));
assertNotNull(entityManufacturer_.getAttribute("aLong"));
assertTrue(entityManufacturer_.getAttribute("aLong").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(long.class, entityManufacturer_.getAttribute("aLong").getJavaType());
// private float aFloat;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aFloat")));
assertNotNull(entityManufacturer_.getAttribute("aFloat"));
assertTrue(entityManufacturer_.getAttribute("aFloat").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(float.class, entityManufacturer_.getAttribute("aFloat").getJavaType());
// private double aDouble;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aDouble")));
assertNotNull(entityManufacturer_.getAttribute("aDouble"));
assertTrue(entityManufacturer_.getAttribute("aDouble").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(double.class, entityManufacturer_.getAttribute("aDouble").getJavaType());
// private char aChar;
//
assertTrue(attributeSet.contains(entityManufacturer_.getAttribute("aChar")));
assertNotNull(entityManufacturer_.getAttribute("aChar"));
assertTrue(entityManufacturer_.getAttribute("aChar").getPersistentAttributeType().equals(PersistentAttributeType.BASIC));
assertEquals(char.class, entityManufacturer_.getAttribute("aChar").getJavaType());
/**
* Return the attributes declared by the managed type.
* Testing for Design Issue 52:
* http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI:52_Refactor:_20090817
*/
// java.util.Set<Attribute<X, ?>> getDeclaredAttributes();
expectedIAExceptionThrown = false;
try {
/**
* Hierarchy:
* Person : MappedSuperclass
* +
* +- id : Integer
* +- name : String
* +- historicalEmps : Manufacturer
*
* Corporation : MappedSuperclass extends Person
* +
* +- corporateComputers : Collection
*
* Manufacturer : Entity extends Corporation
* +
* +- computers : Set
* +- hardwareDesigners : List
* +- hardwareDesignersMap : Map
* +- version : int
*/
Set<Attribute<Manufacturer, ?>> declaredAttributesSet = entityManufacturer_.getDeclaredAttributes();
assertNotNull(declaredAttributesSet);
// We should see 8+17 declared out of 12 attributes for Manufacturer
assertEquals(METAMODEL_MANUFACTURER_DECLARED_TYPES + 1, declaredAttributesSet.size());
// Id is declared 2 levels above
//
assertFalse(declaredAttributesSet.contains(entityManufacturer_.getAttribute("id")));
// name is declared 2 levels above
//
assertFalse(declaredAttributesSet.contains(entityManufacturer_.getAttribute("name")));
// corporateComputers is declared 1 level above
//
assertFalse(declaredAttributesSet.contains(entityManufacturer_.getAttribute("corporateComputers")));
// version is declared at this level
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("version")));
// computers is declared at this level
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("computers")));
// hardwareDesigners is declared at this level
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("hardwareDesigners")));
// hardwareDesignersMap is declared at this level
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMap")));
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC1a")));
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC2")));
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC4")));
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC7")));
//
assertTrue(declaredAttributesSet.contains(entityManufacturer_.getAttribute("hardwareDesignersMapUC8")));
// historicalEmps is declared 2 levels above
//
assertFalse(declaredAttributesSet.contains(entityManufacturer_.getAttribute("historicalEmps")));
Set<Attribute<Corporation, ?>> declaredAttributesSetForCorporation = msCorporation_.getDeclaredAttributes();
assertNotNull(declaredAttributesSetForCorporation);
// We should see 2 declared out of 5 attributes for Computer
assertEquals(2, declaredAttributesSetForCorporation.size());
// Id is declared 1 level above
// assertFalse(declaredAttributesSetForCorporation.contains(msCorporation.getAttribute("id"))); //
// name is declared 1 level above but is not visible in a ms-->ms hierarchy
// assertFalse(declaredAttributesSetForCorporation.contains(msCorporation.getAttribute("name"))); //
// corporateComputers is declared at this level
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
//
assertTrue(declaredAttributesSetForCorporation.contains(msCorporation_.getAttribute("corporateComputers")));
// historicalEmps is declared 1 level above but is not visible in a ms-->ms hierarchy
// assertFalse(declaredAttributesSetForCorporation.contains(msCorporation.getAttribute("historicalEmps"))); //
Set<Attribute<Person, ?>> declaredAttributesSetForPerson = msPerson_.getDeclaredAttributes();
assertNotNull(declaredAttributesSetForPerson);
// We should see 3 declared out of 20 attributes for Person
assertEquals(3, declaredAttributesSetForPerson.size());
// Id is declared at this level
//
assertTrue(declaredAttributesSetForPerson.contains(msPerson_.getAttribute("id")));
// name is declared at this level
//
assertTrue(declaredAttributesSetForPerson.contains(msPerson_.getAttribute("name")));
// historicalEmps is declared at this level
//
assertTrue(declaredAttributesSetForPerson.contains(msPerson_.getAttribute("historicalEmps")));
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
// Test Entity-->Entity hierarchy
/**
* Return the single-valued attribute of the managed
* type that corresponds to the specified name and Java type
* in the represented type.
* @param name the name of the represented attribute
* @param type the type of the represented attribute
* @return single-valued attribute with given name and type
* @throws IllegalArgumentException if attribute of the given
* name and type is not present in the managed type
*/
// <Y> SingularAttribute<? super X, Y> getSingularAttribute(String name, Class<Y> type);
// Test normal path
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, Double> aManufacturer_DoubleAttribute = null;
try {
aManufacturer_DoubleAttribute = entityManufacturer_.getSingularAttribute("aDoubleObject", Double.class);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
assertNotNull(aManufacturer_DoubleAttribute);
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, ?> aManufacturer_doubleAttribute = null;
// Test autoboxed rules relax throwing an IAE
try {
aManufacturer_doubleAttribute = entityManufacturer_.getSingularAttribute("aDoubleObject", double.class);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
assertNotNull(aManufacturer_doubleAttribute);
// Test IAE handling on wrong type
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, ?> aManufacturer_wrong_intAttribute = null;
// Test autoboxed rules relax throwing an IAE
try {
aManufacturer_wrong_intAttribute = entityManufacturer_.getSingularAttribute("aDoubleObject", int.class);
} catch (IllegalArgumentException iae) {
// expecting
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
assertNull(aManufacturer_wrong_intAttribute);
// Test IAE handling on wrong type
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, ?> aManufacturer_wrong_IntegerAttribute = null;
// Test autoboxed rules relax throwing an IAE
try {
aManufacturer_wrong_IntegerAttribute = entityManufacturer_.getSingularAttribute("aDoubleObject", Integer.class);
} catch (IllegalArgumentException iae) {
// expecting
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
assertNull(aManufacturer_wrong_IntegerAttribute);
/**
* Return the declared single-valued attribute of the
* managed type that corresponds to the specified name and Java
* type in the represented type.
* @param name the name of the represented attribute
* @param type the type of the represented attribute
* @return declared single-valued attribute of the given
* name and type
* @throws IllegalArgumentException if attribute of the given
* name and type is not declared in the managed type
*/
// <Y> SingularAttribute<X, Y> getDeclaredSingularAttribute(String name, Class<Y> type);
// Test normal path
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, Double> aDeclaredManufacturer_DoubleAttribute = null;
try {
aDeclaredManufacturer_DoubleAttribute = entityManufacturer_.getDeclaredSingularAttribute("aDoubleObject", Double.class);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
assertNotNull(aDeclaredManufacturer_DoubleAttribute);
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, ?> aDeclaredManufacturer_doubleAttribute = null;
// Test autoboxed rules relax throwing an IAE
try {
aDeclaredManufacturer_doubleAttribute = entityManufacturer_.getDeclaredSingularAttribute("aDoubleObject", double.class);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
assertNotNull(aDeclaredManufacturer_doubleAttribute);
// Test IAE handling on wrong type
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, ?> aDeclaredManufacturer_wrong_intAttribute = null;
// Test autoboxed rules relax throwing an IAE
try {
aDeclaredManufacturer_wrong_intAttribute = entityManufacturer_.getDeclaredSingularAttribute("aDoubleObject", int.class);
} catch (IllegalArgumentException iae) {
// expecting
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
assertNull(aDeclaredManufacturer_wrong_intAttribute);
// Test IAE handling on wrong type
expectedIAExceptionThrown = false;
SingularAttribute<? super Manufacturer, ?> aDeclaredManufacturer_wrong_IntegerAttribute = null;
// Test autoboxed rules relax throwing an IAE
try {
aDeclaredManufacturer_wrong_IntegerAttribute = entityManufacturer_.getDeclaredSingularAttribute("aDoubleObject", Integer.class);
} catch (IllegalArgumentException iae) {
// expecting
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
assertNull(aDeclaredManufacturer_wrong_IntegerAttribute);
// Test wrong hierarchy IAE failures
/**
* Return the single-valued attributes of the managed type.
* @return single-valued attributes
*/
// java.util.Set<SingularAttribute<? super X, ?>> getSingularAttributes();
Set<SingularAttribute<? super Manufacturer, ?>> singularAttributeSet = entityManufacturer_.getSingularAttributes();
assertNotNull(singularAttributeSet);
// We should see 4+18 singular attributes for Manufacturer (id(from the mappedSuperclass), version, name(from the mappedSuperclass))
assertEquals(METAMODEL_MANUFACTURER_DECLARED_TYPES - 6, singularAttributeSet.size());
// for each managed entity we will see 2 entries (one for the Id, one for the Version)
//
assertTrue(singularAttributeSet.contains(entityManufacturer_.getAttribute("id")));
//
assertTrue(singularAttributeSet.contains(entityManufacturer_.getAttribute("version")));
//
assertTrue(singularAttributeSet.contains(entityManufacturer_.getAttribute("name")));
/**
* Return the single-valued attributes declared by the managed
* type.
* @return declared single-valued attributes
*/
// java.util.Set<SingularAttribute<X, ?>> getDeclaredSingularAttributes();
/**
* Return the Collection-valued attribute of the managed type
* that corresponds to the specified name and Java element type.
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
* @return CollectionAttribute of the given name and element
* type
* @throws IllegalArgumentException if attribute of the given
* name and type is not present in the managed type
*/
// <E> CollectionAttribute<? super X, E> getCollection(String name, Class<E> elementType);
/**
* Return the Set-valued attribute of the managed type that
* corresponds to the specified name and Java element type.
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
* @return SetAttribute of the given name and element type
* @throws IllegalArgumentException if attribute of the given
* name and type is not present in the managed type
*/
// <E> SetAttribute<? super X, E> getSet(String name, Class<E> elementType);
/**
* Return the List-valued attribute of the managed type that
* corresponds to the specified name and Java element type.
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
* @return ListAttribute of the given name and element type
* @throws IllegalArgumentException if attribute of the given
* name and type is not present in the managed type
*/
// <E> ListAttribute<? super X, E> getList(String name, Class<E> elementType);
/**
* Return the Collection-valued attribute declared by the
* managed type that corresponds to the specified name and Java
* element type.
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
* @return declared CollectionAttribute of the given name and
* element type
* @throws IllegalArgumentException if attribute of the given
* name and type is not declared in the managed type
*/
// <E> CollectionAttribute<X, E> getDeclaredCollection(String name, Class<E> elementType);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC1 - the attribute does not exist on the managedType (regardless of whether it is on any superType)
CollectionAttribute<Manufacturer, GalacticPosition> anAttribute = entityManufacturer_.getDeclaredCollection("locations", entityLocation_.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The attribute [locations] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present.
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC2 - the attribute is on the managedType (but is the wrong type)
// Also avoid a CCE on a List attribute
// java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metamodel.ListAttributeImpl cannot be cast to jakarta.persistence.metamodel.CollectionAttribute
CollectionAttribute<Manufacturer, ?> anAttribute = entityManufacturer_.getDeclaredCollection("hardwareDesigners", entityManufacturer_.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: Expected attribute return type [COLLECTION] on the existing attribute [hardwareDesigners] on the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] but found attribute return type [LIST].
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
// FUTURE: We need a Collection (computers is a Set)
/* expectedIAExceptionThrown = false;
try {
//<E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC3 - the attribute is on the managedType (not on any superType)
CollectionAttribute<Manufacturer, HardwareDesigner> anAttribute =
entityManufacturer.getDeclaredCollection("computers", entityHardwareDesigner.getJavaType());
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
*/
/* // FUTURE: We need a Collection on a superclass (computers is a Set)
expectedIAExceptionThrown = false;
try {
//<E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC4 - the attribute is on the immediate superclass but it is the wrong return type of LIST instead of COLLECTION
CollectionAttribute<Manufacturer, Computer> anAttribute =
entityManufacturer.getDeclaredCollection("corporateComputers", entityComputer.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
//iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
*/
// private Collection<Computer> corporateComputers = new HashSet<Computer>();
// http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_91:_20091008:_ManagedType.getDeclaredAttribute.28.29_does_not_throw_expected_IAE_for_Entity.28target.29-MappedSuperclass-MappedSuperclass.28attribute.29_Hierarchy
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
// UC4 - the attribute is on the immediate superclass and is the correct COLLECTION - we still get an IAE
CollectionAttribute<Manufacturer, Computer> anAttribute = entityManufacturer_.getDeclaredCollection("corporateComputers", entityComputer_.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: Expected attribute return type [COLLECTION] on the existing attribute [corporateComputers] on the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] but found attribute return type [LIST].
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
/**
* Return the Set-valued attribute declared by the managed type
* that corresponds to the specified name and Java element type.
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
* @return declared SetAttribute of the given name and
* element type
* @throws IllegalArgumentException if attribute of the given
* name and type is not declared in the managed type
*/
// <E> SetAttribute<X, E> getDeclaredSet(String name, Class<E> elementType);
/**
* Return the List-valued attribute declared by the managed
* type that corresponds to the specified name and Java
* element type.
* @param name the name of the represented attribute
* @param elementType the element type of the represented
* attribute
* @return declared ListAttribute of the given name and
* element type
* @throws IllegalArgumentException if attribute of the given
* name and type is not declared in the managed type
*/
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC1 - the attribute does not exist on the managedType (regardless of whether it is on any superType)
ListAttribute<Manufacturer, GalacticPosition> anAttribute = entityManufacturer_.getDeclaredList("locations", entityLocation_.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The attribute [locations] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present.
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC2 - the attribute is on the managedType (but is the wrong type)
ListAttribute<Manufacturer, ?> anAttribute = entityManufacturer_.getDeclaredList("hardwareDesigners", entityManufacturer_.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: Expected attribute type [class org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer] on the existing attribute [hardwareDesigners] on the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] but found attribute type [class org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner].
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC3 - the attribute is on the managedType (not on any superType)
ListAttribute<Manufacturer, HardwareDesigner> anAttribute = entityManufacturer_.getDeclaredList("hardwareDesigners", entityHardwareDesigner_.getJavaType());
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
// private Collection<Computer> corporateComputers = new HashSet<Computer>();
// http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#DI_91:_20091008:_ManagedType.getDeclaredAttribute.28.29_does_not_throw_expected_IAE_for_Entity.28target.29-MappedSuperclass-MappedSuperclass.28attribute.29_Hierarchy
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC4 - the attribute is on the immediate superclass
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
CollectionAttribute<Manufacturer, Computer> anAttribute = entityManufacturer_.getDeclaredCollection("corporateComputers", entityComputer_.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
/**
* Return all collection-valued attributes of the managed type.
* @return collection valued attributes
*/
// java.util.Set<PluralAttribute<? super X, ?, ?>> getCollections();
/**
* Return all collection-valued attributes declared by the
* managed type.
* @return declared collection valued attributes
*/
// java.util.Set<PluralAttribute<X, ?, ?>> getDeclaredCollections();
// This also tests getCollections()
// Here we start with 6 attributes in getAttributes() - this is reduced to 3 in getCollections before declared filtering
// In declaredCollections we reduce this to 2 because one of the types "corporateComputers" is on a mappedSuperclass
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC3 - the attribute is on the managedType (not on any superType)
Set<PluralAttribute<Manufacturer, ?, ?>> collections = entityManufacturer_.getDeclaredPluralAttributes();
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
/**
* Return the attribute of the managed
* type that corresponds to the specified name.
* @param name the name of the represented attribute
* @return attribute with given name
* @throws IllegalArgumentException if attribute of the given
* name is not present in the managed type
*/
// Attribute<? super X, ?> getAttribute(String name);
/**
* Return the declared attribute of the managed
* type that corresponds to the specified name.
* @param name the name of the represented attribute
* @return attribute with given name
* @throws IllegalArgumentException if attribute of the given
* name is not declared in the managed type
*/
// Attribute<X, ?> getDeclaredAttribute(String name);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC1 - the attribute does not exist on the managedType (regardless of whether it is on any superType)
Attribute<Manufacturer, ?> anAttribute = // , entityLocation.getJavaType());
entityManufacturer_.getDeclaredAttribute("locations");
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The attribute [locations] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present.
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC3 - the attribute is on the managedType (not on any superType)
Attribute<Manufacturer, ?> anAttribute = // , entityHardwareDesigner.getJavaType());
entityManufacturer_.getDeclaredAttribute("hardwareDesigners");
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC4 - the attribute is on the immediate superclass
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
Attribute<Manufacturer, ?> anAttribute = // , entityComputer.getJavaType());
entityManufacturer_.getDeclaredAttribute("corporateComputers");
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
Attribute<Manufacturer, ?> aListAttribute = null;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// the attribute is on the class
// , entityComputer.getJavaType());
aListAttribute = entityManufacturer_.getDeclaredAttribute("hardwareDesigners");
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
// iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
assertNotNull(aListAttribute);
// check the root
expectedIAExceptionThrown = false;
Attribute<Person, Manufacturer> aCollectionAttribute = null;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// the attribute is on the class
IdentifiableType person = entityManufacturer_.getSupertype().getSupertype();
// , entityComputer.getJavaType());
aCollectionAttribute = person.getDeclaredAttribute("historicalEmps");
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
// iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
assertNotNull(aCollectionAttribute);
// check managed type
assertEquals(msPerson_, aCollectionAttribute.getDeclaringType());
// check element type
// assertEquals(entityManufacturer, aCollectionAttribute.getDeclaringType());
// positive: check one level down from the root
expectedIAExceptionThrown = false;
Attribute<Corporation, ?> aCollectionAttribute2 = null;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// the attribute is on the class
IdentifiableType corporation = entityManufacturer_.getSupertype();
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
// , entityComputer.getJavaType());
aCollectionAttribute2 = corporation.getDeclaredAttribute("corporateComputers");
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
assertNotNull(aCollectionAttribute2);
// negative: check one level down from the root
expectedIAExceptionThrown = false;
aCollectionAttribute2 = null;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// the attribute is on the class
IdentifiableType corporation = entityManufacturer_.getSupertype();
// , entityComputer.getJavaType());
aCollectionAttribute2 = corporation.getDeclaredAttribute("notFound");
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
expectedIAExceptionThrown = true;
}
// we expect an IAE on getAttribute(name) if name does not exist
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
/**
* Return the single-valued attribute of the managed type that
* corresponds to the specified name in the represented type.
* @param name the name of the represented attribute
* @return single-valued attribute with the given name
* @throws IllegalArgumentException if attribute of the given
* name is not present in the managed type
*/
// SingularAttribute<? super X, ?> getSingularAttribute(String name);
/**
* Return the declared single-valued attribute of the managed
* type that corresponds to the specified name in the
* represented type.
* @param name the name of the represented attribute
* @return declared single-valued attribute of the given
* name
* @throws IllegalArgumentException if attribute of the given
* name is not declared in the managed type
*/
// SingularAttribute<X, ?> getDeclaredSingularAttribute(String name);
/**
* Return the Collection-valued attribute of the managed type
* that corresponds to the specified name.
* @param name the name of the represented attribute
* @return CollectionAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not present in the managed type
*/
// CollectionAttribute<? super X, ?> getCollection(String name);
/**
* Return the Set-valued attribute of the managed type that
* corresponds to the specified name.
* @param name the name of the represented attribute
* @return SetAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not present in the managed type
*/
// SetAttribute<? super X, ?> getSet(String name);
/**
* Return the List-valued attribute of the managed type that
* corresponds to the specified name.
* @param name the name of the represented attribute
* @return ListAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not present in the managed type
*/
// ListAttribute<? super X, ?> getList(String name);
/**
* Return the Map-valued attribute of the managed type that
* corresponds to the specified name.
* @param name the name of the represented attribute
* @return MapAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not present in the managed type
*/
// MapAttribute<? super X, ?, ?> getMap(String name);
/**
* Return the Collection-valued attribute declared by the
* managed type that corresponds to the specified name.
* @param name the name of the represented attribute
* @return declared CollectionAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not declared in the managed type
*/
// CollectionAttribute<X, ?> getDeclaredCollection(String name);
expectedIAExceptionThrown = false;
try {
// UC4 - the attribute is on the immediate superclass
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
CollectionAttribute<Manufacturer, ?> anAttribute = entityManufacturer_.getDeclaredCollection("corporateComputers");
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
expectedIAExceptionThrown = true;
}
// IAE because the attribute is declared one level above
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
try {
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
CollectionAttribute<Corporation, ?> anAttribute = msCorporation_.getDeclaredCollection("corporateComputers");
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
}
assertFalse(expectedIAExceptionThrown);
expectedIAExceptionThrown = false;
try {
// <E> ListAttribute<X, E> getDeclaredList(String name, Class<E> elementType);
// UC4 - the attribute is on the immediate superclass
// Note: internally EclipseLink treats a ONE_TO_MANY as a MANY_TO_MANY for the case of a unidirectional mapping on a MappedSuperclass
CollectionAttribute<Manufacturer, Computer> anAttribute = entityManufacturer_.getDeclaredCollection("corporateComputers", entityComputer_.getJavaType());
} catch (IllegalArgumentException iae) {
// expecting
// java.lang.IllegalArgumentException: The declared attribute [corporateComputers] from the managed type [ManagedTypeImpl[RelationalDescriptor(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer --> [DatabaseTable(CMP3_MM_MANUF)])]] is not present - however, it is declared on a superclass.
expectedIAExceptionThrown = true;
}
assertTrue("Expected thrown IllegalArgumentException", expectedIAExceptionThrown);
// reset state
expectedIAExceptionThrown = false;
/**
* Return the Set-valued attribute declared by the managed type
* that corresponds to the specified name.
* @param name the name of the represented attribute
* @return declared SetAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not declared in the managed type
*/
// SetAttribute<X, ?> getDeclaredSet(String name);
/**
* Return the List-valued attribute declared by the managed
* type that corresponds to the specified name.
* @param name the name of the represented attribute
* @return declared ListAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not declared in the managed type
*/
// ListAttribute<X, ?> getDeclaredList(String name);
/**
* Return the Map-valued attribute declared by the managed
* type that corresponds to the specified name.
* @param name the name of the represented attribute
* @return declared MapAttribute of the given name
* @throws IllegalArgumentException if attribute of the given
* name is not declared in the managed type
*/
// MapAttribute<X, ?, ?> getDeclaredMap(String name);
} catch (IllegalArgumentException iae) {
iae.printStackTrace();
expectedIAExceptionThrown = true;
} finally {
cleanup(em);
assertFalse("An IAE exception should not occur here.", expectedIAExceptionThrown);
}
}
Aggregations