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

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 org.junit.jupiter.api.BeforeAll;

import java.util.Random;

@TestScenario(name = "secure3D")
public class Secure3D {
    private String card;
    private String mobile;
    private SmokeData smokeData;

    @BeforeAll
    public void getInfo(Harness harness) {
        smokeData = SmokeData.getInstance(harness);
        card = smokeData.getCreditData().getCard();
        mobile = "420" + (100_000_000 + new Random().nextInt(899_999_999));
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T2786")
    public void MWFGR7_card_change_secure3D(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFGR7"))
                .addField("CARD_NUMBER", card)
                .addField("LOGO", "2713005")
                .addField("MOBILE_PHONE", mobile)
                .addField("CHG_3DSEC_PHONE", "1")
                .addField("CHG_REGISTER_CARD", "1")
                .addField("ORGANIZATION", "1")
                .postExtended()
                .andAssertStatus(200);
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T3143")
    public void MWF7D5_card_change_set_secure3D(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWF7D5"))
                .addField("CARD_NUMBER", card)
                .addField("CARD_LOGO", "2713005")
                .addField("MOBILE_PHONE", mobile)
                .postExtended()
                .andAssertStatus(200);
    }
}
