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

import cz.moneta.test.dsl.Harness;
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 81) Odvod pokladny")
public class KSNFunction81Test {
    private KSNFunction83Test function83test;
    private boolean doOpposite;

    @Order(1)
    @JiraTestCase(id="PAY-T1705")
    @TestCase(name = "(Fce 81)")
    public void func81underLimit(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 81) ----------------");

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

        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection8()
            .KSNFunction81()
            .CurrencyTillTrans(KSNCurrencies.CZK_NAME.getValue())
            .EnterFunction81()
            .fillAmount("500")
            .fillConstantAndSpecificSymbols()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .checkFunctionIsDone()
            .logOut();

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