package cz.moneta.test.sanity.transactional.cards.wso2.pilotwso2;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.wso2.data.CardData;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.sanity.transactional.SmokeData;
import org.junit.jupiter.api.BeforeAll;

@TestScenario(name = "CardPctTable")
public class PctTable {
    private String card;
    private String contract;
    private SmokeData smokeData;

    @BeforeAll
    public void getInfo(Harness harness) {
        smokeData = SmokeData.getInstance(harness);
        CardData creditData = smokeData.getCreditData();
        card = creditData.getCard();
        contract = creditData.getContract();
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1975")
    public void MWFJY9GetPctTable(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFJY9"))
                .addField("CisloKarty", card)
                .postExtended()
                .andAssertStatus(200)
                .andAssertPresent("PCTTabulkaNaKarte")
                .extract("PCTTabulkaNaKarte").textValue();
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1935")
    public void MWF427GetPctTableByContrNumber(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromNas(smokeData.getPath("MWF427"))
                .addField("ContractNumber", contract)
                .postExtended()
                .andAssertStatus(200)
                .andAssertPresent("IssuanceId")
                .andAssertPresent("ResidenceId")
                .andAssertPresent("PctId");
    }
}
