### Question:
EntityDescFactoryImpl implements EntityDescFactory { public EntityDesc getEntityDesc(DbTableMeta tableMeta) { EntityDesc entityDesc = new EntityDesc(); doName(tableMeta, entityDesc); doTable(tableMeta, entityDesc); doAttributeDesc(tableMeta, entityDesc); doCompositeUniqueConstraintDesc(tableMeta, entityDesc); return entityDesc; } EntityDescFactoryImpl(
            PersistenceConvention persistenceConvention,
            AttributeDescFactory attributeDescFactory,
            CompositeUniqueConstraintDescFactory compositeUniqueConstraintDescFactory); EntityDesc getEntityDesc(DbTableMeta tableMeta);  }### Answer:
@Test public void testName() throws Exception { DbTableMeta dbTableMeta = new DbTableMeta(); dbTableMeta.setName("HOGE"); EntityDesc entityDesc = factory.getEntityDesc(dbTableMeta); assertEquals("Hoge", entityDesc.getName()); }
@Test public void testTable() throws Exception { DbTableMeta dbTableMeta = new DbTableMeta(); dbTableMeta.setCatalogName("AAA"); dbTableMeta.setSchemaName("BBB"); dbTableMeta.setName("HOGE"); EntityDesc entityDesc = factory.getEntityDesc(dbTableMeta); assertEquals("AAA", entityDesc.getCatalogName()); assertEquals("BBB", entityDesc.getSchemaName()); assertEquals("HOGE", entityDesc.getTableName()); }
@Test public void testGetAttributeDescList() throws Exception { DbColumnMeta columnMeta1 = new DbColumnMeta(); columnMeta1.setName("BAR"); columnMeta1.setTypeName("varchar"); DbColumnMeta columnMeta2 = new DbColumnMeta(); columnMeta2.setName("FOO"); columnMeta2.setTypeName("varchar"); DbTableMeta tableMeta = new DbTableMeta(); tableMeta.setName("HOGE"); tableMeta.addColumnMeta(columnMeta1); tableMeta.addColumnMeta(columnMeta2); EntityDesc entityDesc = factory.getEntityDesc(tableMeta); assertEquals(2, entityDesc.getAttributeDescList().size()); }
@Test public void testHasCompositeId() throws Exception { DbColumnMeta columnMeta1 = new DbColumnMeta(); columnMeta1.setName("BAR"); columnMeta1.setPrimaryKey(true); columnMeta1.setTypeName("varchar"); DbColumnMeta columnMeta2 = new DbColumnMeta(); columnMeta2.setName("FOO"); columnMeta2.setPrimaryKey(true); columnMeta2.setTypeName("varchar"); DbTableMeta tableMeta = new DbTableMeta(); tableMeta.setName("HOGE"); tableMeta.addColumnMeta(columnMeta1); tableMeta.addColumnMeta(columnMeta2); EntityDesc entityDesc = factory.getEntityDesc(tableMeta); assertEquals(2, entityDesc.getIdAttributeDescList().size()); assertTrue(entityDesc.hasCompositeId()); }
@Test public void testGetCompositeUniqueConstraintDescList() throws Exception { DbUniqueKeyMeta ukMeta1 = new DbUniqueKeyMeta(); ukMeta1.addColumnName("AAA"); ukMeta1.addColumnName("BBB"); DbUniqueKeyMeta ukMeta2 = new DbUniqueKeyMeta(); ukMeta2.addColumnName("CCC"); ukMeta2.addColumnName("DDD"); DbUniqueKeyMeta ukMeta3 = new DbUniqueKeyMeta(); ukMeta3.addColumnName("EEE"); DbTableMeta tableMeta = new DbTableMeta(); tableMeta.setName("HOGE"); tableMeta.addUniqueKeyMeta(ukMeta1); tableMeta.addUniqueKeyMeta(ukMeta2); tableMeta.addUniqueKeyMeta(ukMeta3); EntityDesc entityDesc = factory.getEntityDesc(tableMeta); assertEquals(2, entityDesc.getCompositeUniqueConstraintDescList() .size()); CompositeUniqueConstraintDesc compositeUniqueConstraintDesc = entityDesc .getCompositeUniqueConstraintDescList().get(0); assertEquals(Arrays.asList("AAA", "BBB"), compositeUniqueConstraintDesc .getColumnNameList()); compositeUniqueConstraintDesc = entityDesc .getCompositeUniqueConstraintDescList().get(1); assertEquals(Arrays.asList("CCC", "DDD"), compositeUniqueConstraintDesc .getColumnNameList()); }