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 TransformFieldOccrTest extends TestCase {
	protected static Logger logger = Logger.getLogger("transformer");

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

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

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

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

    public void tearDown() throws Exception {
        //
    }

  public void testFlatGenerate() throws Exception {
	  		System.out.println("Flat  ==============================================================");
            //----------------------------------------------------------------------
            // source message 타행환공동망통신망전문
            //----------------------------------------------------------------------
        	String data ="LLZZTCP00KBB11112221000201909051040IBK030A234567123456712345671234567123456712345671234567123456712345671234567B234567123456712345671234567123456712345671234567123456712345671234567C234567123456712345671234567123456712345671234567123456712345671234567BBBBBBBBBBBB";
            Message source = MessageFactory.getFactory().getMessage("KFM_EBE98109042_REQ1");
            source.setData(data.getBytes());
            System.out.println(source);
    
            //----------------------------------------------------------------------
            // 변환 방식 1
            //----------------------------------------------------------------------
            Transformer transformer = engine.getTransformer();
            Message target = transformer.transform("TRANSFORM_KFM_EBE9810904EBE_REQ", new Message[] { source });
            
            System.out.println(target);
            System.out.println(target.toString());
            System.out.println("testFlatToJsonTransform >> [["+target.getData()+"]]");
            
        }        
    
    
}
