package com.brilliance.isc.json2mx.camt02900109;

import com.brilliance.isc.swift.objmtconvert.ext.XmlDate;
import com.brilliance.isc.swift.objmtconvert.manager.CreatorManager;
import com.brilliance.isc.swift.objmtconvert.model.mx.camt02900109.MXCamt02900109Creator;
import com.brilliance.isc.swift.objmtconvert.model.mx.common.*;
import com.brilliance.isc.swift.objmtconvert.result.MxResult;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zh
 * @create 2023-04-23-16:56
 * camt02900109(MT196,MT296)
 */
public class Camt02900109Test {

    @Test
    public void test_camt029() {
        MXCamt02900109Creator mxCamt02900109Creator = new MXCamt02900109Creator("camt.029.001.09");

        mxCamt02900109Creator.setSenderBic("PSBCCNBJ");

        mxCamt02900109Creator.setSenderNm("zs");

        mxCamt02900109Creator.setReceiverBic("PSBCCNBJ");

        mxCamt02900109Creator.setReceiverNm("lisi");

//        bizMsgIdr为系统自动生成，如果需要手动给值也可
//        String bizMsgIdr = "1111111";
//        mxPacs00900108COVCreator.setBizMsgIdr(bizMsgIdr);
        mxCamt02900109Creator.setMsgDefIdr("swift.cbprplus.02");

        mxCamt02900109Creator.setBizSvc("dadad");

        mxCamt02900109Creator.setCreDt(new XmlDate());

        mxCamt02900109Creator.setCreDtTm(new XmlDate());

        Othr othr = new Othr();
        othr.setId("adadsds");

        Agent agt = new Agent();
        FinInstnId finInstnId = new FinInstnId();
        PstlAdr pstlAdr = new PstlAdr();
        finInstnId.setBicfi("PSBCCNBJ");
//        finInstnId.setNm("zhaoliu");
//        finInstnId.setLei("11111111111111111111");
        List<String> list = new ArrayList<>();
        list.add("BIODATA GMBH");
        list.add("HOCHSTRASSE, 27");
        pstlAdr.setCtry("CN");
        pstlAdr.setBldgNb("111");
        pstlAdr.setBldgNm("ti mi");
        pstlAdr.setDept("xiao shan");
        pstlAdr.setCtrySubDvsn("tiger");
        pstlAdr.setDstrctNm("zzz");
        pstlAdr.setFlr("2");
        pstlAdr.setPstBx("40000");
        pstlAdr.setPstCd("103");
        pstlAdr.setRoom("103");
        pstlAdr.setStrtNm("xiao li Street");
        pstlAdr.setTwnLctnNm("xiao xiao");
        pstlAdr.setTwnNm("xiao xiao");
        pstlAdr.setAdrLine(list);
//        finInstnId.setPstlAdr(pstlAdr);
        agt.setFinInstnId(finInstnId);

        Party pty = new Party();
        pty.setNm("tianqi");
        pty.setPstlAdr(pstlAdr);
        IdentificationPty identificationPty = new IdentificationPty();
        OrgId orgId = new OrgId();
        identificationPty.setOrgId(orgId);
        orgId.setLei("11111111111111111111");
        orgId.setAnyBIC("PSBCCNBJ");
        List<Othr> othrList = new ArrayList<>();
        othrList.add(othr);
        orgId.setOthr(othrList);
        pty.setId(identificationPty);

        mxCamt02900109Creator.setAssgnrAgt(agt);

        mxCamt02900109Creator.setAssgneAgt(agt);

        mxCamt02900109Creator.setConf("CNCL");

        mxCamt02900109Creator.setCxlStsId("ddadads");

        RslvdCase rslvdCase = new RslvdCase();
        rslvdCase.setId("dasdasd");
        Cretr cretr = new Cretr();
        cretr.setAgt(agt);
        rslvdCase.setCretr(cretr);
        mxCamt02900109Creator.setRslvdCase(rslvdCase);

        mxCamt02900109Creator.setOrgnlMsgId("dasdsaddaaa");

        mxCamt02900109Creator.setOrgnlMsgNmId("pacs.008.001");

        mxCamt02900109Creator.setOrgnlCreDtTm(new XmlDate());

        mxCamt02900109Creator.setOrgnlInstrId("dlajzmdjd");

        mxCamt02900109Creator.setOrgnlEndToEndId("lakolaksss");

        mxCamt02900109Creator.setOrgnlInstrId("ddlakjjj");

        mxCamt02900109Creator.setOrgnlClrSysRef("dljsiywq");

        mxCamt02900109Creator.setOrgtr(pty);

        mxCamt02900109Creator.setRsnCd("AGNT");

        List<String> addtlInfList = new ArrayList<>();
        addtlInfList.add("333");
        addtlInfList.add("444");
        mxCamt02900109Creator.setAddtlInf(addtlInfList);

        MxResult result = (MxResult) CreatorManager.pack(mxCamt02900109Creator);
        if (result.isSuccess())
            System.out.println(result.getMessage());
        else {
            System.out.println(result.getErrorInf());
        }
    }

