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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.DateFormatPatterns;
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.BeforeAll;

import java.time.LocalDate;

@TestScenario(name = "Statements on card")
public class CardStatements {
    private String account;
    private SmokeData smokeData;
    private String lastDayOfPreviousMonth;

    @BeforeAll
    public void getInfo(Harness harness) {
        smokeData = SmokeData.getInstance(harness);
        account = smokeData.getAccountWithStatements();
        lastDayOfPreviousMonth = DateUtils.getDateWithFormat(LocalDate.now().withDayOfMonth(1).minusDays(1),
                DateFormatPatterns.FIRST_VISION_DATE_FORMAT_WITH_SEPARATOR);
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T2095")
    public void MWFA95_DO_STATEMENTS_PRINT(Harness harness) {
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFA95"))
                .addField("CisloKaretnihoUctu", account)
                .addField("CisloKarty", "")
                .addField("DuvodTisku", "STAT")
                .addField("TransakceDatumVypisu", lastDayOfPreviousMonth)
                .postExtended()
                .andAssertStatus(200)
                .andAssertFieldValue("DuvodAkce", "Zaslání kopie výpisu");
    }
}
