package com.brilliance.isc.convert.other;

import com.brilliance.isc.swift.swifteditor.tag.message.MessageAnalyzer;
import com.brilliance.isc.swift.swifteditor.tag.message.SWFMessage;
import com.brilliance.isc.swift.objmtconvert.manager.MtCreatorManager;
import com.brilliance.isc.swift.objmtconvert.model.commontag.ActnoBicAdrTagXXX;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;
import com.brilliance.isc.swift.objmtconvert.util.JsonUtil;
import org.junit.Test;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author gechengyang
 * @date 2023/2/14
 */
public class Obj2MtTest {


    /***
     * 保函涉及60 767 768
     * MT760 保函开立报文
     * MT761 保函开立报文，对MT760内容进行补充、
     * MT775保函修改报文，对MT767内容进行补充的延续报文
     * MT765保函/备证项下的对外索赔报文
     * MT768 确认收妥
     * MT769 通知担保减额或解除责任
     * MT785通知保函/备证不再展期
     * MT786拒付报文
     * MT787保函/备证修改回复电

     */



/**
 *@Author: hedonghao
 *@Date: 2023/2/22
 *@Description: 51A测试
 */
    @Test
    public void mt700_51A() {
        Map map = new mt700TestMap().mapUtil();

        //51A 包含bic [/1!a][/34x]        PartyIdentifier  4!a2!a2!c[3!c]
        ActnoBicAdrTagXXX actnoBicAdrTag51aX = new ActnoBicAdrTagXXX("51");
        actnoBicAdrTag51aX.setInfo("A");
        actnoBicAdrTag51aX.setBic("WHYHCNHBXXX");
        actnoBicAdrTag51aX.setPartyIdentifier("1234-5678");

        map.put("actnoBicAdrTag51a", actnoBicAdrTag51aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());

    }

    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 51D测试
     */
    @Test
    public void mt700_51D() {
        Map map = new mt700TestMap().mapUtil();

        //51D 包含adress 4*35x        PartyIdentifier  4!a2!a2!c[3!c]
        ActnoBicAdrTagXXX actnoBicAdrTag51aX = new ActnoBicAdrTagXXX("51");
        actnoBicAdrTag51aX.setInfo("A");
        actnoBicAdrTag51aX.setPartyIdentifier("1234-5678");
        actnoBicAdrTag51aX.setAddress("地点：中国\r\n湖北省\r\n武汉市");

        map.put("actnoBicAdrTag51a", actnoBicAdrTag51aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }

    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 41A测试
     */
    @Test
    public void mt700_41A() {
        Map map = new mt700TestMap().mapUtil();

        //41A 包含BIC 4!a2!a2!c[3!c]        CODE  14x
        ActnoBicAdrTagXXX actnoBicAdrTag41aX = new ActnoBicAdrTagXXX("41");
        actnoBicAdrTag41aX.setBic("TEST41AA");
        actnoBicAdrTag41aX.setCode("THISIS41A");
        map.put("actnoBicAdrTag41a", actnoBicAdrTag41aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }
    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 41D测试
     */
    @Test
    public void mt700_41D() {
        Map map = new mt700TestMap().mapUtil();

        //41D 包含ADRESS 4*35x        CODE  14x
        ActnoBicAdrTagXXX actnoBicAdrTag41aX = new ActnoBicAdrTagXXX("41");
        actnoBicAdrTag41aX.setAddress("地点：中国\r\n湖北省\r\n武汉市");
        actnoBicAdrTag41aX.setCode("THISIS41D");
        map.put("actnoBicAdrTag41a", actnoBicAdrTag41aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }
    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 42A测试
     */
    @Test
    public void mt700_42A() {
        Map map = new mt700TestMap().mapUtil();

        //42A Party Identifier [/1!a][/34x]        BIC  4!a2!a2!c[3!c]
        ActnoBicAdrTagXXX actnoBicAdrTag42aX = new ActnoBicAdrTagXXX("42");
        actnoBicAdrTag42aX.setInfo("/A");
        actnoBicAdrTag42aX.setPartyIdentifier("/thisis42a");
        actnoBicAdrTag42aX.setBic("THISIS42A");
        map.put("actnoBicAdrTag42a", actnoBicAdrTag42aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }
    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 42D测试
     */
    @Test
    public void mt700_42D() {
        Map map = new mt700TestMap().mapUtil();

        //42D Party Identifier [/1!a][/34x]        ADRESS 4*35x
        ActnoBicAdrTagXXX actnoBicAdrTag42aX = new ActnoBicAdrTagXXX("42");
        actnoBicAdrTag42aX.setInfo("/A");
        actnoBicAdrTag42aX.setPartyIdentifier("/thisis42a");
        actnoBicAdrTag42aX.setAddress("THISIS42A\r\nbicis2222");
        map.put("actnoBicAdrTag42a", actnoBicAdrTag42aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }
    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 58A测试
     */
    @Test
    public void mt700_58A() {
        Map map = new mt700TestMap().mapUtil();

        //58A Party Identifier [/1!a][/34x]        bic 4!a2!a2!c[3!c]
        ActnoBicAdrTagXXX actnoBicAdrTag58aX = new ActnoBicAdrTagXXX("58");
        actnoBicAdrTag58aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag58aX.setAddress("CNBANKWHLOCAL");
        map.put("actnoBicAdrTag58a", actnoBicAdrTag58aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }
    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 58D测试
     */
    @Test
    public void mt700_58D() {
        Map map = new mt700TestMap().mapUtil();

        //58D Party Identifier [/1!a][/34x]        ADRESS 4*35x
        ActnoBicAdrTagXXX actnoBicAdrTag58aX = new ActnoBicAdrTagXXX("58");
        actnoBicAdrTag58aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag58aX.setAddress("JXLC-E3-1-602\r\nJYGY");
        map.put("actnoBicAdrTag58a", actnoBicAdrTag58aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }

    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 53A测试
     */
    @Test
    public void mt700_53A() {
        Map map = new mt700TestMap().mapUtil();

        //53A Party Identifier [/1!a][/34x]        BIC 4!a2!a2!c[3!c]
        ActnoBicAdrTagXXX actnoBicAdrTag53aX = new ActnoBicAdrTagXXX("53");
        actnoBicAdrTag53aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag53aX.setBic("TESTTEST");
        map.put("actnoBicAdrTag53a", actnoBicAdrTag53aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }

    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 53D测试
     */
    @Test
    public void mt700_53D() {
        Map map = new mt700TestMap().mapUtil();

        //53D Party Identifier [/1!a][/34x]        ADRESS 4*35x
        ActnoBicAdrTagXXX actnoBicAdrTag53aX = new ActnoBicAdrTagXXX("53");
        actnoBicAdrTag53aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag53aX.setAddress("TESTTEST");
        map.put("actnoBicAdrTag53a", actnoBicAdrTag53aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }
    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 57A测试
     */
    @Test
    public void mt700_57A() {
        Map map = new mt700TestMap().mapUtil();

        //57A Party Identifier [/1!a][/34x]        BIC 4!a2!a2!c[3!c]
        ActnoBicAdrTagXXX actnoBicAdrTag57aX = new ActnoBicAdrTagXXX("57");
        actnoBicAdrTag57aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag57aX.setBic("TESTTEST");
        map.put("actnoBicAdrTag57a", actnoBicAdrTag57aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }

    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 57B测试
     */
    @Test
    public void mt700_57B() {
        Map map = new mt700TestMap().mapUtil();

        //57B Party Identifier [/1!a][/34x]        LOCATION [35x]
        ActnoBicAdrTagXXX actnoBicAdrTag57aX = new ActnoBicAdrTagXXX("57");
        actnoBicAdrTag57aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag57aX.setLocation("TESTTEST");
        map.put("actnoBicAdrTag57a", actnoBicAdrTag57aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }

    /**
     *@Author: hedonghao
     *@Date: 2023/2/22
     *@Description: 57D测试
     */
    @Test
    public void mt700_57D() {
        Map map = new mt700TestMap().mapUtil();

        //57D Party Identifier [/1!a][/34x]        ADRESS 4*35x
        ActnoBicAdrTagXXX actnoBicAdrTag57aX = new ActnoBicAdrTagXXX("57");
        actnoBicAdrTag57aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag57aX.setAddress("TESTTEST");
        map.put("actnoBicAdrTag57a", actnoBicAdrTag57aX);

        String json = JsonUtil.toJson(map);
        MtResult mtResult = MtCreatorManager.packMt(json);
        System.out.println(mtResult.getMessage());
    }

    @Test
    public void mt700_Test() {
        Map map = new HashMap();
        map.put("msgType", "700");//报文类型
        map.put("sequenceofTotal", "1/1");
        map.put("formofDocumentaryCredit", "0716");
        map.put("documentaryCreditNumber", "LC00001TEST");
        map.put("dateOfIssue", "202303");
        map.put("applicableRules","TESTAPPRULES");
        map.put("dateAndPlaceOfExpiry", "239514DZJ");
        map.put("applicant", "LXZJZ\r\nBANK001\r\nPC777\r\nSWITCH0132");
        map.put("beneficiary", "LEGION11\r\nSUMSUNGS12\r\nAPPLE14\r\nGIVE_ME");
        map.put("pcentgeCrdtAmntTolrance","99/55");
        map.put("currencyCodeAmount", "GFD15DcCode");
        map.put("confirmationInstructions", "DDZZJJJ");
        //非必选项
        map.put("referencetoPreAdvice","this is tag23");
        map.put("pcentgeCrdtAmntTolrance","39/39");
        map.put("additionalAmountsCovered","this is 39C\r\ntest39Csuccess");
        map.put("draftsAt","BK100203\r\nAN3226621");
        map.put("mixedPaymentDetails","20230222 OUTPUT 16￥");
        map.put("negtionDfredPaymentDetail","tag42P\r\n延期付款1周，费用100万￥");
        map.put("partialShipments","仓库现金装运深圳");
        map.put("transhipment","尝试用船运载具");
        map.put("placeOfTakInChargTranDeli","接收地点：京海市/发送地点：武汉/收货地点：新晨科技");
        map.put("portOfLoading","装货港：维多利亚港口/出发机场：武汉天河机场");
        map.put("portOfDischarge","卸货港口：上海入港口/目的机场：北京大兴机场");
        map.put("placeOfFinalDestination","最终目的：潜江/运输至：曹禺公园/交货地点：总口");
        map.put("latestDateOfShipment","最迟装运日期：2023.3.15");
        map.put("shipmentPeriod","装运日期：2023.3.6");
        map.put("descOfGoodsAndServ","服务说明：cash");
        map.put("documentsRequired","所需文件：进关批文");
        map.put("additionalConditions","附加条件：超出距离加钱");
        map.put("specPaymentCondForBenefi","收款行特殊付款条件：房屋抵押");
        map.put("charges","36000000￥");
        map.put("periodForPresentaInDays","提交期限：2023.12.30");

        map.put("recvBic", "CIPSCNSHXXX");//收报行
        map.put("sendBic", "PSBCCNBJXXX");//发报行

        //58
        ActnoBicAdrTagXXX actnoBicAdrTag58aX = new ActnoBicAdrTagXXX("58");
        actnoBicAdrTag58aX.setPartyIdentifier("CNBANKWHLOCAL");
        actnoBicAdrTag58aX.setAddress("JXLC-E3-1-602\r\nJYGY");
        map.put("actnoBicAdrTag58a", actnoBicAdrTag58aX);

        //51
        ActnoBicAdrTagXXX actnoBicAdrTag51aX = new ActnoBicAdrTagXXX("51");
        actnoBicAdrTag51aX.setInfo("A");
        actnoBicAdrTag51aX.setBic("WHYHCNHBXXX");
        actnoBicAdrTag51aX.setCode("test41a");
        actnoBicAdrTag51aX.setAcctno("6226TEST0001");
        actnoBicAdrTag51aX.setPartyIdentifier("1234-5678");
        map.put("actnoBicAdrTag51a", actnoBicAdrTag51aX);

        //41
        ActnoBicAdrTagXXX actnoBicAdrTag41aX = new ActnoBicAdrTagXXX("41");
        actnoBicAdrTag41aX.setAddress("DATE2023\r\nCOMPANY10F\r\nTO-BEIJING");
        //41A设置BIC
        actnoBicAdrTag41aX.setBic("TESTBICFOR4");
        //actnoBicAdrTag41aX.setCode("test41a");
        map.put("actnoBicAdrTag41a", actnoBicAdrTag41aX);

        //42
        ActnoBicAdrTagXXX actnoBicAdrTag42aX = new ActnoBicAdrTagXXX("42");
        actnoBicAdrTag42aX.setInfo("A");
        actnoBicAdrTag42aX.setPartyIdentifier("TEST42");
        actnoBicAdrTag42aX.setBic("CALLITTRA");
        //actnoBicAdrTag42aX.setAddress("GGGGGGG ");
        map.put("actnoBicAdrTag42a", actnoBicAdrTag42aX);

        //53
        ActnoBicAdrTagXXX actnoBicAdrTag53aX = new ActnoBicAdrTagXXX("53");
        actnoBicAdrTag53aX.setInfo("Z");
        actnoBicAdrTag53aX.setPartyIdentifier("TEST53");
        actnoBicAdrTag53aX.setAddress("TESTDDDDD");
   //     actnoBicAdrTag53aX.setBic("TESTAAAAA");
        // actnoBicAdrTag42aX.setAddress("GGGGGGG ");
        map.put("actnoBicAdrTag53a", actnoBicAdrTag53aX);

        //57
        ActnoBicAdrTagXXX actnoBicAdrTag57aX = new ActnoBicAdrTagXXX("57");
        actnoBicAdrTag57aX.setInfo("Z");
        actnoBicAdrTag57aX.setPartyIdentifier("TEST57");
        //actnoBicAdrTag53aX.setBic("TESTAAAAA");
        //actnoBicAdrTag57aX.setLocation("TESTBBBB");
        actnoBicAdrTag57aX.setAddress("TEST57DDDD\r\nxinchen\r\nkeji\r\n10flore");
        map.put("actnoBicAdrTag57a", actnoBicAdrTag57aX);

        String json = JsonUtil.toJson(map);

        /********以上为json参数**************/

        MtResult mtResult = MtCreatorManager.packMt(json);
        if (mtResult.isSuccess())
            System.out.println(mtResult.getMessage());
        else
            System.out.println(mtResult.getMessage());


    }


    @Test
    public void mt760_Test(){
        Map map = new HashMap();
        map.put("msgType","760");//报文类型
        //Sequence A
        map.put("newSequence","");//Empty field
        map.put("sequenceofTotal","1/1");//1!n/1!n
        map.put("purposeofMessage","ew22");//4!c
        //Sequence B
//        map.put("newSequenceB","");//Empty field
//        map.put("undertakingNumber","www2312");//16x
//        map.put("dateofIssue","655678");//6!n
//        map.put("formofUndertaking","qw12");//4!c
//        map.put("applicableRules","2233");//4!a[/35x]
//        map.put("expiryType","qw12");//4!c
//        map.put("undertakingAmount","wzh111,");//3!a15d
//        map.put("undertakingTermsandConditions","湖北");//150*65z
//        //Sequence C
//        map.put("newSequenceOfC","");//Empty field
//        map.put("formofUndertakingOfC","rere");//4!c
//        map.put("applicableRulesOfC","qqqq");//4!a[/35x]
//        map.put("expiryTypeOfC","eeee");//4!c
//        map.put("applicantOfC","dfewfwf");//4*35x
//        map.put("beneficiaryOfC","weffwe");//[/34x]<crlf>4*35x
//        map.put("undertakingAmountOfC","123");//3!a15d
//        map.put("underlyingTransactionDetailsOfC","efff");//50*65z
//
//        //非必选项
//        //Sequence A
//        map.put("sendertoReceiverInformation","新晨科技\n湖北\n武汉");//6*35z
//        map.put("fileIdentification","231r\tqwfq\nefwfe");//4!c/65x
//        //Sequence B
//        map.put("dateofExpiry","202302");//6!n
//        map.put("expiryConditionEvent","qweqweq");//12*65x
//        map.put("applicant","LXZJZ\nrwerw");//4*35x
//        map.put("obligorInstructingParty","fewgew\navev\neee");//4*35x
//        map.put("advisingBankReference","1111111");//16x
//        map.put("additionalAmountInformation","湖北武汉");//12*65z
//        map.put("charges","湖北武昌");//6*35z
//        map.put("documentandPresentationInstructions","124142");//100*65z
//        map.put("confirmationInstructions","wqewrty");//7!x
//        map.put("governingLawandorPlaceofJurisdiction","42342");//2!a[/65x]
//        map.put("automaticExtensionPeriod","34242");//4!a[/35x]
//        map.put("automaticExtensionNonExtensionNotification","42423");//12*65x
//        map.put("automaticExtensionNotificationPeriod","333");//3n
//        map.put("automaticExtensionFinalExpiryDate","333333");//6!n
//        map.put("demandIndicator","3434");//4!c
//        map.put("transferIndicator","234t");//4!c
//        map.put("transferConditions","242342");//12*65z
//        map.put("underlyingTransactionDetails","3423423");//50*65z
//        map.put("deliveryofOriginalUndertaking","4234234");//4!c[/35x]
//        //Sequence C
//        map.put("requestedDateofIssueOfC","333333");//6!n
//        map.put("typeofUndertakingOfC","etrt");//4!c[/35x]
//        map.put("dateofExpiryOfC","666666");//6!n
//        map.put("expiryConditionEventOfC","tntttn");//12*65x
//        map.put("obligorInstructingPartyOfC","ntnttn");//4*35x
//        map.put("additionalAmountInformationOfC","nytnynt");//12*65z
//        map.put("chargesOfC","ntynynt");//6*35z
//        map.put("documentandPresentationInstructionsOfC","ntynyytn");//100*65z
//        map.put("requestedLocalUndertakingTermsandConditionsOfC","ntynynt");//150*65z
//        map.put("standardWordingRequiredOfC","trt5");//4!c
//        map.put("standardWordingRequestedLanguageOfC","we");//2!a
//        map.put("governingLawandorPlaceofJurisdictionOfC","ee");//2!a[/65x]
//        map.put("automaticExtensionPeriodOfC","etrg");//4!a[/35x]
//        map.put("automaticExtensionNonExtensionNotificationOfC","rgeeg");//12*65x
//        map.put("automaticExtensionNotificationPeriodOfC","333");//3n
//        map.put("automaticExtensionFinalExpiryDateOfC","333333");//6!n
//        map.put("demandIndicatorOfC","rrrr");//4!c
//        map.put("transferIndicatorOfC","gggg");//4!c
//        map.put("transferConditionsOfC","rrrererr");//12*65z
//        map.put("deliveryofLocalUndertakingOfC","rrrr");//4!c[/35x]
//
//        //Sequence B
//        //52
//        ActnoBicAdrTagXXX actnoBicAdrTagB52a = new ActnoBicAdrTagXXX("52");
//        actnoBicAdrTagB52a.setPartyIdentifier("CNBANKWHLOCAL");//Party Identifier [/1!a][/34x]
//        actnoBicAdrTagB52a.setBic("TESTTEST");//52A BIC 4!a2!a2!c[3!c]
//        //actnoBicAdrTagB52a.setAddress("egrgrgr");//52D Address 4*35x
//        map.put("actnoBicAdrTagB52a", actnoBicAdrTagB52a);
//
//        //59
//        ActnoBicAdrTagXXX actnoBicAdrTagB59a = new ActnoBicAdrTagXXX("59");
//        actnoBicAdrTagB59a.setAcctno("fewfwwf");//Account [/34x]
//        actnoBicAdrTagB59a.setAddress("wqdqfq");//No letter option Address 4*35x
//        //actnoBicAdrTagB59a.setBic("fewfwef");//59A BIC 4!a2!a2!c[3!c]
//        map.put("actnoBicAdrTagB59a", actnoBicAdrTagB59a);
//
//        //56
//        ActnoBicAdrTagXXX actnoBicAdrTagB56a = new ActnoBicAdrTagXXX("56");
//        actnoBicAdrTagB56a.setPartyIdentifier("FWWAFGWEFEFE");//Party Identifier [/1!a][/34x]
//        actnoBicAdrTagB56a.setBic("EWRWTE");//56A BIC 4!a2!a2!c[3!c]
//        //actnoBicAdrTagB56a.setAddress("rtrtrt");//56D Address 4*35x
//        map.put("actnoBicAdrTagB56a", actnoBicAdrTagB56a);
//
//        //57
//        ActnoBicAdrTagXXX actnoBicAdrTagB57a = new ActnoBicAdrTagXXX("57");
//        actnoBicAdrTagB57a.setPartyIdentifier("TEST57");//Party Identifier [/1!a][/34x]
//        actnoBicAdrTagB57a.setBic("rwrwr");//57A BIC 4!a2!a2!c[3!c]
//        //actnoBicAdrTagB57a.setAddress("fff");//57D Address 4*35x
//        map.put("actnoBicAdrTagB57a", actnoBicAdrTagB57a);
//
//        //41
//        ActnoBicAdrTagXXX actnoBicAdrTagB41a = new ActnoBicAdrTagXXX("41");
//        actnoBicAdrTagB41a.setBic("rwrwr");//41F BIC 4!a2!a2!c[3!c]
//        //actnoBicAdrTagB41a.setAddress("fff");//41G Address 4*35x
//        map.put("actnoBicAdrTagB41a", actnoBicAdrTagB41a);
//
//        //58
//        ActnoBicAdrTagXXX actnoBicAdrTagB58a = new ActnoBicAdrTagXXX("58");
//        actnoBicAdrTagB58a.setPartyIdentifier("TTEEEE");//Party Identifier [/1!a][/34x]
//        actnoBicAdrTagB58a.setBic("EWRWTE");//58A BIC 4!a2!a2!c[3!c]
//        //actnoBicAdrTagB58a.setAddress("wwwwww");//58D Address 4*35x
//        map.put("actnoBicAdrTagB58a", actnoBicAdrTagB58a);
//
//        //24G
//        ActnoBicAdrTagXXX actnoBicAdrTagB24G =new ActnoBicAdrTagXXX("24");
//        actnoBicAdrTagB24G.setCode("wwww");//Code 4!c
//        actnoBicAdrTagB24G.setAddress("fafaf");//Address [6*35x]
//        map.put("actnoBicAdrTagB24G", actnoBicAdrTagB24G);
//
//        //Sequence C
//        //52
//        ActnoBicAdrTagXXX actnoBicAdrTagC52a = new ActnoBicAdrTagXXX("52");
//        actnoBicAdrTagC52a.setPartyIdentifier("CNBANKWHLOCAL");//Party Identifier [/1!a][/34x]
//        actnoBicAdrTagC52a.setBic("TESTTEST");//52A BIC 4!a2!a2!c[3!c]
//        //actnoBicAdrTagC52a.setAddress("egrgrgr");//52D Address 4*35x
//        map.put("actnoBicAdrTagC52a", actnoBicAdrTagC52a);
//
//        //41
//        ActnoBicAdrTagXXX actnoBicAdrTagC41a = new ActnoBicAdrTagXXX("41");
//        actnoBicAdrTagC41a.setBic("rwrwr");//41F BIC 4!a2!a2!c[3!c]
//        //actnoBicAdrTagC41a.setAddress("fff");//41G Address 4*35x
//        map.put("actnoBicAdrTagC41a", actnoBicAdrTagC41a);

        //24G
        ActnoBicAdrTagXXX actnoBicAdrTagC24G =new ActnoBicAdrTagXXX("24");
        actnoBicAdrTagC24G.setCode("wwww");//Code 4!c
        actnoBicAdrTagC24G.setAddress("fafaf");//Address [6*35x]
        map.put("actnoBicAdrTagC24G", actnoBicAdrTagC24G);


        map.put("recvBic", "CIPSCNSHXXX");//收报行
        map.put("sendBic", "PSBCCNBJXXX");//发报行



        String json = JsonUtil.toJson(map);

        /********以上为json参数**************/

        MtResult mtResult = MtCreatorManager.packMt(json);
        if (mtResult.isSuccess())
            System.out.println(mtResult.getMessage());
        else
            System.out.println(mtResult.getMessage());
    }
    @Test
    public void mt942_Test(){
        // 组报文

        Map map = new HashMap();
        map.put("msgType", "942");//报文类型
        map.put("tranReferenceNum", "tranReferenceNum");
        map.put("relatedReferen", "relatedReferen");
        map.put("stattNumSeqNum", "12345");
        map.put("dateIndication", "qwertyuioplkjhg");
        map.put("openBalance", "S123321REEDFDF");
        map.put("numSumEntrieD", "213ERWWER");
        map.put("numSumEntrieC", "213ERWWER");
        map.put("bookBalance", "S122233DFDFFF");
        map.put("infoAccontOwner", "ASDASDASD");

        //1!a6!n3!a15d
        LinkedList<Object> linkedList = new LinkedList<>();
        linkedList.add("A666666bbb");
        linkedList.add("A888888bbb");
        linkedList.add("A999999bbb");
        map.put("fowrdAvaBalnce",linkedList);

        ActnoBicAdrTagXXX actnoBicAdrTag25aX = new ActnoBicAdrTagXXX("25");
        actnoBicAdrTag25aX.setAcctno("why null");
        actnoBicAdrTag25aX.setBic("TESTTEST");
        map.put("actnoBicAdrTag25a", actnoBicAdrTag25aX);

        map.put("recvBic", "CIPSCNSHXXX");//收报行
        map.put("sendBic", "PSBCCNBJXXX");//发报行


        String json = JsonUtil.toJson(map);

        /********以上为json参数**************/

        MtResult mtResult=MtCreatorManager.packMt(json);


        if(mtResult.isSuccess())
            System.out.println(mtResult.getMessage());
        else
            System.out.println(mtResult.getMessage());
    }

    @Test
    public void mt970_Test(){
        // 组报文

        Map map = new HashMap();
        map.put("msgType", "942");//报文类型
        map.put("tranReferenceNum", "tranReferenceNum");
        map.put("accountIc", "accountIc");
        map.put("statNumSeqNum", "statNumSeqNum");
        map.put("closAvaBlan", "closAvaBlan");

        //1!a6!n3!a15d
        LinkedList<Object> linkedList = new LinkedList<>();
        linkedList.add("A666666bbb");
        linkedList.add("A888888bbb");
        linkedList.add("A999999bbb");
        map.put("statLine",linkedList);

        ActnoBicAdrTagXXX actnoBicAdrTag60aX = new ActnoBicAdrTagXXX("60");
        actnoBicAdrTag60aX.setAcctno("why null");
        actnoBicAdrTag60aX.setBic("TESTTEST");
        map.put("actnoBicAdrTag25a", actnoBicAdrTag60aX);

        map.put("recvBic", "CIPSCNSHXXX");//收报行
        map.put("sendBic", "PSBCCNBJXXX");//发报行


        String json = JsonUtil.toJson(map);

        /********以上为json参数**************/

        MtResult mtResult=MtCreatorManager.packMt(json);


        if(mtResult.isSuccess())
            System.out.println(mtResult.getMessage());
        else
            System.out.println(mtResult.getMessage());
    }
    @Test
    public void mt103_Test() {
        // 组报文

        Map map = new HashMap();
        map.put("msgType", "103");//报文类型

        map.put("sequenceofTotal", "1/1");
        map.put("formofDocumentaryCredit", "1111");
        map.put("documentaryCreditNumber", "LC00001TEST");
        map.put("recvBic","CIPSCNSHXXX");//收报行
        map.put("sendBic","PSBCCNBJXXX");//发报行



        //20
        map.put("SendersReference", "SendersReference");//Sender's Reference
        //13C
        map.put("TimeIndication", "TimeIndication");//Time Indication
        //23B
        map.put("BankOperationCode", "BankOperationCode");//Bank Operation Code
        //23E
        map.put("InstructionCode", "InstructionCode");//Instruction Code
        //26T
        map.put("TransactionTypeCode", "TransactionTypeCode");//Transaction Type Code
        //32A
        map.put("ValueDateCurrencyInterbankSettledAmount", "ValueDateCurrencyInterbankSettledAmount");//Value Date/Currency/Interbank Settled Amount
        //33B
        map.put("CurrencyInstructedAmount", "CurrencyInstructedAmount");//Currency/Instructed Amount
        //36
        map.put("ExchangeRate", "ExchangeRate");//Exchange Rate
        //50a
        ActnoBicAdrTagXXX actnoBicAdrTag50a=new ActnoBicAdrTagXXX("50");
        actnoBicAdrTag50a.setInfo("B");
//        actnoBicAdrTag50a.setBic("WHYHCNHBXXX");
        actnoBicAdrTag50a.setLocation("WHYHCNHBXXX");
        actnoBicAdrTag50a.setAcctno("6226TEST0001");
        actnoBicAdrTag50a.setPartyIdentifier("1234-5678");

        map.put("actnoBicAdr50a",actnoBicAdrTag50a);//Ordering Customer

        //51A
        map.put("SendingInstitution", "SendingInstitution");//Sending Institution

        //52a
        ActnoBicAdrTagXXX actnoBicAdrTag52a=new ActnoBicAdrTagXXX("52");
        actnoBicAdrTag52a.setInfo("D");
//        actnoBicAdrTag52a.setBic("WHYHCNHBXXX");
        actnoBicAdrTag52a.setAddress("WHYHCNHBXXX");
        actnoBicAdrTag52a.setAcctno("6226TEST0001");
        actnoBicAdrTag52a.setPartyIdentifier("1234-5678");
        map.put("actnoBicAdr52a", actnoBicAdrTag52a);//Ordering Institution

        //53a
        ActnoBicAdrTagXXX actnoBicAdrTag53a=new ActnoBicAdrTagXXX("53");
        actnoBicAdrTag53a.setInfo("A53a");
//        actnoBicAdrTag53a.setBic("WHYHCNHBXXX");
        actnoBicAdrTag53a.setAcctno("6226TEST0001");
        actnoBicAdrTag53a.setPartyIdentifier("6756-7657");
        map.put("actnoBicAdr53a", actnoBicAdrTag53a);//Sender's Correspondent
        //54a
        ActnoBicAdrTagXXX actnoBicAdrTag54a=new ActnoBicAdrTagXXX("54");
        actnoBicAdrTag54a.setInfo("54a");
        actnoBicAdrTag54a.setBic("WHYHCNHBXXX");
        actnoBicAdrTag54a.setAcctno("6226TEST0001");
        actnoBicAdrTag54a.setPartyIdentifier("5345-6756");
        map.put("actnoBicAdr54a", actnoBicAdrTag54a);//Receiver's Correspondent
        //55a
        ActnoBicAdrTagXXX actnoBicAdrTag55a=new ActnoBicAdrTagXXX("55");
        actnoBicAdrTag55a.setInfo("55a");
        actnoBicAdrTag55a.setBic("WHYHCNHBXXX");
        actnoBicAdrTag55a.setAcctno("6226TEST0001");
        actnoBicAdrTag55a.setPartyIdentifier("1234-5678");
        map.put("actnoBicAdr55a", actnoBicAdrTag55a);//Third Reimbursement Institution
        //56a
        ActnoBicAdrTagXXX actnoBicAdrTag56a=new ActnoBicAdrTagXXX("56");
        actnoBicAdrTag56a.setInfo("56a");
        actnoBicAdrTag56a.setBic("WHYHCNHRXXX");
        actnoBicAdrTag56a.setAcctno("6226TEST56450001");
        actnoBicAdrTag56a.setPartyIdentifier("5634-3534-7654-6543");
        map.put("actnoBicAdr56a", actnoBicAdrTag56a);//Intermediary Institution
        //57a
        ActnoBicAdrTagXXX actnoBicAdrTag57a=new ActnoBicAdrTagXXX("57");
        actnoBicAdrTag57a.setInfo("57a");
        actnoBicAdrTag57a.setBic("WHYHCNHDXXX");
        actnoBicAdrTag57a.setAcctno("6226TEST48890007");
        actnoBicAdrTag57a.setPartyIdentifier("3450-2432-4359-3535-5935-3523");
        map.put("actnoBicAdr57a", actnoBicAdrTag57a);//Account With Institution
        //59a
        ActnoBicAdrTagXXX actnoBicAdrTag59a=new ActnoBicAdrTagXXX("59");
        actnoBicAdrTag59a.setInfo("59a");
        actnoBicAdrTag59a.setBic("WHYHCNHHXXX");
        actnoBicAdrTag59a.setAcctno("6226TEST34530004");
        actnoBicAdrTag59a.setPartyIdentifier("4532-6545-5884");
        map.put("actnoBicAdr59a", actnoBicAdrTag59a);//Beneficiary Customer


        //70
        map.put("RemittanceInformation", "RemittanceInformation");//Remittance Information
        //71A
        map.put("DetailsofCharges", "DetailsofCharges");//Details of Charges
        //71F
        map.put("SendersCharges", "SendersCharges");//Sender's Charges
        //71G
        map.put("ReceiversCharges", "ReceiversCharges");//Receiver's Charges
        //72
        map.put("SendertoReceiverInformation", "SendertoReceiverInformation");//Sender to Receiver Information
        //77B
        map.put("RegulatoryReporting", "RegulatoryReporting");//Regulatory Reporting




        ActnoBicAdrTagXXX actnoBicAdrTag50X=new ActnoBicAdrTagXXX("51");
        actnoBicAdrTag50X.setInfo("A");
        actnoBicAdrTag50X.setBic("WHYHCNHBXXX");
        actnoBicAdrTag50X.setAcctno("6226TEST0001");
        actnoBicAdrTag50X.setPartyIdentifier("1234-5678");
        //这里的属性名actnoBicAdr51a 要和MT700Creator里面的属性保持一致
        map.put("actnoBicAdr51a",actnoBicAdrTag50X);
        String json = JsonUtil.toJson(map);



        /********以上为json参数**************/

        MtResult mtResult=MtCreatorManager.packMt(json);

        String str = mtResult.getMessage();
        SWFMessage swf = MessageAnalyzer.loadCheckSwiftMessage(str);

        swf.getMsgCheck("NYCBCNSH","ICBKGB2LAAAA");

//        if(mtResult.isSuccess())
//            System.out.println(mtResult.getMessage());
//        else
//            System.out.println(mtResult.getMessage());


    }


    @Test
    public void test() {
        String str = "love234csdnjava";
        String regEx = "[^0-9]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        String result = m.replaceAll("").trim();
        System.out.println(result);
        System.out.println(str);
    }
}

