### Question:
IdTableDescFactoryImpl implements IdTableDescFactory { public TableDesc getTableDesc(EntityMeta entityMeta, PropertyMeta propertyMeta) { GenerationType generationType = propertyMeta.getGenerationType(); if (generationType == GenerationType.AUTO) { generationType = dialect.getDefaultGenerationType(); } if (generationType == GenerationType.TABLE) { TableGenerator generator = getTableGenerator(entityMeta, propertyMeta); TableDesc tableDesc = new TableDesc(); doName(entityMeta, tableDesc, generator); doPrimaryKeyColumn(entityMeta, tableDesc, generator); doValueColumn(entityMeta, tableDesc, generator); doUniqueConstraints(entityMeta, tableDesc, generator); return tableDesc; } return null; } IdTableDescFactoryImpl(GenDialect dialect,
            UniqueKeyDescFactory uniqueKeyDescFactory); TableDesc getTableDesc(EntityMeta entityMeta,
            PropertyMeta propertyMeta);  }### Answer:
@Test public void testGetTableDesc_tableId() throws Exception { Field field = getClass().getDeclaredField("tableId"); TableMeta tableMeta = new TableMeta(); tableMeta.setCatalog("HOGE"); tableMeta.setSchema("FOO"); tableMeta.setName("BAR"); EntityMeta entityMeta = new EntityMeta(); entityMeta.setTableMeta(tableMeta); PropertyMeta propertyMeta = propertyMetaFactory.createPropertyMeta( field, entityMeta); TableDesc tableDesc = idTableDescFactory.getTableDesc(entityMeta, propertyMeta); assertEquals("AAA", tableDesc.getCatalogName()); assertEquals("BBB", tableDesc.getSchemaName()); assertEquals("CCC", tableDesc.getName()); assertNotNull(tableDesc.getPrimaryKeyDesc()); assertEquals(2, tableDesc.getColumnDescList().size()); ColumnDesc columnDesc = tableDesc.getColumnDescList().get(0); assertEquals("DDD", columnDesc.getName()); assertEquals("varchar(255)", columnDesc.getDefinition()); columnDesc = tableDesc.getColumnDescList().get(1); assertEquals("EEE", columnDesc.getName()); assertEquals("bigint", columnDesc.getDefinition()); }
@Test public void testGetTableDesc_classAnnotatedTableId() throws Exception { Field field = getClass().getDeclaredField("classAnnotatedTableId"); TableMeta tableMeta = new TableMeta(); tableMeta.setCatalog("HOGE"); tableMeta.setSchema("FOO"); tableMeta.setName("BAR"); EntityMeta entityMeta = new EntityMeta(); entityMeta.setTableMeta(tableMeta); entityMeta.setEntityClass(getClass()); PropertyMeta propertyMeta = propertyMetaFactory.createPropertyMeta( field, entityMeta); TableDesc tableDesc = idTableDescFactory.getTableDesc(entityMeta, propertyMeta); assertEquals("FFF", tableDesc.getCatalogName()); assertEquals("GGG", tableDesc.getSchemaName()); assertEquals("HHH", tableDesc.getName()); assertNotNull(tableDesc.getPrimaryKeyDesc()); assertEquals(2, tableDesc.getColumnDescList().size()); ColumnDesc columnDesc = tableDesc.getColumnDescList().get(0); assertEquals("III", columnDesc.getName()); assertEquals("varchar(255)", columnDesc.getDefinition()); columnDesc = tableDesc.getColumnDescList().get(1); assertEquals("JJJ", columnDesc.getName()); assertEquals("bigint", columnDesc.getDefinition()); }
@Test public void testGetTableDesc_noGeneraterTableId() throws Exception { Field field = getClass().getDeclaredField("noGeneraterTableId"); TableMeta tableMeta = new TableMeta(); tableMeta.setCatalog("HOGE"); tableMeta.setSchema("FOO"); tableMeta.setName("BAR"); EntityMeta entityMeta = new EntityMeta(); entityMeta.setTableMeta(tableMeta); PropertyMeta propertyMeta = propertyMetaFactory.createPropertyMeta( field, entityMeta); TableDesc tableDesc = idTableDescFactory.getTableDesc(entityMeta, propertyMeta); assertEquals("HOGE", tableDesc.getCatalogName()); assertEquals("FOO", tableDesc.getSchemaName()); assertEquals("ID_GENERATOR", tableDesc.getName()); assertNotNull(tableDesc.getPrimaryKeyDesc()); assertEquals(2, tableDesc.getColumnDescList().size()); assertEquals("PK", tableDesc.getColumnDescList().get(0).getName()); assertEquals("VALUE", tableDesc.getColumnDescList().get(1).getName()); }