package com.brilliance.isc.convert.mt1xx;

import com.brilliance.isc.swift.objmtconvert.manager.MtCreatorManager;
import com.brilliance.isc.swift.objmtconvert.model.commontag.ActnoBicAdrTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.commontag.DcDateCurAmtTagXXX;
import com.brilliance.isc.swift.objmtconvert.model.mt1xx.MT111Creator;
import org.junit.Test;

import java.math.BigDecimal;


/**
 * @author liusheng
 * @date 2023/2/27
 */
public class MT111Test {
    @Test
    public void MT111_TEST() {
        MT111Creator mt111Creator = new MT111Creator("111");
        //20
        mt111Creator.setSendersReference("SendersReference");
        //21
        mt111Creator.setChequeNumber("Cheque Number");
        //30
        mt111Creator.setDateOfIssue("201201");
        //59
        ActnoBicAdrTagXXX payee = new ActnoBicAdrTagXXX("59", "111");
        payee.setAcctno("PayeeAccount");
        payee.setAddress("PayeeAddress");
        mt111Creator.setPayee(payee);
        //75
        mt111Creator.setQueries("/19/36018077\r\n/21/");
        //32a
        DcDateCurAmtTagXXX dcDateCurAmtTag32a = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32a.setDate("201231");
        dcDateCurAmtTag32a.setAmount(new BigDecimal("1000"));
        dcDateCurAmtTag32a.setCurrency("USD");
        mt111Creator.setAmount(dcDateCurAmtTag32a);
        //52a
        ActnoBicAdrTagXXX actnoBicAdrTag52a = new ActnoBicAdrTagXXX("52");
        actnoBicAdrTag52a.setInfo("52A");
        actnoBicAdrTag52a.setBic("ABOCCNBJ110");
        mt111Creator.setDrawerBank(actnoBicAdrTag52a);

        MtCreatorManager.packMT(mt111Creator);
    }

    //数据格式正确的测试方法。
    @Test
    public void MT111_TEST_1() {
        MT111Creator mt111Creator = new MT111Creator("111");
        //20
        mt111Creator.setSendersReference("SendersReference");
        //21
        mt111Creator.setChequeNumber("ChequeNumber");
        //30
        mt111Creator.setDateOfIssue("201231");
        //32a A
        DcDateCurAmtTagXXX amount = new DcDateCurAmtTagXXX("32");
        amount.setDate("220101");
        amount.setCurrency("CNY");
        amount.setAmount(new BigDecimal("10000.00"));
        mt111Creator.setAmount(amount);
        //52a A
        ActnoBicAdrTagXXX drawerBank = new ActnoBicAdrTagXXX("52");
        drawerBank.setInfo("D");
        drawerBank.setPartyIdentifier("52A_PartyIdentifier");
        drawerBank.setBic("BKTRUS33XXX");
        mt111Creator.setDrawerBank(drawerBank);
        //59
        ActnoBicAdrTagXXX payee = new ActnoBicAdrTagXXX("59", "111");
        payee.setAcctno("59Account");
        payee.setAddress("Address\r\nAddress");
        mt111Creator.setPayee(payee);
        //75
        mt111Creator.setQueries("Queries");

        MtCreatorManager.packMT(mt111Creator);
    }

    //数据格式正确的测试方法。
    @Test
    public void MT111_TEST_2() {
        MT111Creator mt111Creator = new MT111Creator("111");
        //20
        mt111Creator.setSendersReference("SendersReference");
        //21
        mt111Creator.setChequeNumber("ChequeNumber");
        //30
        mt111Creator.setDateOfIssue("201231");
        //32a B
        DcDateCurAmtTagXXX amount = new DcDateCurAmtTagXXX("32");
        amount.setCurrency("CNY");
        amount.setAmount(new BigDecimal("20000.99"));
        mt111Creator.setAmount(amount);
        //52a B
        ActnoBicAdrTagXXX drawerBank = new ActnoBicAdrTagXXX("52");
        drawerBank.setInfo("D");
        drawerBank.setPartyIdentifier("52B_PartyIdentifier");
        drawerBank.setLocation("52B_Location");
        mt111Creator.setDrawerBank(drawerBank);

        MtCreatorManager.packMT(mt111Creator);
    }

    //数据格式正确的测试方法。
    @Test
    public void MT111_TEST_3() {
        MT111Creator mt111Creator = new MT111Creator("111");
        //20
        mt111Creator.setSendersReference("SendersReference");
        //21
        mt111Creator.setChequeNumber("ChequeNumber");
        //30
        mt111Creator.setDateOfIssue("201231");
        //32a B
        DcDateCurAmtTagXXX amount = new DcDateCurAmtTagXXX("32");
        amount.setCurrency("CNY");
        amount.setAmount(new BigDecimal("20000.99"));
        mt111Creator.setAmount(amount);
        //52a D
        ActnoBicAdrTagXXX drawerBank = new ActnoBicAdrTagXXX("52");
        drawerBank.setInfo("D");
        drawerBank.setPartyIdentifier("52D_PartyIdentifier");
        drawerBank.setAddress("52D_Address\r\nAddress2");
        mt111Creator.setDrawerBank(drawerBank);

        MtCreatorManager.packMT(mt111Creator);
    }

    //数据格式错误的测试方法。
    @Test
    public void MT111_TEST_4() {
        MT111Creator mt111Creator = new MT111Creator("111");
        //20 字段过长
        mt111Creator.setSendersReference("12345678902234567890");
        //21 字段过长
        mt111Creator.setChequeNumber("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        //30 字段过长
        mt111Creator.setDateOfIssue("20201231");
        //32a A
        DcDateCurAmtTagXXX amount = new DcDateCurAmtTagXXX("32");
        //date字段过长
        amount.setDate("20220101");
        //currency出现非字母字符
        amount.setCurrency("123");
        amount.setAmount(new BigDecimal("10000.00"));
        mt111Creator.setAmount(amount);
        //52a A
        ActnoBicAdrTagXXX drawerBank = new ActnoBicAdrTagXXX("52");
        drawerBank.setInfo("ABCD");
        drawerBank.setPartyIdentifier("52A_PartyIdentifier");
        //BIC格式错误
        drawerBank.setBic("12345678901");
        mt111Creator.setDrawerBank(drawerBank);
        //59
        ActnoBicAdrTagXXX payee = new ActnoBicAdrTagXXX("59", "111");
        //address换行过多
        payee.setAddress("A\r\nd\r\nd\r\nr\r\ne\r\ns\r\ns");
        mt111Creator.setPayee(payee);
        //75 换行过多
        mt111Creator.setQueries("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n");

        MtCreatorManager.packMT(mt111Creator);
    }
}
