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.harness.support.rest.RawRestRequest;
import cz.moneta.test.sanity.transactional.SmokeData;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;

@TestScenario(name = "change student card fee plan")
public class CardFeePlan {
    private String bu;
    private SmokeData smokeData;

    @BeforeAll
    public void getInfo(Harness harness) {
        smokeData = SmokeData.getInstance(harness);
        bu = smokeData.getStudentBU();
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T3146")
    public void MWF2DU_BATCH_UPDATES_DEB_CARD_ACC_FEE_PLAN(Harness harness) {
        changeFeePlan(harness, "162") // free & flexi
                .andAssertStatus(200);
    }

    private RawRestRequest.Response changeFeePlan(Harness harness, String feePlan) {
        return harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromIcb(smokeData.getPath("MWF2DU"))
                .addField("CurrentAccountNumber", bu)
                .addField("CurrentAccountFeePlan", feePlan)
                .postExtended();
    }

    @AfterAll
    public void restoreFeePlan(Harness harness) {
        changeFeePlan(harness, "140");  //student
    }
}
