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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.DateUtils;
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.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

import static cz.moneta.test.dsl.util.DateFormatPatterns.FIRST_VISION_DATE_FORMAT_WITHOUT_SEPARATOR;

@Execution(ExecutionMode.SAME_THREAD)
@TestScenario(name = "adding/terminating new card")
public class Termination {
    private String account;
    private SmokeData smokeData;

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

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T2435")
    public void MWFL57_AUTOMATIC_CANCELLATION_CREATE(Harness harness) {
        String todayString = DateUtils.getFormattedTodayDate(FIRST_VISION_DATE_FORMAT_WITHOUT_SEPARATOR);
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFL57"))
                .addField("CisloKaretnihoUctu", account)
                .addField("DatumPrijeti", todayString)
                .addField("ZpusobZruseni", "2")
                .addField("TiskDopisu", "0")
                .postExtended()
                .andAssertStatus(200);
    }

    @AfterAll
    public void unblockAccount(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFJW3"))
                .addField("CisloKaretnihoUctu", account)
                .postExtended();
    }
}
