package cz.moneta.test.regression.aml;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.banka.tasks.BankaTasks;
import cz.moneta.test.dsl.util.data.client.Address;
import cz.moneta.test.dsl.util.data.client.IdCard;
import cz.moneta.test.dsl.util.data.client.NonClient;
import cz.moneta.test.dsl.util.data.client.OccupationType;
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 java.time.LocalDate;

import static cz.moneta.test.dsl.util.credentials.Keys.ufo;
import static cz.moneta.test.harness.annotations.Environment.TST1;

@TestScenario(name = "Test for client identification during creating of new CIF")
public class AmlClientIdentification {

    @JiraTestCase(id = "AML-T1374")
    @TestCase(name = "Test for client identification during creating of new CIF", environments = {TST1})
    public void tc_clientIdentification(Harness harness, @Key(ufo.banka.anotherOmBanker) Credentials banker) {
        BankaTasks bankaTasks = harness.tasks().ufo().banka();

        NonClient nonClient = harness.data().newNonClient()
                .withBirthNumber("8101104352")
                .withFirstName("Servác")
                .withLastName("Novák")
                .withIdCard(new IdCard("222000366", LocalDate.of(2014, 9, 9), LocalDate.of(2024, 9, 9)))
                .withIdNumber("222000366")
                .withResidencyAddress(Address.builder()
                        .street("nám. sv. Václava")
                        .descriptiveNumber("1")
                        .orientationNumber("14")
                        .city("Brandýs nad Labem-Stará Boleslav")
                        .cityPart("Stará Boleslav")
                        .zip("25001")
                        .build())
                .withPlaceOfBirth("Brázdim")
                .withOccupationType(OccupationType.IT_GUYS);

        harness.withUfo()
                .openLoginPage()
                .then(bankaTasks.login().withCredentials(banker))
                .then(bankaTasks.search().findByNewRc(nonClient.birthNumber()))
                .clickCreateNewCustomerOnIdDocumentsCopy()
                .then(bankaTasks.newClient().selectDocumentIdCard("OP se strojově čitelnými údaji"))
                .onTabletCommunicationErrorPage()
                .continueToSignError()
                .clickCenterButton()
                .onCreateNewCif()
                .then(bankaTasks.newClient().createCustomerWith(nonClient))
                .then(bankaTasks.newClient().checkRegistryLoad(nonClient))
                .fillResidency()
                .fillCity("Brandýs nad Labem")
                .fillPostOffice("Brandýs nad Labem")
                .fillContacts()
                .checkRefuseEmail()
                .fillEmployment()
                .selectIncomeType("Příjem z podnikání")
                .selectIncomeSubtype("Příjem z podnikání")
                .selectEmployment(nonClient.occupationType().getUfoValue())
                .fillAdditionalInformation()
                .clickNoPep()
                .clickConsents()
                .clickContinue()
                .onSignerSelectionPage_TIS050()
                .clickSignedPersonallyAndContinue()
                .closePrintWindow()
                .onClientSignatureConfirmationPage()
                .clickContinue()
                .onClientContractSignPage()
                .clickCenterButton()
                .onScanDocumentsPage()
                .clickSkipButton()
                .onMainClientPage()
                .checkBirthNumberLabel(nonClient.birthNumber())
                .checkIdCardLabel(nonClient.idCardNumber())
                .verifyThatCifIsValid();
    }
}
