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 org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.BeforeAll;

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

@TestScenario(name = "VMX.MEMOS")
public class Memos {
    private String account;
    private String card;
    private String memo;

    @BeforeAll
    public void getInfo(Harness harness) {
        SmokeData data = SmokeData.getInstance(harness);
        account = data.getCreditData().getAccount();
        card = data.getCreditData().getCard();
        memo = RandomStringUtils.randomAlphabetic(10);
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1923")
    public void VMX_MEMO_ADD(Harness harness) {
        harness.withWso2()
                .prepareRequest()
                .withPath(FV)
                .withPojoPayload(new MESSAGE("VMX.MEMO.ADD", "E8V1"))
                .addField(VMX_MSGIN, "CARD_NBR", card)
                .addField(VMX_MSGIN, "ACCOUNT", account)
                .addField(VMX_MSGIN, "ACTN_CD", "BLAC")
                .addField(VMX_MSGIN, "MEMO_LINE_1", memo)
                .postExtended()
                .andAssertFieldValue(SVC_RETURN, "P");
    }

}
