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());
}
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.
}
Aggregations