package cz.moneta.test.regression.commercial.smallbusiness.digital.localtests.banka.testscenarios;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.data.client.NonClient;
import cz.moneta.test.harness.annotations.*;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import cz.moneta.test.regression.commercial.smallbusiness.digital.DataPrepare;
import cz.moneta.test.regression.commercial.smallbusiness.digital.TearDown;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Order;

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

@Disabled("This product has been canceled")
@Deprecated
@TestScenarioWithOrder(name = "Create FON CIF with Moneta Business Card - Retail Hunter")
public class CreateFonWithRetailHunter {

    private NonClient nonClient;
    private BankaTasks bankaTasks;

    @BeforeAll
    protected void setUp(Harness harness) {
        bankaTasks = harness.tasks().ufo().banka();
        nonClient = DataPrepare.setUpFop(harness);
    }

    @TestCase(name = "Create FON Statutory Authority", environments = {TST1, PPE})
    @Order(1)
    @JiraTestCase(id = "SBD-T486")
    public void createFonStatutoryAuthority(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findByNewRc(nonClient.birthNumber()))
                .then(bankaTasks.newStatutoryAuthority().createStatutoryAuthority(nonClient))
                .then(bankaTasks.sharedTasks().storeFullNameAndBirthNumber());

        harness.storeGlobal("FON_STAT_PASSED", "PASS");
    }

    /**
     * V teste nutne vyplnit realne ICO do premennej "businessIco"
     */
    @EnableIfSet(globalKey = "FON_STAT_PASSED")
    @TestCase(name = "Moneta Business Card for FON - Retail Hunter", environments = {TST1, PPE})
    @Order(2)
    @JiraTestCase(id = "SBD-T493")
    public void retailHunter(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {
        String businessIco = "74564684";

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findByRC(nonClient.birthNumber()))
                .then(bankaTasks.retailHunter().createRetailHunter(nonClient, businessIco))
                .then(bankaTasks.sharedTasks().storeFullNameAndBirthNumber());
    }

    @AfterEach
    public void tearDown(Harness harness) {
        TearDown.storeBirthNumberFullNameCifSessionId(harness);
    }
}
