/*
 * DaoInfoMappingTest.java
 *
 * Created on 2006/12/18, 20:07
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package test.org.itscool.commons.dao;

import java.util.HashMap;
import junit.framework.TestCase;
import org.itscool.commons.dao.EntityInfo;
import org.itscool.commons.dao.EntityInfoMapping;
import org.itscool.commons.dao.FieldMap;
import org.itscool.commons.dao.RecordMap;

/**
 *
 * @author kanou
 */
public class DaoInfoMappingTest extends TestCase{
    public void test1(){
        EntityInfoMapping mapping = EntityInfoMapping.getInstance();
        mapping.clear();
        HashMap daoInfoMappings = new HashMap();
        EntityInfo autorInfo = new EntityInfo();
        daoInfoMappings.put("test.org.itscool.commons.dao.AutorBean1", new EntityInfo());
        daoInfoMappings.put("test.org.itscool.commons.dao.BookBean1", new EntityInfo());
        //DaoInfoの登録とRecordMapの生成を行う
        mapping.setDaoInfoMappings(daoInfoMappings);
        
        //RecordMapの確認
        EntityInfo info = (EntityInfo)mapping.get("test.org.itscool.commons.dao.AutorBean1");
        RecordMap gRecordMap = info.getGRecordMap();
        
        //テーブル、クラス情報の取得テスト
        assertEquals(gRecordMap.getClassName(), AutorBean1.class.getName());
        assertEquals(gRecordMap.getTableName(), AutorBean1.TABLE);
        assertEquals(gRecordMap.getClassOnlyName(), "AutorBean1");
        
        //フィールド情報の取得テスト
        FieldMap field = gRecordMap.getField(AutorBean1.TABLE +"."+AutorBean1.COLUM_id);
        assertEquals(field.getPropertyName(), "id");
        assertEquals(field.getColumAsName(),"AUTOR_ID");
        
    }
}
