package com.brilliance.isc.convert.mt1xx;

import com.brilliance.isc.swift.objmtconvert.manager.MtCreatorManager;
import com.brilliance.isc.swift.objmtconvert.model.mt1xx.MT195Creator;
import org.junit.Test;

/**
 * MT195报文测试类。
 * 暂时将MT and Date of the Original Message按照11S处理。
 * 暂时不处理Copy of fields。
 * @author liusheng
 */
public class MT195Test {

    //数据格式和业务逻辑均正确的测试方法。
    @Test
    public void MT195_Test_1() {
        MT195Creator mt195Creator = new MT195Creator("195");
        //20
        mt195Creator.setTransactionReferenceNumber("Transaction");
        //21
        mt195Creator.setRelatedReference("Related");
        //75
        mt195Creator.setQueries("Queries");
        //77A
        mt195Creator.setNarrative("Narrative");
        //11a
        mt195Creator.setMtDateTag11a("195\r\n201231\r\n1234123456");
        //错误格式
        //mt195Creator.setMtDateTag11a("195201231");
        //79
        mt195Creator.setNarrativeDescription("Description");

        MtCreatorManager.packMT(mt195Creator);
    }

    //数据格式错误的测试方法。
    @Test
    public void MT195_Test_2() {
        MT195Creator mt195Creator = new MT195Creator("195");
        //20 字段超长
        mt195Creator.setTransactionReferenceNumber("1234567890 2234567890");
        //21 字段超长
        mt195Creator.setRelatedReference("1234567890 2234567890");
        //75 换行过多
        mt195Creator.setQueries("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n");
        //77A 字段超长
        mt195Creator.setNarrative("1234567890 2234567890 3234567890 423456890");
        //11a 格式错误
        mt195Creator.setMtDateTag11a("195201231");
        //79 字段超长
        mt195Creator.setNarrativeDescription("1234567890 2234567890 3234567890 423456890 " +
                "5234567890");

        MtCreatorManager.packMT(mt195Creator);
    }

    //不符合业务逻辑C1的测试方法。
    @Test
    public void MT195_Test_3() {        MT195Creator mt195Creator = new MT195Creator("195");
        //20
        mt195Creator.setTransactionReferenceNumber("Transaction");
        //21
        mt195Creator.setRelatedReference("Related");
        //75
        mt195Creator.setQueries("Queries");
        //77A
        mt195Creator.setNarrative("Narrative");
        //11a
        mt195Creator.setMtDateTag11a("195\r\n201231\r\n1234123456");
        //79
        // C1.79域与相关查询报文必填域的拷贝不能同时出现。
        // 由于相关报文查询报文必填域的拷贝目前为空，此处只判断79域是否为空。
//        mt195Creator.setNarrativeDescription("Description");

        MtCreatorManager.packMT(mt195Creator);
    }
}
