use of org.datanucleus.store.schema.naming.DN2NamingFactory in project tests by datanucleus.
the class DN2NamingFactoryTest method testDatastoreIdColumnName.
public void testDatastoreIdColumnName() {
JDOPersistenceManagerFactory jdoPMF = (JDOPersistenceManagerFactory) pmf;
NucleusContext nucCtx = jdoPMF.getNucleusContext();
ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
MetaDataManager mmgr = nucCtx.getMetaDataManager();
AbstractClassMetaData cmd1 = mmgr.getMetaDataForClass(Gym.class, clr);
DN2NamingFactory factory = new DN2NamingFactory(nucCtx);
factory.setMaximumLength(SchemaComponent.COLUMN, 128);
factory.setNamingCase(NamingCase.LOWER_CASE);
assertEquals("Column name for datastore-id is incorrect", "gym_id", factory.getColumnName(cmd1, ColumnType.DATASTOREID_COLUMN));
}
use of org.datanucleus.store.schema.naming.DN2NamingFactory in project tests by datanucleus.
the class DN2NamingFactoryTest method testJoinTableName.
public void testJoinTableName() {
JDOPersistenceManagerFactory jdoPMF = (JDOPersistenceManagerFactory) pmf;
NucleusContext nucCtx = jdoPMF.getNucleusContext();
ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
MetaDataManager mmgr = nucCtx.getMetaDataManager();
AbstractClassMetaData cmd1 = mmgr.getMetaDataForClass(UserGroup.class, clr);
DN2NamingFactory factory = new DN2NamingFactory(nucCtx);
factory.setNamingCase(NamingCase.LOWER_CASE);
factory.setMaximumLength(SchemaComponent.TABLE, 128);
String name = factory.getTableName(cmd1.getMetaDataForMember("members"));
assertEquals("Join table name is incorrect", "usergroup_members", name);
}
use of org.datanucleus.store.schema.naming.DN2NamingFactory in project tests by datanucleus.
the class DN2NamingFactoryTest method testNestedEmbeddedPCColumnNames.
/**
* Test where the sample classes have no EmbeddedMetaData overriding the column names, so we just get generated names for embedded class and nested embedded class.
*/
public void testNestedEmbeddedPCColumnNames() {
JDOPersistenceManagerFactory jdoPMF = (JDOPersistenceManagerFactory) pmf;
NucleusContext nucCtx = jdoPMF.getNucleusContext();
ClassLoaderResolver clr = nucCtx.getClassLoaderResolver(null);
MetaDataManager mmgr = nucCtx.getMetaDataManager();
DN2NamingFactory factory = new DN2NamingFactory(nucCtx);
factory.setMaximumLength(SchemaComponent.COLUMN, 128);
factory.setNamingCase(NamingCase.LOWER_CASE);
AbstractClassMetaData emb1Cmd = mmgr.getMetaDataForClass(EmbCls1.class, clr);
AbstractMemberMetaData embCls2aMmd = emb1Cmd.getMetaDataForMember("embCls2a");
AbstractMemberMetaData embCls2bMmd = emb1Cmd.getMetaDataForMember("embCls2b");
AbstractClassMetaData emb2Cmd = mmgr.getMetaDataForClass(EmbCls2.class, clr);
AbstractMemberMetaData embCls3Mmd = emb2Cmd.getMetaDataForMember("embCls3");
AbstractMemberMetaData cls2NameMmd = emb2Cmd.getMetaDataForMember("cls2Name");
AbstractClassMetaData emb3Cmd = mmgr.getMetaDataForClass(EmbCls3.class, clr);
AbstractMemberMetaData cls3NameMmd = emb3Cmd.getMetaDataForMember("cls3Name");
List<AbstractMemberMetaData> colMmds = new ArrayList<AbstractMemberMetaData>();
colMmds.add(embCls2aMmd);
colMmds.add(cls2NameMmd);
String colName = factory.getColumnName(colMmds, 0);
assertEquals("embcls2a_cls2name", colName);
colMmds.clear();
colMmds.add(embCls2bMmd);
colMmds.add(cls2NameMmd);
colName = factory.getColumnName(colMmds, 0);
assertEquals("embcls2b_cls2name", colName);
colMmds.clear();
colMmds.add(embCls2aMmd);
colMmds.add(embCls3Mmd);
colMmds.add(cls3NameMmd);
colName = factory.getColumnName(colMmds, 0);
assertEquals("embcls2a_embcls3_cls3name", colName);
colMmds.clear();
colMmds.add(embCls2bMmd);
colMmds.add(embCls3Mmd);
colMmds.add(cls3NameMmd);
colName = factory.getColumnName(colMmds, 0);
assertEquals("embcls2b_embcls3_cls3name", colName);
}
Aggregations