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

@TestScenario(name = "no client required")
public class Inputless {
    private SmokeData smokeData;
    private String rc;

    @BeforeAll
    public void getInfo(Harness harness) {
        smokeData = SmokeData.getInstance(harness);
        rc = "8706107399";
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1929")
    public void MWF0E0_DO_BIRTH_NUMBER_PARSE(Harness harness) {
        String date = "19" + rc.substring(0, 2) + "-"
                + rc.substring(2, 4) + "-"
                + rc.substring(4, 6);
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWF0E0"))
                .addField("BirthNumber", rc)
                .postExtended()
                .andAssertStatus(200)
                .andAssertFieldValue("BirthDate", date);
    }

    @TestCase(environments = {Environment.TST3, Environment.FVE, Environment.PPE})
    @JiraTestCase(id = "FVP-T1981")
    public void MWFXXX1_GET_CARD_DETAIL_EMBOSS_NAME(Harness harness) {
        String titleBefore = RandomStringUtils.randomAlphabetic(3);
        String nameFirst = RandomStringUtils.randomAlphabetic(8);
        String nameLast = RandomStringUtils.randomAlphabetic(8);
        String titleAfter = RandomStringUtils.randomAlphabetic(3);
        String expectedNameEmbossed = titleBefore.toUpperCase() + " " +
                nameFirst.toUpperCase() + " " + nameLast.toUpperCase();
        String expectedNameShortened = titleBefore + " " + nameFirst + " " + nameLast;
        harness.tasks().wso2().restRequest()
                .prepareEmptyRequestFromUfo(smokeData.getPath("MWFXXX1"))
                .addField("titleBefore", titleBefore)
                .addField("nameFirst", nameFirst)
                .addField("nameLast", nameLast)
                .addField("titleAfter", titleAfter)
                .addField("busName", "")
                .addField("nameLengthMax", "")
                .postExtended()
                .andAssertStatus(200)
                .andAssertFieldValue("NAME_EMBOSSED", expectedNameEmbossed)
                .andAssertFieldValue("NAME_SHORTENED", expectedNameShortened);
    }
}
