Search in sources :

Example 1 with HardwareDesigner

use of org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner in project eclipselink by eclipse-ee4j.

the class MetamodelMetamodelTest method testManagedType_getDeclaredSingularAttribute_Type_param_Method.

// TODO: This is not testing anything different?
public void testManagedType_getDeclaredSingularAttribute_Type_param_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_);
    } catch (IllegalArgumentException iae) {
        iae.printStackTrace();
        expectedIAExceptionThrown = true;
    } finally {
        cleanup(em);
        assertFalse("An IAE exception should not occur here.", expectedIAExceptionThrown);
    }
}
Also used : GalacticPosition(org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition) Corporation(org.eclipse.persistence.testing.models.jpa.metamodel.Corporation) EntityManager(jakarta.persistence.EntityManager) HardwareDesigner(org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner) Manufacturer(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer) EntityTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl) MappedSuperclassTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.MappedSuperclassTypeImpl) Computer(org.eclipse.persistence.testing.models.jpa.metamodel.Computer) Metamodel(jakarta.persistence.metamodel.Metamodel) Person(org.eclipse.persistence.testing.models.jpa.metamodel.Person)

Example 2 with HardwareDesigner

use of org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner in project eclipselink by eclipse-ee4j.

the class MetamodelMetamodelTest method testManagedType_getList_Type_param_Method.

// TODO: This is not testing anything different?
public void testManagedType_getList_Type_param_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_);
    } catch (IllegalArgumentException iae) {
        iae.printStackTrace();
        expectedIAExceptionThrown = true;
    } finally {
        cleanup(em);
        assertFalse("An IAE exception should not occur here.", expectedIAExceptionThrown);
    }
}
Also used : GalacticPosition(org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition) Corporation(org.eclipse.persistence.testing.models.jpa.metamodel.Corporation) EntityManager(jakarta.persistence.EntityManager) HardwareDesigner(org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner) Manufacturer(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer) EntityTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl) MappedSuperclassTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.MappedSuperclassTypeImpl) Computer(org.eclipse.persistence.testing.models.jpa.metamodel.Computer) Metamodel(jakarta.persistence.metamodel.Metamodel) Person(org.eclipse.persistence.testing.models.jpa.metamodel.Person)

Example 3 with HardwareDesigner

use of org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner in project eclipselink by eclipse-ee4j.

the class MetamodelMetamodelTest method testManagedType_getCollection_Type_param_Method.

// TODO: This is not testing anything different?
public void testManagedType_getCollection_Type_param_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_);
    } catch (IllegalArgumentException iae) {
        iae.printStackTrace();
        expectedIAExceptionThrown = true;
    } finally {
        cleanup(em);
        assertFalse("An IAE exception should not occur here.", expectedIAExceptionThrown);
    }
}
Also used : GalacticPosition(org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition) Corporation(org.eclipse.persistence.testing.models.jpa.metamodel.Corporation) EntityManager(jakarta.persistence.EntityManager) HardwareDesigner(org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner) Manufacturer(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer) EntityTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl) MappedSuperclassTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.MappedSuperclassTypeImpl) Computer(org.eclipse.persistence.testing.models.jpa.metamodel.Computer) Metamodel(jakarta.persistence.metamodel.Metamodel) Person(org.eclipse.persistence.testing.models.jpa.metamodel.Person)

Example 4 with HardwareDesigner

use of org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner in project eclipselink by eclipse-ee4j.

the class MetamodelMetamodelTest method testBindable_getBindableJavaType_Method.

