use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.
the class AnnotationTest method testPersistenceAware.
/**
* Test for use of @PersistenceAware
*/
public void testPersistenceAware() {
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(AccessPublicFields.class.getName(), clr);
String prefix = cmd1.getFullClassName() + " : ";
assertNotNull(prefix + "has no MetaData!", cmd1);
assertTrue(prefix + "is not PersistenceAware yet should be", cmd1.getPersistenceModifier() == ClassPersistenceModifier.PERSISTENCE_AWARE);
}
use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.
the class AnnotationTest method testPersistentProperties.
/**
* Test of specifying annotations on getters.
*/
public void testPersistentProperties() {
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(MyPropertyBean.class.getName(), clr);
assertEquals(1, cmd1.getNoOfPrimaryKeyMembers());
}
use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.
the class AnnotationTest method testNonPersistent.
/**
* Test of @NotPersistent on a field.
*/
public void testNonPersistent() {
ClassMetaData cmd = (ClassMetaData) metaDataMgr.getMetaDataForClass(Person.class.getName(), clr);
String prefix = cmd.getFullClassName() + " : ";
AbstractMemberMetaData fmd = cmd.getMetaDataForMember("mood");
assertEquals(prefix + "field should be non-persistent", FieldPersistenceModifier.NONE, fmd.getPersistenceModifier());
}
use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.
the class AnnotationTest method testVersion.
/**
* Test for use of version specification in annotations
*/
public void testVersion() {
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(Trade1.class.getName(), clr);
String prefix = cmd1.getFullClassName() + " : ";
VersionMetaData vermd = cmd1.getVersionMetaData();
assertNotNull(prefix + "has no VersionMetaData", vermd);
assertEquals(prefix + "has incorrect version strategy", "version-number", vermd.getVersionStrategy().toString());
assertNotNull(prefix + "has incorrect version column info", vermd.getColumnMetaData());
assertEquals(prefix + "has incorrect version column name", "TRADE_VERSION", vermd.getColumnMetaData().getName());
}
use of org.datanucleus.metadata.ClassMetaData in project tests by datanucleus.
the class AnnotationTest method testMapKeyInValue.
/**
* Test for use of map with using @Key, @Value.
*/
public void testMapKeyInValue() {
ClassMetaData cmd1 = (ClassMetaData) metaDataMgr.getMetaDataForClass(Person.class.getName(), clr);
String prefix = cmd1.getFullClassName() + " : ";
AbstractMemberMetaData fmd = cmd1.getMetaDataForMember("phoneNumbers");
assertNotNull(prefix + "doesnt have required field", fmd);
MapMetaData mapmd = fmd.getMap();
assertNotNull(prefix + "MapMetaData is null!", mapmd);
assertEquals(prefix + "MapMetaData keyType is incorrect", String.class.getName(), mapmd.getKeyType());
assertEquals(prefix + "MapMetaData valueType is incorrect", PhoneNumber.class.getName(), mapmd.getValueType());
JoinMetaData joinmd = fmd.getJoinMetaData();
assertNull(prefix + "field \"phoneNumbers\" has join information!", joinmd);
KeyMetaData keymd = fmd.getKeyMetaData();
assertEquals(prefix + "field \"phoneNumbers\" has incorrect key mapped-by", "name", keymd.getMappedBy());
}
Aggregations