/*
 * 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.criteria;

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(AutorBean1.class.getName(), new EntityInfo());
        daoInfoMappings.put(BookBean1.class.getName(), new EntityInfo());
        //DaoInfoの登録とRecordMapの生成を行う
        mapping.setDaoInfoMappings(daoInfoMappings);
        
        //RecordMapの確認
        EntityInfo info = (EntityInfo)mapping.get(AutorBean1.class.getName());
        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");
        
    }
}
