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

import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.TestMethodOrder;
import cz.moneta.test.dsl.Harness;
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;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@NonConcurrentTestScenario(name = "(Fce 72) Storno bezhotovostních operací")
public class KSNFunction72Test {

    private final String debetAmount = "1000";
    private final String BU_CZK_206971718 = "206971718";
    private final String BU_CZK_16916363 = "16916363";
    private final String HK_CZK_1191000 = "1191000";

    @Order(1)
    @JiraTestCase(id="PAY-T1798")
    @TestCase(name = "(Fce 72 - fromBUtoBU)")
    public void func72fromBUtoBU(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 72 fromBUtoBU) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection7()
            .KSNFunction72()
            .debet_AccountNumber(BU_CZK_206971718)
            .credit_AccountNumber(BU_CZK_16916363)
            .EnterFunction72()
            .debetAmount2(debetAmount)
            .authPerson4()
            .fillSymbols()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .doVerification(harness, debetAmount, BU_CZK_206971718, verifyBanker)
            .checkFunctionIsDone()
            .doStorno(harness.withKasanova().isStornoOn(), debetAmount, BU_CZK_206971718,
                    harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),0)
            .logOut();

        harness.log("---------------- END TEST (FUNCTION 72 fromBUtoBU) ----------------");
    }

    @Order(2)
    @JiraTestCase(id="PAY-T1799")
    @TestCase(name = "(Fce 72 - fromHKtoBU)")
    public void func72fromHKtoBU(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 72 fromHKtoBU) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection7()
            .KSNFunction72()
            .debet_AccountNumber(HK_CZK_1191000)
            .clickDebetHlKnihaCheckbox()
            .credit_AccountNumber(BU_CZK_16916363)
            .EnterFunction72()
            .debetAmount2(debetAmount)
            .fillSymbols()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .doVerification(harness, debetAmount, HK_CZK_1191000, verifyBanker)
            .checkFunctionIsDone()
            .doStorno(harness.withKasanova().isStornoOn(), debetAmount, HK_CZK_1191000,
                    harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),0)
            .logOut();

        harness.log("---------------- END TEST (FUNCTION 72 fromHKtoBU) ----------------");
    }

    @Order(3)
    @JiraTestCase(id="PAY-T1800")
    @TestCase(name = "(Fce 72 - fromBUtoHK)")
    public void func72fromBUtoHK(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 72 fromBUtoHK) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection7()
            .KSNFunction72()
            .debet_AccountNumber(BU_CZK_206971718)
            .clickKreditHlKnihaCheckbox()
            .credit_AccountNumber(HK_CZK_1191000)
            .EnterFunction72()
            .debetAmount2(debetAmount)
            .authPerson4()
            .fillSymbols()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .doVerification(harness, debetAmount, BU_CZK_206971718, verifyBanker)
            .checkFunctionIsDone()
            .doStorno(harness.withKasanova().isStornoOn(), debetAmount, BU_CZK_206971718,
                    harness.getConfig("kasanova-config.verify-banker.uid"), verifyBanker.getUsername(), verifyBanker.getPassword(),0)
            .logOut();

        harness.log("---------------- END TEST (FUNCTION 72 fromBUtoHK) ----------------");
    }
}
