package com.brilliance.isc.convert.mt1xx;

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

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

    //数据格式和业务逻辑均正确的测试方法。
    @Test
    public void MT196_Test_1() {
        MT196Creator mt196Creator = new MT196Creator("196");
        //20
        mt196Creator.setTransactionReferenceNumber("Transaction");
        //21
        mt196Creator.setRelatedReference("Related");
        //76
        mt196Creator.setAnswers("Queries");
        //77A
        mt196Creator.setNarrative("Narrative");
        //11a
        mt196Creator.setMtDateTag11a("195\r\n201231\r\n1234123456");
        //错误格式
        //mt196Creator.setMtDateTag11a("195201231");
        //79
        mt196Creator.setNarrativeDescriptionOriginal("DescriptionOriginal");

        MtCreatorManager.packMT(mt196Creator);
    }

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

        MtCreatorManager.packMT(mt196Creator);
    }

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

        MtCreatorManager.packMT(mt196Creator);
    }
}
