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

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 java.util.Random;

import static cz.moneta.test.sanity.transactional.cards.firstvision.MESSAGE.*;

@TestScenario(name = "updates credit limit on card")
public class CreditLimitUpd {

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T3102")
    public void VMX_CMS_CREDITLIMIT_UPD_EMEA(Harness harness) {
        String account = SmokeData.getInstance(harness).getCreditData().getAccount();
        int newLimit = new Random().nextInt(10000);
        harness.withWso2()
                .prepareRequest()
                .withPath(FV)
                .withPojoPayload(new MESSAGE("VMX.CMS.CREDITLIMIT.UPD.EMEA", "E8V2"))
                .addField(VMX_MSGIN, "ACCOUNT", account)
                .addField(VMX_MSGIN, "CRLIM", newLimit)
                .addField(VMX_MSGIN, "RESET_HOLD_AMT", "0")
                .postExtended()
                .andAssertFieldValue(SVC_RETURN, "P")
                .andAssertFieldValue(VMX_MSGOUT + ".CRLIM", newLimit + "");
    }
}
