package cz.moneta.test.regression.commercial.auto.smartauto;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.auto.smartauto.shared.*;
import cz.moneta.test.dsl.util.credentials.Keys.smart;
import cz.moneta.test.dsl.util.task.auto.smartauto.SmartAutoTasks;
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.auto.smartauto.mockdata.*;
import org.junit.jupiter.api.Disabled;
@Disabled
@TestScenario(name = "Successfully filled agro.")
public class AgroTest extends InsuranceAndBenefitData {

    @JiraTestCase(id = "LAMD-T1411")
    @TestCase(name = "Successfully filled agro with TP")
    public void tcAgroWithTP(Harness harness, @Key(smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();
        CalculationData calculationData = AgroMock.prepareCalculationDataWithTP();
        CompanyData companyData = SharedMock.prepareCompanyData();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculationAgro(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, companyData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .clickVehiclePage()
                .then(smartAutoTasks.data().doNotHaveVIN())
                .then(smartAutoTasks.data().checkAgroInformation(calculationData.getBrand(), calculationData.getModel()))
                .then(smartAutoTasks.validation().validateVehiclePage());
    }

    @JiraTestCase(id = "LAMD-T1412")
    @TestCase(name = "Successfully filled agro without TP")
    public void tcAgroWithoutTP(Harness harness, @Key(smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();
        CalculationData calculationData = AgroMock.prepareCalculationDataWithoutTP();
        CompanyData companyData = SharedMock.prepareCompanyData();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculationAgroWithoutTP(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, companyData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .clickVehiclePage()
                .then(smartAutoTasks.data().doNotHaveVIN())
                .then(smartAutoTasks.data().fillAgroAdditionalDataWithoutTP(null))
                .then(smartAutoTasks.data().checkAgroInformation(calculationData.getBrand(), calculationData.getModel()))
                .then(smartAutoTasks.validation().validateVehiclePage());
    }

    @JiraTestCase(id = "LAMD-T1413")
    @TestCase(name = "Successfully filled agro with TP C2C - Consumer")
    public void tcAgroWithTPC2CConsumer(Harness harness, @Key(smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();
        CalculationData calculationData = AgroMock.prepareCalculationDataWithTPC2C();
        CompanyData companyData = SharedMock.prepareCompanyData();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculationAgro(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, companyData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .clickVehiclePage()
                .then(smartAutoTasks.data().doNotHaveVIN())
                .then(smartAutoTasks.data().checkAgroInformation(calculationData.getBrand(), calculationData.getModel()))
                .then(smartAutoTasks.validation().validateVehiclePage())
                .then(smartAutoTasks.account().fillOthersPageForC2CConsumer(777666555, 51, BankCode.KOMERCNI_BANKA, "Ok", "Jan", "Novák", "01.01.2000"));
    }

    @JiraTestCase(id = "LAMD-T1414")
    @TestCase(name = "Successfully filled agro with TP C2C - Businessman")
    public void tcAgroWithTPC2CBusiness(Harness harness, @Key(smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();
        CalculationData calculationData = AgroMock.prepareCalculationDataWithTPC2C();
        CompanyData companyData = SharedMock.prepareCompanyData();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculationAgro(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, companyData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .clickVehiclePage()
                .then(smartAutoTasks.data().checkAgroInformation(calculationData.getBrand(), calculationData.getModel()))
                .then(smartAutoTasks.data().doNotHaveVIN())
                .then(smartAutoTasks.validation().validateVehiclePage())
                .then(smartAutoTasks.account().fillOthersPageForC2CBussiness(777777777, 51, BankCode.KOMERCNI_BANKA, "OK", "Nejlepší firma", "123654"));
    }

    @JiraTestCase(id = "LAMD-T1638")
    @TestCase(name = "Successfully filled agro with TP - Irregular payments - Businessman")
    public void tcAgroWithTPIrregular(Harness harness, @Key(smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();
        CalculationData calculationData = AgroMock.prepareCalculationDataWithTP();
        CompanyData companyData = SharedMock.prepareCompanyData();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculationAgro(calculationData))
                .then(smartAutoTasks.irregularPaymentTasks().addIrregularPayment(50000L))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, companyData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .clickVehiclePage()
                .then(smartAutoTasks.data().doNotHaveVIN())
                .then(smartAutoTasks.data().checkAgroInformation(calculationData.getBrand(), calculationData.getModel()))
                .then(smartAutoTasks.validation().validateVehiclePage());
    }
}