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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.kasanova.components.enums.KSNAccounts;
import cz.moneta.test.dsl.kasanova.components.enums.KSNOriginDeposit;
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 51) Zrušení účtu - BÚ")
public class KSNFunction51Test {

    @Order(1)
    @JiraTestCase(id = "PAY-T1757")
    @TestCase(name = "(Fce 51 - 3.osoba - podlimit)")
    public void func51underLimitNoDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 51 UnderLimitNoDispo) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection5()
                .KSNFunction51()
                .MA_AccountNumber(KSNAccounts.CZK_214419499.getValue())
                .enterFunction51()
                .fillIdentificationAndSymbolsShort()
                .continueWithPrintAction()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .doStorno(harness.withKasanova().isStornoOn(), "15834", KSNAccounts.CZK_214419499.getValue(),
                        harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),0)
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 51 UnderLimitNoDispo) ----------------");
    }

    @Order(2)
    @JiraTestCase(id = "PAY-T1758")
    @TestCase(name = "(Fce 51 - 3.osoba - nadlimit)")
    public void func51overLimitNoDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 51 OverLimitNoDispo) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection5()
                .KSNFunction51()
                .MA_AccountNumber(KSNAccounts.CZK_206973713.getValue())
                .enterFunction51()
                .originePurpose(KSNOriginDeposit.PUVOD_VKLADU_4.getValue())
                .fillIdentificationAndSymbolsLong()
                .continueWithPrintAction()
                .kasanovaDialogClickYes()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .doVerification(harness, "4992529", KSNAccounts.CZK_206973713.getValue(), verifyBanker)
                .checkFunctionIsDone()
                .doStorno(harness.withKasanova().isStornoOn(), "4992529", KSNAccounts.CZK_206973713.getValue(),
                        harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),0)
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 51 OverLimitNoDispo) ----------------");
    }

    @Order(3)
    @JiraTestCase(id = "PAY-T1759")
    @TestCase(name = "(Fce 51 - oprávněná osoba - podlimit)")
    public void func51underLimitWithDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 51 UnderLimitWithDispo) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection5()
                .KSNFunction51()
                .MA_AccountNumber(KSNAccounts.CZK_214419499.getValue())
                .enterFunction51()
                .authPerson1()
                .fillIdentificationAndSymbolsMini()
                .continueWithPrintAction()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .checkFunctionIsDone()
                .doStorno(harness.withKasanova().isStornoOn(), "15834", KSNAccounts.CZK_214419499.getValue(),
                        harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),0)
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 51 UnderLimitWithDispo) ----------------");
    }

    @Order(4)
    @JiraTestCase(id = "PAY-T1760")
    @TestCase(name = "(Fce 51 - oprávněná osoba - nadlimit)")
    public void func51overLimitWithDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 51 OverLimitWithDispo) ----------------");
        harness.withKasanova()
                .openLoginPage()
                .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
                .KSNSection5()
                .KSNFunction51()
                .MA_AccountNumber(KSNAccounts.CZK_206973713.getValue())
                .enterFunction51()
                .originePurpose(KSNOriginDeposit.PUVOD_VKLADU_3.getValue())
                .authPerson3()
                .fillIdentificationAndSymbolsMini()
                .continueWithPrintAction()
                .dismissPrintWindow()
                .continueWithSaveAction()
                .doVerification(harness, "4992529", KSNAccounts.CZK_206973713.getValue(), verifyBanker)
                .checkFunctionIsDone()
                .doStorno(harness.withKasanova().isStornoOn(), "4992529", KSNAccounts.CZK_206973713.getValue(),
                        harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),0)
                .logOut();
        harness.log("---------------- END TEST (FUNCTION 51 OverLimitWithDispo) ----------------");
    }

}
