package cz.moneta.test.dataprepare.ml.hypos;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.hypos.contractPrepare.data.ContractDataPrepare;
import cz.moneta.test.dsl.hypos.contractPrepare.process.ContractProcessPrepare;
import cz.moneta.test.dsl.hypos.enums.HyposProfile;
import cz.moneta.test.dsl.hypos.tasks.HyposTasks;
import cz.moneta.test.dsl.util.data.hypos.HyposContract;
import cz.moneta.test.harness.annotations.Environment;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;

@TestScenario(name = "Create new contract until loan account opening")
public class LoanAccountPrepare {

    @TestCase(name = "Create new contract until loan account opening with job param", environments = {Environment.TST1, Environment.PPE, Environment.FVE})
    public void tcCreateContractUntilLoanAccountOpening(Harness harness) {
        HyposTasks tasks = harness.tasks().hypos();
        ContractProcessPrepare contractProcessPrepare = new ContractProcessPrepare(harness);
        ContractDataPrepare contractDataPrepare = new ContractDataPrepare(harness);
        HyposContract hyposContract = contractDataPrepare.prepareContractData(harness.getSystemOrConfigValue("yamlData"), harness);

        contractProcessPrepare.createNewHypokalkulacka(hyposContract);
        contractProcessPrepare.fillDataAndStartPrescoring(hyposContract);
        contractProcessPrepare.fillDataAndStartScoringManual(hyposContract);
        contractProcessPrepare.approveContract(hyposContract);
        harness.withHypos()
                .openLoginPage()
                .then(tasks.loginToHyposWithProfile(HyposProfile.EMERGENCY))
                .then(tasks.searchAndOpenContractAndCheckState(hyposContract.getContractId(), "Úvěr schválen"))
                .then(tasks.contractTasks().setEventsFlagsUw2());
    }
}