public void testBindable_getBindableJavaType_Method() {
    EntityManager em = null;
    boolean exceptionThrown = false;
    try {
        em = privateTestSetup();
        assertNotNull(em);
        Metamodel metamodel = em.getMetamodel();
        assertNotNull("The metamodel should never be null after an em.getMetamodel() call here.", metamodel);
        // Actual Test Case
        /*public static enum BindableType {
            SINGULAR_ATTRIBUTE, PLURAL_ATTRIBUTE, ENTITY_TYPE}*/
        EntityTypeImpl<Manufacturer> entityManufacturer_ = (EntityTypeImpl) metamodel.entity(Manufacturer.class);
        assertNotNull(entityManufacturer_);
        SingularAttribute<Manufacturer, Boolean> manufacturer_booleanObject = entityManufacturer_.getDeclaredSingularAttribute("aBooleanObject", Boolean.class);
        assertNotNull(manufacturer_booleanObject);
        ListAttribute<Manufacturer, HardwareDesigner> manufacturer_hardwareDesignersList = entityManufacturer_.getDeclaredList("hardwareDesigners", HardwareDesigner.class);
        assertNotNull(manufacturer_hardwareDesignersList);
        /**
         * Return the Java type of the represented object.
         * If the bindable type of the object is <code>PLURAL_ATTRIBUTE</code>,
         * the Java element type is returned. If the bindable type is
         * <code>SINGULAR_ATTRIBUTE</code> or <code>ENTITY_TYPE</code>,
         * the Java type of the
         * represented entity or attribute is returned.
         * @return Java type
         */
        // Class<T> getBindableJavaType();
        // EntityTypeImpl
        assertEquals(entityManufacturer_.getJavaType(), entityManufacturer_.getBindableJavaType());
        // SingularAttribute
        assertEquals(manufacturer_booleanObject.getJavaType(), manufacturer_booleanObject.getBindableJavaType());
        // PluralAttribute
        Type<HardwareDesigner> manufacturer_hardwareDesignersType = manufacturer_hardwareDesignersList.getElementType();
        assertNotNull(manufacturer_hardwareDesignersType);
        assertNotNull(manufacturer_hardwareDesignersType.getJavaType());
        assertEquals(manufacturer_hardwareDesignersType.getJavaType(), manufacturer_hardwareDesignersList.getBindableJavaType());
    } catch (IllegalArgumentException iae) {
        iae.printStackTrace();
        exceptionThrown = true;
    } finally {
        cleanup(em);
        assertFalse("An IAE exception should not occur here.", exceptionThrown);
    }
}
Also used : EntityManager(jakarta.persistence.EntityManager) HardwareDesigner(org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner) Manufacturer(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer) EntityTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl) Metamodel(jakarta.persistence.metamodel.Metamodel)

Example 5 with HardwareDesigner

use of org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner in project eclipselink by eclipse-ee4j.

the class MetamodelMetamodelTest method testSingularAttribute_isVersion_Method.

public void testSingularAttribute_isVersion_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_);
        // Composite table FK's that include a MappedSuperclass
        // get an Attribute<Container, Type==String>
        Attribute nameAttribute = entityManufacturer_.getAttribute("name");
        assertTrue(null != nameAttribute);
        /**
         *  Is the attribute a version attribute.
         *  @return boolean indicating whether or not attribute is
         *          a version attribute
         */
        // public boolean isVersion() {
        assertFalse(((AttributeImpl) nameAttribute).isPlural());
        assertFalse(((SingularAttributeImpl) nameAttribute).isVersion());
    } catch (IllegalArgumentException iae) {
        iae.printStackTrace();
        expectedIAExceptionThrown = true;
    } finally {
        cleanup(em);
        assertFalse("An IAE exception should not occur here.", expectedIAExceptionThrown);
    }
}
Also used : EntityManager(jakarta.persistence.EntityManager) HardwareDesigner(org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner) PluralAttribute(jakarta.persistence.metamodel.PluralAttribute) Attribute(jakarta.persistence.metamodel.Attribute) MapAttribute(jakarta.persistence.metamodel.MapAttribute) SingularAttribute(jakarta.persistence.metamodel.SingularAttribute) SetAttribute(jakarta.persistence.metamodel.SetAttribute) ListAttribute(jakarta.persistence.metamodel.ListAttribute) CollectionAttribute(jakarta.persistence.metamodel.CollectionAttribute) Manufacturer(org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer) EntityTypeImpl(org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl) Metamodel(jakarta.persistence.metamodel.Metamodel)

Aggregations

EntityManager (jakarta.persistence.EntityManager)36 Metamodel (jakarta.persistence.metamodel.Metamodel)36 EntityTypeImpl (org.eclipse.persistence.internal.jpa.metamodel.EntityTypeImpl)36 HardwareDesigner (org.eclipse.persistence.testing.models.jpa.metamodel.HardwareDesigner)36 Manufacturer (org.eclipse.persistence.testing.models.jpa.metamodel.Manufacturer)36 MappedSuperclassTypeImpl (org.eclipse.persistence.internal.jpa.metamodel.MappedSuperclassTypeImpl)25 Computer (org.eclipse.persistence.testing.models.jpa.metamodel.Computer)25 Corporation (org.eclipse.persistence.testing.models.jpa.metamodel.Corporation)25 GalacticPosition (org.eclipse.persistence.testing.models.jpa.metamodel.GalacticPosition)25 Person (org.eclipse.persistence.testing.models.jpa.metamodel.Person)25 PluralAttribute (jakarta.persistence.metamodel.PluralAttribute)11 Attribute (jakarta.persistence.metamodel.Attribute)10 CollectionAttribute (jakarta.persistence.metamodel.CollectionAttribute)10 ListAttribute (jakarta.persistence.metamodel.ListAttribute)10 MapAttribute (jakarta.persistence.metamodel.MapAttribute)10 SetAttribute (jakarta.persistence.metamodel.SetAttribute)10 SingularAttribute (jakarta.persistence.metamodel.SingularAttribute)10 Bindable (jakarta.persistence.metamodel.Bindable)3 IdentifiableType (jakarta.persistence.metamodel.IdentifiableType)3 ManagedType (jakarta.persistence.metamodel.ManagedType)3