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 15) Vklad na BÚ - Vklad hypotéka")
public class KSNFunction15Test {

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

        harness.log("---------------- START TEST (FUNCTION 15 UnderLimit) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction15()
                .MA_AccountNumber(KSNAccounts.UCET_HYPOTEKA.getValue())
                .enterFunction15()
                .depositAmount("100")
                .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_100_INPUT, "1")
                .fillIdentificationAndSymbolsShort()
                .continueWithPrintAction()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 15 UnderLimit) ----------------");
    }

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

        harness.log("---------------- START TEST (FUNCTION 15 MiddleLimit) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction15()
                .MA_AccountNumber(KSNAccounts.UCET_HYPOTEKA.getValue())
                .enterFunction15()
                .depositAmount("50000")
                .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_5000_INPUT, "10")
                .fillIdentificationAndSymbolsLong()
                .continueWithPrintAction()
                .kasanovaDialogClickYes()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 15 MiddleLimit) ----------------");
    }

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

        harness.log("---------------- START TEST (FUNCTION 15 OverLimit) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction15()
                .MA_AccountNumber(KSNAccounts.UCET_HYPOTEKA.getValue())
                .enterFunction15()
                .depositAmount("500000")
                .kasanovaDialogClickOK()
                .originePurpose(KSNOriginDeposit.PUVOD_VKLADU_2.getValue())
                .relationToTheOwner(KSNRelationShipToTheOwner.VZTAH_K_MAJITELI_22.getValue())
                .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_5000_INPUT, "100")
                .fillIdentificationAndSymbolsLong()
                .continueWithPrintAction()
                .kasanovaDialogClickYes()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 15 OverLimit) ----------------");
    }

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

        harness.log("---------------- START TEST (FUNCTION 15 Redirect) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection1()
                .KSNFunction11()
                .MA_AccountNumber(KSNAccounts.UCET_HYPOTEKA.getValue())
                .enterFunction15()
                .checkRedirect("15 - Vklad na BÚ - Vklad hypotéka")
                .backToMainMenu()
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 15 Redirect) ----------------");
    }
}