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.auto.smartauto.util.MonthUtil;
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.SharedMock;
import org.junit.jupiter.api.Disabled;

@Disabled
@TestScenario(name = "eSubsidies at SMARTauto.")
public class ESubsidiesTest {

    @JiraTestCase(id = "LAMD-T1800")
    @TestCase(name = "Test Full Calculation with Subsidy")
    public void tcESubsidyCalculation(Harness harness, @Key(smart.auto.general) Credentials credentials) {
        SmartAutoTasks smartAutoTasks = harness.tasks().auto().smartAuto();
        CalculationData calculationData = prepareCalculationData(Customer.BUSINESSMAN_WITHOUT_VAT);
        CompanyData companyData = SharedMock.prepareCompanyData();
        ContactData contactData = SharedMock.prepareContactDataMan();
        IdentificationData identificationData = SharedMock.prepareIdentificationDataMan();

        harness.withSmartAuto()
                .openLoginPage()
                .then(smartAutoTasks.login().loginWithCredentials(credentials))
                .then(smartAutoTasks.calculationType().makeSubsidyCalculation(calculationData, companyData, contactData, identificationData, smartAutoTasks))
                .then(smartAutoTasks.verification().checkNewCalculation())
                .then(smartAutoTasks.save().saveNewCalculationPage())
                .clickCreateApplication()
                .then(smartAutoTasks.contact().fillBusinessmanInformation(companyData))
                .then(smartAutoTasks.identification().fillFirstRepresentativeIdentification(contactData, identificationData))
                .then(smartAutoTasks.contact().fillCompanyInformationFallback(companyData))
                .then(smartAutoTasks.bankContact().fillBusinessmanBankContact("212345", BankCode.KOMERCNI_BANKA))
                .then(smartAutoTasks.financial().clickDoubleEntry())
                .then(smartAutoTasks.validation().validateCustomerPage())
                .then(smartAutoTasks.data().checkVehicleInformation(calculationData.getBrand(), calculationData.getModel()))
                .then(smartAutoTasks.search().searchVehicleWithVin("TMBEA6NJXFZ070004", FilterFuel.PETROL, Model.FABIA))
                .then(smartAutoTasks.data().checkAndAddAdditionalData(FilterFuel.PETROL, 5000, "Popis vozidla", ImportVehicle.NO, DealerIsOwner.NO))
                .then(smartAutoTasks.validation().validateVehiclePage())
                .then(smartAutoTasks.account().fillOthersPageForStandard(721456790, "eDotace Testy :D"))
                .then(smartAutoTasks.validation().validateOthersPage())
                .then(smartAutoTasks.application().sendSubsidyApplication());
    }

    private CalculationData prepareCalculationData(Customer customer) {
        CalculationData calculationData = new CalculationData();
        return calculationData.setCustomer(customer)
                .setPrClass(PrClass.CARNEW)
                .setPrGroup(PrGroup.CAR)
                .setGroup(Group.M1)
                .setBrand(Brand.SKODA)
                .setModel(Model.FABIA)
                .setPrice(1500000)
                .setVat(Vat.NO)
                .setUsage(Usage.OTHERS)
                .setMonth(MonthUtil.getCurrentMonth())
                .setSubsidy(Subsidy.ELEKTROMOBILITA)
                .setProduct(Product.AUTO_CREDIT_IC_STANDARD)
                .setFirstPayment(600000);
    }
}