package cz.moneta.test.regression.feeincome;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "PPI AdditionalInsurance TestSuite basic tests cases")
public class PpiAdditionalInsurance {

    @TestCase(name = "AdditionalInsurance Exp in UFO Bank", environments = {TST1, PPE})
    @JiraTestCase(id = "INS-T358")
    public void checkExpresInsuranceBank(Harness harness, @Key("ufo-banka-banker") Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        String birthnumber = harness.getConfig("rc.checkExpresInsuranceBank");
        String expresNumber = harness.getConfig("expres.checkExpresInsuranceBank");

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentials(credentials))
                .then(bankaTasks.search().searchByRc(birthnumber))
                .clickExpresDetail(expresNumber)
                .clickEditIns()
                .then(bankaTasks.newInsurancePpiTasks().createAndCancelInsurance());
    }

    @TestCase(name = "AdditionalInsurance UDC in UFO Bank", environments = {TST1, PPE})
    @JiraTestCase(id = "INS-T394")
    public void checkUdcInsuranceBank(Harness harness, @Key("ufo-banka-banker") Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        String birthnumber = harness.getConfig("rc.checkUdcInsuranceBank");
        String expresNumber = harness.getConfig("expres.checkUdcInsuranceBank");

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentials(credentials))
                .then(bankaTasks.search().searchByRc(birthnumber))
                .clickExpresDetail(expresNumber)
                .clickEditIns()
                .then(bankaTasks.newInsurancePpiTasks().createAndCancelInsurance());
    }

    @TestCase(name = "AdditionalInsurance Exp Plus in UFO Bank", environments = {TST1, PPE})
    @JiraTestCase(id = "INS-T395")
    public void checkExpresPlusInsuranceBank(Harness harness, @Key("ufo-banka-banker") Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        String birthnumber = harness.getConfig("rc.checkExpresPlusInsuranceBank");
        String expresNumber = harness.getConfig("expres.checkExpresPlusInsuranceBank");

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentials(credentials))
                .then(bankaTasks.search().searchByRc(birthnumber))
                .clickExpresDetail(expresNumber)
                .clickServiceCredit()
                .clickEditInsurancePlus()
                .then(bankaTasks.newInsurancePpiPlusTasks().createAndCancelInsurancePlus());
    }

    @TestCase(name = "Pripojisteni Udc Plus in UFO Bank", environments = {TST1, PPE})
    @JiraTestCase(id = "INS-T396")
    public void checkUdcPlusInsuranceBank(Harness harness, @Key("ufo-banka-banker") Credentials credentials) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();
        String birthnumber = harness.getConfig("rc.checkUdcPlusInsuranceBank");
        String expresNumber = harness.getConfig("expres.checkUdcPlusInsuranceBank");

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentials(credentials))
                .then(bankaTasks.search().searchByRc(birthnumber))
                .clickExpresDetail(expresNumber)
                .clickServiceCredit()
                .clickEditInsurancePlus()
                .then(bankaTasks.newInsurancePpiPlusTasks().createAndCancelInsurancePlus());
    }
}