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.MT190Creator;
import org.junit.Test;

import java.math.BigDecimal;

public class MT190Test {
    @Test
    public void MT190_Test() {
        MT190Creator mt190Creator = new MT190Creator("190");
        //20
        mt190Creator.setTransactionReferenceNumber("Transaction");
        //21
        mt190Creator.setRelatedReference("Related");
        //25
        mt190Creator.setAccountIdentification("Account");
        //32a
        DcDateCurAmtTagXXX dcDateCurAmtTag32a = new DcDateCurAmtTagXXX("32");
        dcDateCurAmtTag32a.setDate("201231");
        dcDateCurAmtTag32a.setCurrency("CNY");
        dcDateCurAmtTag32a.setAmount(new BigDecimal("1000"));
        mt190Creator.setValDateCurAmt(dcDateCurAmtTag32a);
        //52a
        ActnoBicAdrTagXXX actnoBicAdrTag52a = new ActnoBicAdrTagXXX("52");
        actnoBicAdrTag52a.setPartyIdentifier("PartyIdentifier");
        actnoBicAdrTag52a.setAddress("Ben\r\nCity\r\nProvince\r\nCountry");
        mt190Creator.setOrderingInstitution(actnoBicAdrTag52a);
        //71B
        mt190Creator.setDetailsOfCharges("Details\r\nof\r\nCharge");
        //72
        mt190Creator.setSenderToReceiverInformation("Sender\r\nto\r\nReceiver\r\nInformation");


        MtCreatorManager.packMT(mt190Creator);

    }

    //数据格式正确的测试方法。
    @Test
    public void MT190_Test_1() {
        MT190Creator mt190Creator = new MT190Creator("190");
        //20
        mt190Creator.setTransactionReferenceNumber("TrnNum");
        //21
        mt190Creator.setRelatedReference("Related");
        //25
        mt190Creator.setAccountIdentification("AccountId");
        //32a C
        DcDateCurAmtTagXXX valDateCurAmt = new DcDateCurAmtTagXXX("32");
        valDateCurAmt.setDate("201231");
        valDateCurAmt.setCurrency("CNY");
        valDateCurAmt.setAmount(new BigDecimal("1000.99"));
        mt190Creator.setValDateCurAmt(valDateCurAmt);
        //52a A
        ActnoBicAdrTagXXX orderingInstitution = new ActnoBicAdrTagXXX("52");
        orderingInstitution.setBic("BKTRUS33XXX");
        orderingInstitution.setInfo("A");
        orderingInstitution.setPartyIdentifier("52A_PartyIdentifier");
        mt190Creator.setOrderingInstitution(orderingInstitution);
        //71B
        mt190Creator.setDetailsOfCharges("Details\r\nOf\r\nCharges");
        //72
        mt190Creator.setSenderToReceiverInformation("Sender\r\nTo\r\nReceiver\r\nInformation");

        MtCreatorManager.packMT(mt190Creator);
    }

    //数据格式正确的测试方法。
    @Test
    public void MT190_Test_2() {
        MT190Creator mt190Creator = new MT190Creator("190");
        //20
        mt190Creator.setTransactionReferenceNumber("TrnNum");
        //21
        mt190Creator.setRelatedReference("Related");
        //25
        mt190Creator.setAccountIdentification("AccountId");
        //32a D
        DcDateCurAmtTagXXX valDateCurAmt = new DcDateCurAmtTagXXX("32");
        valDateCurAmt.setDate("210101");
        valDateCurAmt.setCurrency("EUR");
        valDateCurAmt.setAmount(new BigDecimal("2000.99"));
        mt190Creator.setValDateCurAmt(valDateCurAmt);
        //52a D
        ActnoBicAdrTagXXX orderingInstitution = new ActnoBicAdrTagXXX("52");
        orderingInstitution.setAddress("52D_Address1\r\nAddress2");
        orderingInstitution.setInfo("D");
        orderingInstitution.setPartyIdentifier("52A_PartyIdentifier");
        mt190Creator.setOrderingInstitution(orderingInstitution);
        //71B
        mt190Creator.setDetailsOfCharges("Details\r\nOf\r\nCharges");
        //72
        mt190Creator.setSenderToReceiverInformation("Sender\r\nTo\r\nReceiver\r\nInformation");

        MtCreatorManager.packMT(mt190Creator);
    }

    //数据格式错误的测试方法。
    @Test
    public void MT190_Test_3() {
        MT190Creator mt190Creator = new MT190Creator("190");
        //20 字段超长
        mt190Creator.setTransactionReferenceNumber("TransactionReferenceNumber");
        //21 字段超长
        mt190Creator.setRelatedReference("12345678902234567890");
        //25 换行过多
        mt190Creator.setAccountIdentification("Account\r\nId");
        //32a C
        DcDateCurAmtTagXXX valDateCurAmt = new DcDateCurAmtTagXXX("32");
        //Date格式错误
        valDateCurAmt.setDate("20001231");
        valDateCurAmt.setCurrency("CNY");
        valDateCurAmt.setAmount(new BigDecimal("1000.99"));
        mt190Creator.setValDateCurAmt(valDateCurAmt);
        //52a A
        ActnoBicAdrTagXXX orderingInstitution = new ActnoBicAdrTagXXX("52");
        //BIC格式错误
        orderingInstitution.setBic("12345678901");
        orderingInstitution.setInfo("A");
        orderingInstitution.setPartyIdentifier("52A_PartyIdentifier");
        mt190Creator.setOrderingInstitution(orderingInstitution);
        //71B 换行过多
        mt190Creator.setDetailsOfCharges("Details\r\nOf\r\nCharges\r\nDetails\r\nOf\r\nCharges\r\n");
        //72 换行过多
        mt190Creator.setSenderToReceiverInformation("Sender\r\nTo\r\nReceiver\r\nInformation\r\n" +
                "Sender\r\nTo\r\nReceiver\r\nInformation\r\n" +
                "Sender\r\nTo\r\nReceiver\r\nInformation\r\n");

        MtCreatorManager.packMT(mt190Creator);
    }
}