    @Test
    public void test_Camt029_2(){
        MXCamt02900109Creator mxCamt02900109Creator = new MXCamt02900109Creator("camt.029.001.09");

        mxCamt02900109Creator.setSenderBic("NDEAFIHH");

        mxCamt02900109Creator.setReceiverBic("HELSFIHH");

        mxCamt02900109Creator.setBizMsgIdr("cmt056bizmsgidr-002");

        mxCamt02900109Creator.setMsgDefIdr("camt.056.001.08");

        mxCamt02900109Creator.setBizSvc("swift.cbprplus.02");

        mxCamt02900109Creator.setCreDt(new XmlDate());

        Agent assgnrAgt = new Agent();
        FinInstnId finInstnId = new FinInstnId();
        finInstnId.setBicfi("HELSFIHH");
        assgnrAgt.setFinInstnId(finInstnId);
        mxCamt02900109Creator.setAssgnrAgt(assgnrAgt);

        Agent assgneAgt = new Agent();
        FinInstnId finInstnId1 = new FinInstnId();
        finInstnId1.setBicfi("NDEAFIHH");
        assgneAgt.setFinInstnId(finInstnId1);
        mxCamt02900109Creator.setAssgneAgt(assgneAgt);

        mxCamt02900109Creator.setCreDtTm(new XmlDate());

        mxCamt02900109Creator.setConf("CNCL");

        mxCamt02900109Creator.setCxlStsId("CNCL-ID001");

        RslvdCase rslvdCase = new RslvdCase();
        rslvdCase.setId("CSE-001");
        Cretr cretr = new Cretr();
        Agent agent = new Agent();
        FinInstnId finInstnId2 = new FinInstnId();
        finInstnId2.setBicfi("RBOSGB2L");
        agent.setFinInstnId(finInstnId2);
        cretr.setAgt(agent);
        rslvdCase.setCretr(cretr);
        mxCamt02900109Creator.setRslvdCase(rslvdCase);

        mxCamt02900109Creator.setOrgnlMsgId("pacs8bizmsgidr01");

        mxCamt02900109Creator.setOrgnlMsgNmId("pacs.008.001.08");

        mxCamt02900109Creator.setOrgnlCreDtTm(new XmlDate());

        mxCamt02900109Creator.setOrgnlInstrId("pacs8bizmsgidr01");

        mxCamt02900109Creator.setOrgnlEndToEndId("pacs008EndToEndId-001");

        mxCamt02900109Creator.setUetr("8a562c67-ca16-48ba-b074-65581be6f001");

        Party orgtr = new Party();
        orgtr.setNm("Z Krediter");
        PstlAdr pstlAdr = new PstlAdr();
        pstlAdr.setStrtNm("Antinkatu 11");
        pstlAdr.setTwnNm("Pori");
        pstlAdr.setCtry("FI");
        orgtr.setPstlAdr(pstlAdr);
        mxCamt02900109Creator.setOrgtr(orgtr);

        mxCamt02900109Creator.setRsnCd("AGNT");

        MxResult result = (MxResult) CreatorManager.pack(mxCamt02900109Creator);
        if (result.isSuccess())
            System.out.println(result.getMessage());
        else {
            System.out.println(result.getErrorInf());
        }




    }



}
