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

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.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 cz.moneta.test.regression.transactional.payments.cash.kasanova.section1.KSNFunction11Test;
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 36) Výběr v měně účtu, BÚ - třetí osoba")
public class KSNFunction36Test {    
    private KSNFunction11Test function11test;
    private boolean doOpposite;
    
    @Order(1)
    @JiraTestCase(id="PAY-T1300")
    @TestCase(name = "(Fce 36 - podlimit)")
    public void func36underLimit(Harness harness, @Key(kasanova.banker) Credentials banker) {
        doOpposite = Boolean.parseBoolean(harness.getConfig("kasanova-config.doOpposite"));
        if(doOpposite == true) {
            function11test = new KSNFunction11Test();
            function11test.underLimitWithDispo(harness, banker, false);
        }

        harness.log("---------------- START TEST (FUNCTION 36 UnderLimit) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection3()
            .KSNFunction36()
            .MA_AccountNumber(KSNAccounts.CZK_206971718.getValue())
            .EnterFunction36()
            .withdrawAmount("400")
            .fillIdentificationAndSymbolsShort()
            .continueWithPrintAction()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .checkFunctionIsDone()
            .logOut();
        
        harness.log("---------------- END TEST (FUNCTION 36 UnderLimit) ----------------");
    }    
    
    @Order(2)
    @JiraTestCase(id="PAY-T1352")
    @TestCase(name = "(Fce 36 - mezilimit)")
    public void func36middleLimit(Harness harness, @Key(kasanova.banker) Credentials banker) {
        doOpposite = Boolean.parseBoolean(harness.getConfig("kasanova-config.doOpposite"));
        if(doOpposite == true) {
            function11test = new KSNFunction11Test();
            function11test.middleLimitWithDispo(harness, banker, false);
        }

        harness.log("---------------- START TEST (FUNCTION 36 MiddleLimit) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection3()
            .KSNFunction36()
            .MA_AccountNumber(KSNAccounts.CZK_206971718.getValue())
            .EnterFunction36()
            .withdrawAmount("50000")
            .fillIdentificationAndSymbolsLong()
            .continueWithPrintAction()
            .kasanovaDialogClickYes()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .checkFunctionIsDone()
            .logOut();
        
        harness.log("---------------- END TEST (FUNCTION 36 MiddleLimit) ----------------");
    }
    
    @Order(3)
    @JiraTestCase(id="PAY-T1353")
    @TestCase(name = "(Fce 36 - nadlimit)")
    public void func36overLimit(Harness harness, @Key(kasanova.banker) Credentials banker, @Key(kasanova.verifyBanker) Credentials verifyBanker) {
        doOpposite = Boolean.parseBoolean(harness.getConfig("kasanova-config.doOpposite"));
        if(doOpposite == true) {
            function11test = new KSNFunction11Test();
            function11test.overLimitWithDispo(harness, banker, verifyBanker, false);
        }

        harness.log("---------------- START TEST (FUNCTION 36 OverLimit) ----------------");
        harness.withKasanova()
            .openLoginPage()
            .then(harness.tasks().kasanova().loginWithUserAndPassword(banker))
            .KSNSection3()
            .KSNFunction36()
            .MA_AccountNumber(KSNAccounts.CZK_206971718.getValue())
            .EnterFunction36()
            .withdrawAmount("500000")
            .kasanovaDialogClickOK()
            .originePurpose(KSNOriginDeposit.PUVOD_VKLADU_11.getValue())
            .fillIdentificationAndSymbolsLong()
            .continueWithPrintAction()
            .kasanovaDialogClickYes()
            .dismissPrintWindow()
            .continueWithSaveAction()
            .doVerification(harness, "500000", KSNAccounts.CZK_206971718.getValue(), verifyBanker)
            .checkFunctionIsDone()
            .logOut();
        
        harness.log("---------------- END TEST (FUNCTION 36 OverLimit) ----------------");
    }
    
}
