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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.kasanova.components.enums.KSNCoinSplits;
import cz.moneta.test.dsl.kasanova.components.enums.KSNCurrencies;
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 83) Dotace pokladny")
public class KSNFunction83Test {
    private KSNFunction81Test function81test;
    private boolean doOpposite;

    @Order(1)
    @JiraTestCase(id="PAY-T1707")
    @TestCase(name = "(Fce 83)")
    public void func83underLimit(Harness harness, @Key(kasanova.banker) Credentials banker) {
        doOpposite = Boolean.parseBoolean(harness.getConfig("kasanova-config.doOpposite"));
        underLimit(harness, banker, doOpposite);
    }

    public void underLimit(Harness harness, @Key(kasanova.banker) Credentials banker, boolean doOpposite) {
        harness.log("---------------- (FUNCTION 83) ----------------");

        if(doOpposite == true) {
            function81test = new KSNFunction81Test();
            function81test.underLimit(harness, banker, false);
        }

        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection8()
            .KSNFunction83()
            .CurrencyTillTrans(KSNCurrencies.CZK_NAME.getValue())
            .EnterFunction83()
            .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_500_INPUT, "1")
            .fillConstantAndSpecificSymbols()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .checkFunctionIsDone()
            .logOut();

        harness.log("---------------- (FUNCTION 83) ----------------");
    }

    public void forFunc86(Harness harness, @Key(kasanova.banker) Credentials banker, boolean doOpposite) {
	harness.log("---------------- (FUNCTION 83) ----------------");

        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection8()
            .KSNFunction83()
            .CurrencyTillTrans(KSNCurrencies.CZK_NAME.getValue())
            .EnterFunction83()
            .coinSplitTable(KSNCoinSplits.COINSPLIT_CZK_5000_INPUT, "1")
            .fillConstantAndSpecificSymbols()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .checkFunctionIsDone()
            .logOut();

        harness.log("---------------- (FUNCTION 83) ----------------");
    }
}
