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

import com.fasterxml.jackson.annotation.JsonProperty;
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 lombok.Builder;
import lombok.Data;

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

@TestScenario(name = "R1 VMX.NON.MON.UPD E8V5")
public class NonMonetaryUpd {
    
    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1904")
    public void VMX_NONMON_UPD(Harness harness) {
        String accountInput = SmokeData.getInstance(harness).getCreditData().getAccount();
        MEMOS memos = MEMOS.builder()
                .memo1("some memo1")
                .memo2("another memo2")
                .build();
        harness.withWso2()
                .prepareRequest()
                .withPath(FV)
                .withPojoPayload(new MESSAGE("VMX.NONMON.UPD", "E8V5"))
                .addField(VMX_MSGIN, "ACCOUNT", accountInput)
                .addField(VMX_MSGIN, "ORG", "861")
                .addField(VMX_MSGIN, "ACTION_CODE", "BLAC")
                .addField(VMX_MSGIN, "REVIEW_DATE", "0")
                .addField(VMX_MSGIN, "REVIEW_TIME", "0")
                .addField(VMX_MSGIN, "CARD_SEQUENCE", "1")
                .addField(VMX_MSGIN, "MEMOS", memos)
                .postExtended()
                .andAssertFieldValue(SVC_RETURN, "P");
    }

    @Data
    @Builder
    private static class MEMOS {
        @JsonProperty("MEMO_1")
        private String memo1;
        @JsonProperty("MEMO_2")
        private String memo2;
        @JsonProperty("MEMO_3")
        private String memo3;
        @JsonProperty("MEMO_4")
        private String memo4;
        @JsonProperty("MEMO_5")
        private String memo5;
    }
}
