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

import cz.moneta.test.dsl.Harness;
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 cz.moneta.test.sanity.transactional.cards.firstvision.Embosser;
import org.junit.jupiter.api.BeforeAll;

@TestScenario(name = "CARD_DELIVERY_TRACK_STATUS")
public class Delivery {
    private String mailingId;
    private String account;
    private String card;
    private SmokeData smokeData;

    @BeforeAll
    public void getInfo(Harness harness) {
        smokeData = SmokeData.getInstance(harness);
        account = smokeData.getCreditData().getAccount();
        card = smokeData.getCreditData().getCard();
        mailingId = Embosser.getEmbosser(harness, "E8V7B", card).extract("VMX_ROOT.VMX_MSGOUT.USER_3").textValue();
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T2429")
    public void MWFDN7GetCardDeliveryTrackList(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFDN7"))
                .addField("MailingID", mailingId)
                .postExtended()
                .andAssertStatus(200)
                .andAssertPresent("Data")
                .andAssertFieldValue("Data[0].DuvodVraceni", "3") //ADDRESSEE_NOT_FOUND
                .andAssertFieldValue("Data[0].StavDodani", "1") //ON_THE_WAY_TO_BRANCH
                .andAssertFieldValue("Data[0].IDMail", mailingId)
                .andAssertFieldValue("Data[0].CisloKaretnihoUctu", account)
                .andAssertFieldValue("Data[0].CisloPK", card.substring(3));
    }
}
