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 75) Storno bezhotovostních operací bez klienta")
public class KSNFunction75Test {

    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-T1801")
    @TestCase(name = "(Fce 75 - fromBUtoBU)")
    public void func75fromBUtoBU(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {

        harness.log("---------------- START TEST (FUNCTION 75 fromBUtoBU) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection7()
            .KSNFunction75()
            .debet_AccountNumber(BU_CZK_206971718)
            .credit_AccountNumber(BU_CZK_16916363)
            .EnterFunction75()
            .debetAmount2(debetAmount)
            .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 75 fromBUtoBU) ----------------");
    }

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

        harness.log("---------------- START TEST (FUNCTION 75 fromHKtoBU) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection7()
            .KSNFunction75()
            .debet_AccountNumber(HK_CZK_1191000)
            .clickDebetHlKnihaCheckbox()
            .credit_AccountNumber(BU_CZK_16916363)
            .EnterFunction75()
            .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 75 fromHKtoBU) ----------------");
    }

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

        harness.log("---------------- START TEST (FUNCTION 75 fromBUtoHK) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection7()
            .KSNFunction75()
            .debet_AccountNumber(BU_CZK_206971718)
            .clickKreditHlKnihaCheckbox()
            .credit_AccountNumber(HK_CZK_1191000)
            .EnterFunction75()
            .debetAmount2(debetAmount)
            .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 75 fromBUtoHK) ----------------");
    }
}
