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 = "DO_CARD_SERV_ADJUST_DATA")
public class CardLimits {
    private SmokeData smokeData;
    private String card;

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

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1960")
    public void MWFH02_DO_CARD_SERV_ADJUST_DATA(Harness harness) {
        //TODO  not changing limit
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFH02"))
                .addField("CisloKarty", card)
                .addField("LimitBankomat", 7000)
                .addField("LimitMOTOInternet", 8000)
                .addField("LimitObchodnik", 9000)
                .postExtended()
                .andAssertStatus(200);
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T2428")
    public void MWFDB8_DO_CARD_AUTHORIZATION(Harness harness) {
        String amount = new Random().nextInt(100) + "";
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFDB8"))
                .addField("CARDNUMBER", card)
                .addField("AMOUNT", amount)
                .addField("TRANSACTIONTYPE", 0)
                .addField("CARDEXPIRYDATE", "2310")
                .postExtended()
                .andAssertStatus(200)
                .andAssertFieldValue("CARDNUMBER", card)
                .andAssertFieldValue("AMOUNT", amount)
                .andAssertPresent("RESULT")
                .andAssertPresent("RESPONSECODE");
    }
}
