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.kasanova.components.enums.KSNPersons;
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;

import static cz.moneta.test.dsl.util.credentials.Keys.kasanova;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@NonConcurrentTestScenario(name = "(Fce 53) Zrušení účtu - TV)")
public class KSNFunction53Test {

    private final String accountBalance = "286045";
    private final String TV_CZK_202990663 = "202990663";

    @Order(1)
    @JiraTestCase(id="PAY-T1755")
    @TestCase(name = "(Fce 53 - 3.osoba - mezilimit)")
    public void middleLimitNoDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 53 MiddleLimitNoDispo) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection5()
            .KSNFunction53()
            .MA_AccountNumber(TV_CZK_202990663)
            .EnterFunction53()
            .fillIdentificationAndSymbolsLong()
            .continueWithPrintAction()
            .kasanovaDialogClickYes()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .checkFunctionIsDone()
            .doStorno(harness.withKasanova().isStornoOn(), accountBalance, TV_CZK_202990663,
                    harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),1)
            .logOut();

        harness.log("---------------- END TEST (FUNCTION 53 MiddleLimitNoDispo) ----------------");
    }

    @Order(2)
    @JiraTestCase(id="PAY-T1756")
    @TestCase(name = "(Fce 53 - oprávněná osoba - mezilimit)")
    public void middleLimitWithDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {
        harness.log("---------------- START TEST (FUNCTION 53 MiddleLimitWithDispo) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection5()
            .KSNFunction53()
            .MA_AccountNumber(TV_CZK_202990663)
            .EnterFunction53()
            .authPerson(KSNPersons.DRAHOSLAV_VRZAL.getValue())
            .fillIdentificationAndSymbolsShort()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .checkFunctionIsDone()
            .doStorno(harness.withKasanova().isStornoOn(), accountBalance, TV_CZK_202990663,
                    harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),1)
            .logOut();

        harness.log("---------------- END TEST (FUNCTION 53 MiddleLimitWithDispo) ----------------");
    }

    @Order(3)
    @JiraTestCase(id="PAY-T1750")
    @TestCase(name = "(Fce 53 - 3.osoba - nadilimit)")
    public void overLimitNoDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {
        harness.log("---------------- START TEST (FUNCTION 53 OverLimitNoDispo) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection5()
            .KSNFunction53()
            .MA_AccountNumber(KSNAccounts.TV_CZK_214564530.getValue())
            .EnterFunction53()
            .originePurpose(KSNOriginDeposit.PUVOD_VKLADU_2.getValue())
            .fillIdentificationAndSymbolsLong()
            .continueWithPrintAction()
            .kasanovaDialogClickYes()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .doVerification(harness, "510003,57", KSNAccounts.TV_CZK_214564530.getValue(), verifyBanker)
            .checkFunctionIsDone()
            .doStorno(harness.withKasanova().isStornoOn(), "510004", KSNAccounts.TV_CZK_214564530.getValue(),
                    harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),1)
            .logOut();

        harness.log("---------------- END TEST (FUNCTION 53 OverLimitNoDispo) ----------------");
    }

    @Order(4)
    @JiraTestCase(id="PAY-T1754")
    @TestCase(name = "(Fce 53 - oprávněná osoba - nadilimit)")
    public void overLimitWithDispo(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {
        harness.log("---------------- START TEST (FUNCTION 53 OverLimitWithDispo) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection5()
            .KSNFunction53()
            .MA_AccountNumber(KSNAccounts.TV_CZK_214564530.getValue())
            .EnterFunction53()
            .originePurpose(KSNOriginDeposit.PUVOD_VKLADU_2.getValue())
            .authPerson(KSNPersons.VACLAV_KSNTESTY.getValue())
            .fillIdentificationAndSymbolsShort()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .doVerification(harness, "510003,57", KSNAccounts.TV_CZK_214564530.getValue(), verifyBanker)
            .checkFunctionIsDone()
            .doStorno(harness.withKasanova().isStornoOn(), "510004", KSNAccounts.TV_CZK_214564530.getValue(),
                    harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),1)
            .logOut();

        harness.log("---------------- END TEST (FUNCTION 53 OverLimitWithDispo) ----------------");
    }
}
