package cz.moneta.test.smoke.itp.ieandmwf;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.rest.RawRestRequest;
import org.junit.jupiter.api.Assertions;

import static cz.moneta.test.harness.annotations.Environment.*;

@TestScenario(name = "Smoke test GMC")
public class CallMWFAE1ToGMC {

    @TestCase(name = "Test GMC system with CRT_SERVER_PRINT", environments = {TST1, TST3, PPE, EDU})
    public void testCRT_SERVER_PRINT(Harness harness) {
        RawRestRequest.Response response = harness.withWso2()
                .prepareRequest()
                .withPath("/t/branch.cluster/IPE/CRT_SERVER_PRINT/001")
                .withHeader("Authorization", harness.tasks().wso2().authorization().getToken("DigitalchannelsSB_CBL"))
                .withHeader("activityId", harness.tasks().wso2().restRequest().getRandomId())
                .withHeader("requestId", harness.tasks().wso2().restRequest().getRandomId())
                .withPayload("{" +
                        " \"docType\" : \"PDF\"," +
                        " \"rptName\" : \"vcs://Runtime/Non-UFO/Central/SmokeTest/SmokeTestGMC.wfd\", " +
                        " \"rptData\" : \"\\\"<RptData>" +
                        "  <PREDSMLUVNI_INFORMACE>" +
                        "    <SPOTREBITELSKY_UVER>" +
                        "      <VYSE_UVERU>200000</VYSE_UVERU>" +
                        "      <DOBA_TRVANI>108</DOBA_TRVANI>" +
                        "      <CELKOVA_CASTKA>343001.67</CELKOVA_CASTKA>" +
                        "      <SPLATKY>" +
                        "        <ANUITNI_SPLATKA>3410.42</ANUITNI_SPLATKA>" +
                        "        <POSLEDNI_MESICNI_SPLATKA>3410.42</POSLEDNI_MESICNI_SPLATKA>" +
                        "        <DATUM_SPLATKY>20</DATUM_SPLATKY>" +
                        "      </SPLATKY>" +
                        "      <NAKLADY>" +
                        "        <UROKOVA_SAZBA>13.2</UROKOVA_SAZBA>" +
                        "        <RPSN>14.02</RPSN>" +
                        "      </NAKLADY>" +
                        "      <SANKCNI_UROK>10</SANKCNI_UROK>" +
                        "    </SPOTREBITELSKY_UVER>" +
                        "    <PLATNOST_INFORMACI>29.09.2019</PLATNOST_INFORMACI>" +
                        "    <ZPROSTREDKOVATEL>" +
                        "      <PROMOTER_ID></PROMOTER_ID>" +
                        "      <OBCHODNI_FIRMA></OBCHODNI_FIRMA>" +
                        "      <ULICE></ULICE>" +
                        "      <CP></CP>" +
                        "      <PSC></PSC>" +
                        "      <MESTO></MESTO>" +
                        "      <TELEFON></TELEFON>" +
                        "      <EMAIL></EMAIL>" +
                        "     <IC></IC>" +
                        "      <ZAPSANA></ZAPSANA>" +
                        "      <ODDIL></ODDIL>" +
                        "      <VLOZKA></VLOZKA>" +
                        "    </ZPROSTREDKOVATEL>" +
                        "    <DIGITALSIGNATUREIDENTITY>ICA - 10371259</DIGITALSIGNATUREIDENTITY>" +
                        "    <KANAL_PORIZENI>WEB_SALES</KANAL_PORIZENI>" +
                        "    <KLIENT>" +
                        "      <NOVY_KLIENT>1</NOVY_KLIENT>" +
                        "      <KLIENT_MFC_HIGH>0</KLIENT_MFC_HIGH>" +
                        "    </KLIENT>" +
                        "  </PREDSMLUVNI_INFORMACE>" +
                        "  <Podpisy>" +
                        "    <S_PODPISOVA_POLE_BANKER>" +
                        "      <ARRAY-BANKER>" +
                        "        <BANKER>" +
                        "          <RS_TYP_PODPISU>C</RS_TYP_PODPISU>" +
                        "          <DIGITALSIGNATUREIDENTITY>ICA - 10371259</DIGITALSIGNATUREIDENTITY>" +
                        "        </BANKER>" +
                        "      </ARRAY-BANKER>" +
                        "    </S_PODPISOVA_POLE_BANKER>" +
                        "    <S_PODPISOVA_POLE_KLIENT>" +
                        "      <ARRAY-KLIENT>" +
                        "        <KLIENT>" +
                        "          <RS_TYP_PODPISU>S</RS_TYP_PODPISU>" +
                        "          <RS_ZPUSOB_PODEPISOVANI>Mobilní klíč (nešifrovaný SMS)</RS_ZPUSOB_PODEPISOVANI>" +
                        "          <RS_OSOBA_JMENO>Jakub</RS_OSOBA_JMENO>" +
                        "          <RS_OSOBA_PRIJMENI>Testovací</RS_OSOBA_PRIJMENI>" +
                        "          <RS_ID_PODPISU>12345</RS_ID_PODPISU>" +
                        "          <RS_CASOVE_RAZITKO>25.09.2019 13:10:32</RS_CASOVE_RAZITKO>" +
                        "        </KLIENT>" +
                        "      </ARRAY-KLIENT>" +
                        "    </S_PODPISOVA_POLE_KLIENT>" +
                        "  </Podpisy>" +
                        "</RptData>\\\"\"" +
                        "}")
                .post()
                .andAssertStatus(200);

        Assertions.assertNotNull(response.extract("documentURL"));

        harness.log("URL dokumentu: " + response.extract("documentURL"));
    }
}