package cz.moneta.test.regression.commercial.smallbusiness.digital.localtests.banka.products.smeautomats.po;

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.Environment;
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 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;

@TestScenario(name = "Create Expres Business Po Bytové družstvo/Společenství vlastníků jednotek")
public class CreateExpresBusinessBdSvj {

    private NonClient nonPoClient;
    private BankaTasks bankaTasks;

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

    @TestCase(name = "Create Expres Business Bd/Svj", environments = {Environment.TST1, Environment.PPE})
    @JiraTestCase(id = "SBD-T1051")
    public void createExpresBusinessBdSvj(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {
        String lastYear = DataPrepare.getLastYear();
        String yearBeforeLast = DataPrepare.getYearBeforeLast();
        String loanExpresAmount = "500000";
        String numberOfPayments = "360";
        String financingReason = "Modernizace";

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentialsAndTurnOffSignpad(credentials))
                .then(bankaTasks.search().findLegalRepresentativeByIco(nonPoClient.ico()))
                .then(bankaTasks.sharedTasks().storeFullNameAndIco())
                .then(bankaTasks.newSmeAutomatPoTasks().withExpresBusinessCooperativeOwnership(harness, loanExpresAmount, numberOfPayments, lastYear, yearBeforeLast, financingReason));
    }

    @AfterEach
    protected void tearDown(Harness harness) {
        TearDown.storeIcoFullNameCifSessionId(harness);
    }
}
