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;
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.CarMock;
import cz.moneta.test.regression.commercial.auto.smartauto.mockdata.SharedMock;
import org.junit.jupiter.api.Disabled;

@Disabled
@TestScenario(name = "Filling Customer consumer.")
public class CustomerConsumerTest extends InsuranceAndBenefitData {

    @JiraTestCase(id = "LAMD-T1018")
    @TestCase(name = "Nationality: CZ, Employment: indefinite period, Employer: registered in CZ")
    public void tcCustomerConsumer1(Harness harness, @Key(Keys.smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();

        ContactData contactData = SharedMock.prepareContactDataWoman();
        IdentificationData identificationData = SharedMock.prepareIdentificationDataWoman();
        CompanyData companyData = SharedMock.prepareCompanyData();
        CalculationData calculationData = CarMock.prepareCalculationCar1();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculation(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, contactData, identificationData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .then(smartAutoTasks.contact().fillContactInformation(contactData))
                .then(smartAutoTasks.identification().fillIdentification(identificationData))
                .then(smartAutoTasks.bankContact().fillBankContact("212345", BankCode.KOMERCNI_BANKA))
                .then(smartAutoTasks.personalData().fillPersonalData(MaritalStatus.SINGLE, 2, HousingKind.OWN_FLAT, Education.COLLEGE))
                .then(smartAutoTasks.employment().fillEmployment(Employment.INDEFINITE_PERIOD, "01.01.2010", "SW Developer"))
                .then(smartAutoTasks.revenuesAndExpenses().fillRevenuesAndExpenses(30000, 50000, 10000, 10000))
                .then(smartAutoTasks.company().fillCompanyRegistered(companyData))
                .then(smartAutoTasks.validation().validateCustomerPage());
    }

    @JiraTestCase(id = "LAMD-T1019")
    @TestCase(name = "Nationality: CZ, Employment: indefinite period, Employer: NOT registered in CZ")
    public void tcCustomerConsumer2(Harness harness, @Key(Keys.smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();

        ContactData contactData = SharedMock.prepareContactDataWoman();
        IdentificationData identificationData = SharedMock.prepareIdentificationDataWoman();
        CompanyData companyData = SharedMock.prepareCompanyData();
        CalculationData calculationData = CarMock.prepareCalculationCar1();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculation(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, contactData, identificationData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .then(smartAutoTasks.contact().fillContactInformation(contactData))
                .then(smartAutoTasks.identification().fillIdentification(identificationData))
                .then(smartAutoTasks.bankContact().fillBankContact("212345", BankCode.KOMERCNI_BANKA))
                .then(smartAutoTasks.personalData().fillPersonalData(MaritalStatus.SINGLE, 2, HousingKind.OWN_FLAT, Education.COLLEGE))
                .then(smartAutoTasks.employment().fillEmployment(Employment.INDEFINITE_PERIOD, "01.01.2010", "SW Developer"))
                .then(smartAutoTasks.revenuesAndExpenses().fillRevenuesAndExpenses(30000, 50000, 10000, 10000))
                .then(smartAutoTasks.company().fillCompanyRegistered(companyData))
                .then(smartAutoTasks.validation().validateCustomerPage());
    }

    @JiraTestCase(id = "LAMD-T1020")
    @TestCase(name = "Nationality: SLOVAKIA, Employment: indefinite period, Employer: registered in CZ")
    public void tcCustomerConsumer3(Harness harness, @Key(Keys.smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();

        ContactData contactData = SharedMock.prepareContactDataMan();
        IdentificationData identificationData = SharedMock.prepareIdentificationDataMan();
        CompanyData companyData = SharedMock.prepareCompanyData();
        CalculationData calculationData = CarMock.prepareCalculationCar1();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculation(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, contactData, identificationData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .then(smartAutoTasks.contact().fillContactInformation(contactData))
                .then(smartAutoTasks.identification().fillIdentification(identificationData))
                .then(smartAutoTasks.bankContact().fillBankContact("212345", BankCode.KOMERCNI_BANKA))
                .then(smartAutoTasks.personalData().fillPersonalData(MaritalStatus.SINGLE, 2, HousingKind.OWN_FLAT, Education.COLLEGE))
                .then(smartAutoTasks.employment().fillEmployment(Employment.INDEFINITE_PERIOD, "01.01.2010", "SW Developer"))
                .then(smartAutoTasks.revenuesAndExpenses().fillRevenuesAndExpenses(30000, 50000, 10000, 10000))
                .then(smartAutoTasks.company().fillCompanyRegistered(companyData))
                .then(smartAutoTasks.validation().validateCustomerPage());
    }

    @JiraTestCase(id = "LAMD-T1021")
    @TestCase(name = "Nationality: CZ, Employment: retirement")
    public void tcCustomerConsumer4(Harness harness, @Key(Keys.smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();

        ContactData contactData = SharedMock.prepareContactDataWoman();
        IdentificationData identificationData = SharedMock.prepareIdentificationDataWoman();
        CalculationData calculationData = CarMock.prepareCalculationCar1();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculation(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, contactData, identificationData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .then(smartAutoTasks.contact().fillContactInformation(contactData))
                .then(smartAutoTasks.identification().fillIdentification(identificationData))
                .then(smartAutoTasks.bankContact().fillBankContact("212345", BankCode.KOMERCNI_BANKA))
                .then(smartAutoTasks.personalData().fillPersonalData(MaritalStatus.SINGLE, 2, HousingKind.RENTED_FLAT, Education.HIGHSCHOOL))
                .then(smartAutoTasks.employment().fillEmploymentRetirement("01.01.2010"))
                .then(smartAutoTasks.revenuesAndExpenses().fillRevenuesAndExpenses(30000, 50000, 10000, 10000))
                .then(smartAutoTasks.validation().validateCustomerPage());
    }

    @JiraTestCase(id = "LAMD-T1022")
    @TestCase(name = "Nationality: CZ, Employment: certain time, client in notice period, Employer: registered in CZ")
    public void tcCustomerConsumer5(Harness harness, @Key(Keys.smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();

        ContactData contactData = SharedMock.prepareContactDataWoman();
        IdentificationData identificationData = SharedMock.prepareIdentificationDataWoman();
        CompanyData companyData = SharedMock.prepareCompanyData();
        CalculationData calculationData = CarMock.prepareCalculationCar1();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeCalculation(calculationData))
                .then(smartAutoTasks.insuranceTasks().fillCustomerData(calculationData, smartAutoTasks, contactData, identificationData))
                .then(smartAutoTasks.insuranceTasks().fillInsuranceData(calculationData, smartAutoTasks))
                .then(smartAutoTasks.calculationType().closeInsuranceModal())
                .clickCreateApplication()
                .then(smartAutoTasks.contact().fillContactInformation(contactData))
                .then(smartAutoTasks.identification().fillIdentification(identificationData))
                .then(smartAutoTasks.bankContact().fillBankContact("212345", BankCode.KOMERCNI_BANKA))
                .then(smartAutoTasks.personalData().fillPersonalData(MaritalStatus.SINGLE, 2, HousingKind.OWN_FLAT, Education.COLLEGE))
                .then(smartAutoTasks.employment().fillEmploymentCertainPeriodNoticePeriod("01.01.2018", "01.01.2035", "01.01.2035", "SW Developer"))
                .then(smartAutoTasks.revenuesAndExpenses().fillRevenuesAndExpenses(30000, 500000, 10000, 10000))
                .then(smartAutoTasks.company().fillCompanyRegistered(companyData))
                .then(smartAutoTasks.validation().validateCustomerPage());
    }
}