Search in sources :

Example 1 with Department

use of org.datanucleus.samples.ann_xml.models.company.Department in project tests by datanucleus.

the class AnnotationPlusXMLTest method testDefaultFetchGroup.

/**
 * Test of DFG on a field (implicit or explicit).
 */
public void testDefaultFetchGroup() {
    // Person
    ClassMetaData cmd = (ClassMetaData) metaDataMgr.getMetaDataForClass(Person.class.getName(), clr);
    String prefix = cmd.getFullClassName() + " : ";
    // "bestFriend" - not set, not default
    AbstractMemberMetaData fmd = cmd.getMetaDataForMember("bestFriend");
    assertEquals(prefix + "field should be persistent", FieldPersistenceModifier.PERSISTENT, fmd.getPersistenceModifier());
    assertFalse(prefix + "dfg is wrong", fmd.isDefaultFetchGroup());
    // "dateOfBirth" - not set, but default
    fmd = cmd.getMetaDataForMember("dateOfBirth");
    assertEquals(prefix + "field should be persistent", FieldPersistenceModifier.PERSISTENT, fmd.getPersistenceModifier());
    assertTrue(prefix + "dfg is wrong", fmd.isDefaultFetchGroup());
    // "lastName" - not annotated, but default
    fmd = cmd.getMetaDataForMember("lastName");
    assertEquals(prefix + "field should be persistent", FieldPersistenceModifier.PERSISTENT, fmd.getPersistenceModifier());
    assertTrue(prefix + "dfg is wrong", fmd.isDefaultFetchGroup());
    // Department
    cmd = (ClassMetaData) metaDataMgr.getMetaDataForClass(Department.class.getName(), clr);
    prefix = cmd.getFullClassName() + " : ";
    // "manager" - explicitly set
    fmd = cmd.getMetaDataForMember("manager");
    assertEquals(prefix + "field should be persistent", FieldPersistenceModifier.PERSISTENT, fmd.getPersistenceModifier());
    assertTrue(prefix + "dfg is wrong", fmd.isDefaultFetchGroup());
}
Also used : Department(org.datanucleus.samples.ann_xml.models.company.Department) AbstractMemberMetaData(org.datanucleus.metadata.AbstractMemberMetaData) ClassMetaData(org.datanucleus.metadata.ClassMetaData)

Example 2 with Department

use of org.datanucleus.samples.ann_xml.models.company.Department in project tests by datanucleus.

the class AnnotationPlusXMLTest method testInheritanceStrategy.

public void testInheritanceStrategy() {
    // Person
    ClassMetaData cmd = (ClassMetaData) metaDataMgr.getMetaDataForClass(Person.class.getName(), clr);
    String prefix = cmd.getFullClassName() + " : ";
    InheritanceMetaData inhmd = cmd.getInheritanceMetaData();
    assertNotNull(prefix + " has no inheritance information", inhmd);
    assertEquals(prefix + " inheritance strategy is incorrect", InheritanceStrategy.NEW_TABLE, inhmd.getStrategy());
    // Department
    cmd = (ClassMetaData) metaDataMgr.getMetaDataForClass(Department.class.getName(), clr);
    prefix = cmd.getFullClassName() + " : ";
    inhmd = cmd.getInheritanceMetaData();
    assertEquals(prefix + "inheritance strategy is incorrect", InheritanceStrategy.NEW_TABLE, inhmd.getStrategy());
// TODO: test a SUBCLASS_TABLE inheritance strategy annotation.
}
Also used : Department(org.datanucleus.samples.ann_xml.models.company.Department) InheritanceMetaData(org.datanucleus.metadata.InheritanceMetaData) ClassMetaData(org.datanucleus.metadata.ClassMetaData)

Aggregations

ClassMetaData (org.datanucleus.metadata.ClassMetaData)2 Department (org.datanucleus.samples.ann_xml.models.company.Department)2 AbstractMemberMetaData (org.datanucleus.metadata.AbstractMemberMetaData)1 InheritanceMetaData (org.datanucleus.metadata.InheritanceMetaData)1