package com.eactive.eai.transformer;

import com.eactive.eai.common.util.Logger;
import com.eactive.eai.transformer.engine.TransformEngine;
import com.eactive.eai.transformer.engine.Transformer;
import com.eactive.eai.transformer.message.Message;
import com.eactive.eai.transformer.message.MessageFactory;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;


public class TransformKEC047244ABFES01Test extends TestCase {
	protected static Logger logger = Logger.getLogger("transformer");

	TransformEngine engine = null;
    
    
    public TransformKEC047244ABFES01Test(String name) {
        super(name);
    }

    public static Test suite() {
        /*
        * the dynamic way
        */
        return new TestSuite(TransformKEC047244ABFES01Test.class);
    }

    public void setUp() throws Exception {
    	
        // 변환 초기화
        engine = TransformEngine.getInstance();

        if (!engine.isStarted()) {
            engine.start();
        }
    }

    public void tearDown() throws Exception {
        //
    }
    
    public void testXmlToUJson() throws Exception {
  		System.out.println("Xml TO Json ==============================================================");

        //----------------------------------------------------------------------
        // source message 생성
        //----------------------------------------------------------------------
    	String data ="";
    	//data = "<EAI_TSTXML_REQ1><GROUP><HANGLE>한글</HANGLE><TEXT>ABCD1234</TEXT><BASE>한글</BASE></GROUP></EAI_TSTXML_REQ1>";
    	data ="<KEC_KEC047244A_RES1>"
    	+"<OutData>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     "
    	+"	<MgivstPrdctPrstusYildPDTO feeSubstrBfAfDstcd=\"0\" groupCoCd=\"KB0\" startYmd=\"20191201\" rtirePensnUserName=\"=한=엄사렬\" wholValpr=\"0\" wholYild=\"0\" asstMgtInstiCd=\"9999\" ppsnTypIRPAcnYild=\"0\" inquryEndYmd=\"20200320\" corpTypIRPAcnBal=\"0\" bramDstcdNm=\"전체\" custIdnfr=\"\" corpTypIRPAcnYild=\"0\" rtirePensnCtrcDsticName=\"DB\" pDCAcnBal=\"0\" inquryDstcd=\"2\" inquryStartYmd=\"20190320\" wholBal=\"0\" pDCAcnYild=\"0\" wholPaymtCmtlAmt=\"0\" joinYmd=\"20110429\" pDCAcnValpr=\"0\" bramDstcd=\"0\" rtirePensnCtrcDstcd=\"1\" rtirePensnJoinPnm=\"=한=엄사렬\" ppsnTypIRPAcnPaymtCmtlAmt=\"0\" wholMnrcvCmtlAmt=\"0\" ppsnTypIRPAcnMnrcvCmtlAmt=\"0\" ppsnTypIRPAcnBal=\"0\" corpTypIRPAcnPaymtCmtlAmt=\"0\" custMgtNo=\"\" corpTypIRPAcnMnrcvCmtlAmt=\"0\" rtirePensnUserAcno=\"86518900000534\" ppsnTypIRPAcnValpr=\"0\" pDCAcnPaymtCmtlAmt=\"0\" endYmd=\"20200319\" elctyEndYmd=\"20191130\" corpTypIRPAcnValpr=\"0\" rtirePensnApctAcno=\"86518900000534\" pDCAcnMnrcvCmtlAmt=\"0\">   "
    	+"		<messageDTO>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              "
    	+"			<MessageDTO msgCd=\"00\" msgData=\"조회되었습니다.\"/>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  "
    	+"		</messageDTO>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             "
    	+"		<PrdctDsticPerYildDDTO rtirePensnPrdctPbnotiDstcd=\"1\" rtirePensnPrdctPbnotiDsticName=\"원리금보장상품\"/>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               "
    	+"		<PrdctDsticPerYildDDTO rtirePensnPrdctPbnotiDstcd=\"2\" rtirePensnPrdctPbnotiDsticName=\"비원리금보장상품\"/>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             "
    	+"		<PrdctDsticPerYildDDTO rtirePensnPrdctPbnotiDstcd=\"3\" rtirePensnPrdctPbnotiDsticName=\"대기성자금\"/>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   "
    	+"	</MgivstPrdctPrstusYildPDTO>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                "
    	+"	<MessageDTO msgCd=\"00\" msgData=\"조회되었습니다.\"/>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      "
    	+"</OutData>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    "
    	+"</KEC_KEC047244A_RES1>"
    	;
    	
    	System.out.println(data);
    	Message source = MessageFactory.getFactory().getMessage("KEC_KEC047244A_RES1");
        source.setData(data);

        System.out.println("source="+source);

        //----------------------------------------------------------------------
        // 변환 방식 1
        //----------------------------------------------------------------------
        Transformer transformer = engine.getTransformer();
        Message target = transformer.transform("TRANSFORM_BFE_KEC047244ABFE_RES", new Message[] { source });

        System.out.println(target.toString());
        System.out.println(target.getData());
        
    }
 
    
}
