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 = "ClientInfo")
public class ClientInfo {
    private String cif;
    private String bu;
    private String rc;
    private String card;
    private SmokeData smokeData;

    @BeforeAll
    public void getInfo(Harness harness) {
        smokeData = SmokeData.getInstance(harness);
        CardData creditData = smokeData.getCreditData();
        cif = creditData.getCif();
        bu = creditData.getBu();
        rc = creditData.getRc();
        card = creditData.getCard();
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T2436")
    public void MWFN03DealGetList(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFN03"))
                .addField("CIF", cif)
                .addField("ID_Osoba", rc)
                .postExtended()
                .andAssertStatus(200)
                .andAssertFieldValue("Data[0].CisloUctu", bu);
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1959")
    public void MWFGA4GetContactAllAddress(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFGA4"))
                .addField("CIF", cif)
                .postExtended()
                .andAssertStatus(200)
                .andAssertPresent("Data")
                .andAssertPresent("Data[0].Mesto")
                .andAssertPresent("Data[0].PSC")
                .andAssertPresent("Data[0].Ulice")
                .andAssertPresent("Data[0].Zeme")
                .andAssertPresent("Data[0].Posta")
                .andAssertPresent("Data[0].CisloOrientacni")
                .andAssertPresent("Data[0].CisloPopisne");
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T2430")
    public void MWFGA6GetContactAllPhoneEmail(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFGA6"))
                .addField("CIF", cif)
                .postExtended()
                .andAssertStatus(200)
                .andAssertPresent("Data")
                .andAssertPresent("Data[0].Email")
                .andAssertPresent("Data[0].Telefon")
                .andAssertPresent("Data[0].TelefonPredvolba")
                .andAssertPresent("Data[0].TelefonTyp")
                .andAssertPresent("Data[0].SystemID");
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1966")
    public void MWFIW3GetMassCardBlockPhoneNum(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromWps(smokeData.getPath("MWFIW3"))
                .addField("CardNumber", card)
                .postExtended()
                .andAssertStatus(200)
                .andAssertPresent("MobilePhone")
                .andAssertPresent("MobilePhone[0]");
    }
}
