package cz.moneta.test.regression.transactional.payments.cash.kasanova.section1;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.kasanova.components.enums.KSNAccounts;
import cz.moneta.test.dsl.kasanova.components.enums.KSNCoinSplits;
import cz.moneta.test.dsl.kasanova.components.enums.KSNOriginDeposit;
import cz.moneta.test.dsl.kasanova.components.enums.KSNRelationShipToTheOwner;
import cz.moneta.test.dsl.util.credentials.Keys.kasanova;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.NonConcurrentTestScenario;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.TestMethodOrder;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@NonConcurrentTestScenario(name = "(Fce 19) Vklad na BÚ - MONETA - Stavební spořitelna)")
public class KSNFunction19Test {

    @Order(1)
    @JiraTestCase(id = "PAY-T1710")
    @TestCase(name = "(Fce 19 - podlimit)")
    public void func19underLimit(Harness harness, @Key(kasanova.banker) Credentials banker) {

        harness.log("---------------- START TEST (FUNCTION 19 UnderLimit) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction19()
                .WUNumber()
                .enterFunction19()
                .depositAmount("100")
                .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_100_INPUT, "1")
                .fillIdentificationAndSymbolsFunc19Short()
                .continueWithPrintAction()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 19 UnderLimit) ----------------");
    }

    @Order(2)
    @JiraTestCase(id = "PAY-T1711")
    @TestCase(name = "(Fce 19 - mezilimit)")
    public void func19middleLimit(Harness harness, @Key(kasanova.banker) Credentials banker) {

        harness.log("---------------- START TEST (FUNCTION 19 MiddleLimit) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction19()
                .WUNumber()
                .enterFunction19()
                .depositAmount("50000")
                .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_5000_INPUT, "10")
                .fillIdentificationAndSymbolsFunc19Long()
                .continueWithPrintAction()
                .kasanovaDialogClickYes()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 19 MiddleLimit) ----------------");
    }

    @Order(3)
    @JiraTestCase(id = "PAY-T1712")
    @TestCase(name = "(Fce 19 - nadlimit)")
    public void func19overLimit(Harness harness, @Key(kasanova.banker) Credentials banker) {

        harness.log("---------------- START TEST (FUNCTION 19 OverLimit) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction19()
                .WUNumber()
                .enterFunction19()
                .depositAmount("500000")
                .kasanovaDialogClickOK()
                .originePurpose(KSNOriginDeposit.PUVOD_VKLADU_1.getValue())
                .relationToTheOwner(KSNRelationShipToTheOwner.VZTAH_K_MAJITELI_21.getValue())
                .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_5000_INPUT, "100")
                .fillIdentificationAndSymbolsFunc19Long()
                .continueWithPrintAction()
                .kasanovaDialogClickYes()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 19 OverLimit) ----------------");
    }

    @Order(4)
    @JiraTestCase(id = "PAY-T1713")
    @TestCase(name = "(Fce 19 - přesměrování z funkce 11)")
    public void func19redirect(Harness harness, @Key(kasanova.banker) Credentials banker) {

        harness.log("---------------- START TEST (FUNCTION 19 Redirect) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction11()
                .MA_AccountNumber(KSNAccounts.UCET_STAVEBNI_SPORITELNA.getValue())
                .enterFunction19()
                .checkRedirect("19 - Vklad na BÚ - MONETA - Stavební spořitelna")
                .backToMainMenu()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 19 Redirect) ----------------");
    }
}