package cz.moneta.test.regression.cvm.api.enterpriseitservices;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.regression.cvm.api.inegrationgov.ApiMWFAE1;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Call API CMH_SEND_LETTER to WSO2 and assert response parameters")
public class ApiCmhSendLetter {

    @TestCase(name = "Call API CMH_SEND_LETTER to WSO2", environments = {TST1, PPE})
    public void postCmhSendLetter(Harness harness) {
        final String documentURL = new ApiMWFAE1().getResponseOfCallMWFAE1(harness).extract("documentURL").textValue();

        harness.tasks().wso2().restRequest().prepareRequestFromCvm("enterpriseit.services/CMH_SEND_LETTER/001", true,
                "{\n" +
                        "    \"AdresaJmeno\": \"Bart Simpson\",\n" +
                        "    \"AdresaMesto\": \"Praha\",\n" +
                        "    \"AdresaPSC\": \"15400\",\n" +
                        "    \"AdresaPoznamka\": \"\",\n" +
                        "    \"AdresaUlice\": \"Ječná 67\",\n" +
                        "    \"AdresaZeme\": \"52\",\n" +
                        "    \"CisloSmlouvy\": \"\",\n" +
                        "    \"CisloUctu\": \"\",\n" +
                        "    \"CostCentrum\": \"CC2150\",\n" +
                        "    \"FormatDokumentu\": \"PDF\",\n" +
                        "    \"IDInstanceKlienta\": null,\n" +
                        "    \"IDSystemu\": \"\",\n" +
                        "    \"IDUnifikovanehoKlienta\": null,\n" +
                        "    \"LimitProDoruceni\": null,\n" +
                        "    \"PocetStranek\": 2,\n" +
                        "    \"PristupoveHeslo\": \"\",\n" +
                        "    \"Spolecnost\": \"GEMCB\",\n" +
                        "    \"StartWPS\": null,\n" +
                        "    \"TypOdeslani\": \"1\",\n" +
                        "    \"TypPrilohy\": \"\",\n" +
                        "    \"TypSablony\": null,\n" +
                        "    \"URIDokumentu\": \"" + documentURL + "\"\n" +
                        "}")
                .post()
                .andAssertStatus(200)
                .andAssertFieldValue("tifResponseStatus.resultCode", "0");
    }
}
