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

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

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

    public void setUp() throws Exception {
        // 
        engine = TransformEngine.getInstance();

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

    public void tearDown() throws Exception {
        //
    }
    /*
INSERT INTO TSEAITR07 (LOUTNAME, LOUTPTRNNAME, LOUTDESC, LASTAMNDHMS, EAIBZWKDSTCD, UAPPLNAME, SYSINTFACNAME, CREATEBY, UPDATEBY) VALUES ('FUNCTION_IF', 'BYTES', 'FUNCTION IF �׽�Ʈ', '2016080304100100', 'TST', null, null, 'admin', 'admin');
INSERT INTO TSEAITR08 (LOUTNAME, LOUTITEMNAME, LOUTITEMSERNO, LOUTITEMIDNAME, PARNTLOUTITEMIDNAME, LOUTITEMDESC, LOUTITEMNODEPTRNIDNAME, LOUTITEMPTRNIDNAME, LOUTITEMPATHNAME, LOUTITEMLENCNT, LOUTITEMREFINFO, LOUTITEMREFINFO2, LOUTITEMOCCURPTRNDSTCD, LOUTITEMMAXOCCURNOITM, LOUTITEMMINOCCURNOITM, LOUTITEMBASCVAL, LOUTITEMMSKYN, LOUTDPTCNT, DECPTLENCNT, LOUTITEMREFPTRNIDNAME, LOUTITEMMASKLENGTH) VALUES ('FUNCTION_IF', 'FUNCTION_IF', 0, 1000, 0, 'FUNCTION IF �׽�Ʈ', 2201, 2100, ' ', 0, ' ', ' ', ' ', 0, 0, ' ', ' ', 1, 0, ' ', null);
INSERT INTO TSEAITR08 (LOUTNAME, LOUTITEMNAME, LOUTITEMSERNO, LOUTITEMIDNAME, PARNTLOUTITEMIDNAME, LOUTITEMDESC, LOUTITEMNODEPTRNIDNAME, LOUTITEMPTRNIDNAME, LOUTITEMPATHNAME, LOUTITEMLENCNT, LOUTITEMREFINFO, LOUTITEMREFINFO2, LOUTITEMOCCURPTRNDSTCD, LOUTITEMMAXOCCURNOITM, LOUTITEMMINOCCURNOITM, LOUTITEMBASCVAL, LOUTITEMMSKYN, LOUTDPTCNT, DECPTLENCNT, LOUTITEMREFPTRNIDNAME, LOUTITEMMASKLENGTH) VALUES ('FUNCTION_IF', 'DATA1', 1, 1001, 1000, 'DATA1', 2203, 2113, ' ', 5, ' ', ' ', ' ', 1, 1, ' ', ' ', 3, 0, 'String', null);
INSERT INTO TSEAITR01 (CNVSNNAME, CNVSNDESC, LASTAMNDHMS, CREATEBY, UPDATEBY) VALUES ('TRANSFORM_FUNCTION_IF_REQ', null, '20160803154737  ', 'admin', 'admin');
INSERT INTO TSEAITR02 (CNVSNNAME, LOUTNAME, SOURCRSULTDSTCD) VALUES ('TRANSFORM_FUNCTION_IF_REQ', 'FUNCTION_IF', 'TGT_LAYOUT');
INSERT INTO TSEAITR02 (CNVSNNAME, LOUTNAME, SOURCRSULTDSTCD) VALUES ('TRANSFORM_FUNCTION_IF_REQ', 'FUNCTION_IF', 'SRC_LAYOUT');
INSERT INTO TSEAITR03 (CNVSNNAME, CNVSNRSULTITEMPATHNAME, CNVSNCMDNAME, CNVSNITEMBASCVAL, CNVSNITEMSERNO) VALUES ('TRANSFORM_FUNCTION_IF_REQ', 'FUNCTION_IF.DATA1', 'if(tostring(FUNCTION_IF.DATA1)=="12345","00000","XXXXX")', null, 999);

     */
	public void testIf() throws Exception {
		System.out.println("Test If ==============================================================");
		// logger.debug("Transform08900001Test | testTransform()");

		// ----------------------------------------------------------------------
		// source message 
		// ----------------------------------------------------------------------
		String data = "";
    	data = "12345";


		Message source = MessageFactory.getFactory().getMessage("FUNCTION_IF");
		
		source.setData(data.getBytes());
        Transformer transformer = engine.getTransformer();
        Message target = transformer.transform("TRANSFORM_FUNCTION_IF_REQ", new Message[] { source });
      
      
      
        System.out.println("["+new String((byte[])target.getData())+"]");
		
		
		
		

	} 
    
}
