package cz.moneta.test.sandbox.dsl.util;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.data.client.Address;
import cz.moneta.test.dsl.util.data.client.NonClient;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import org.junit.jupiter.api.Assertions;

import java.util.Date;

@TestScenario(name = "Tests for TestUtils.")
public class DefaultsTest {

    @TestCase(name = "Tests unique birth number generator happy path.")
    void shouldGenerateRandomBirthNumber(Harness harness) {
        String birthNumber = harness.data().newNonClient().birthNumber();
        Assertions.assertNotNull(birthNumber);
    }

    @TestCase(name = "Tests unique mobile phone number generator happy path.")
    void shouldGenerateMobileNumber(Harness harness) {
        String mobileNumber = harness.data().newNonClient().mobileNumber();
        Assertions.assertNotNull(mobileNumber);
    }

    @TestCase(name = "Tests unique fix line phone number generator happy path.")
    void shouldGenerateFixLineNumber(Harness harness) {
        String fixPhoneNumberHome = harness.data().newNonClient().fixPhoneNumberHome();
        Assertions.assertNotNull(fixPhoneNumberHome);
    }

    @TestCase(name = "Tests proper handling of default methods")
    void shouldReturnAddress(Harness harness) {
        Address residencyAddress = harness.data().newNonClient().residencyAddress();
        Assertions.assertNotNull(residencyAddress);
    }

    @TestCase(name = "Tests proper parsing of @Value annotation")
    void shouldReturnOccupationCode(Harness harness) {
        int occupationCode = Integer.parseInt(harness.data().newNonClient().occupationType().getHCisValue());
        Assertions.assertEquals(8, occupationCode);
    }

    @TestCase(name = "Tests proper parsing of @Date annotation.")
    void shouldReturnIdCardExpiryDate(Harness harness) {
        Date expiryDate = harness.data().newNonClient().idCardExpiredRaw();
        Assertions.assertNotNull(expiryDate);
    }

    @TestCase(name = "Manual fraud check number")
    void shouldReturnRightCheckNumber(Harness harness) {
        NonClient client = harness.data().newNonClient()
                .withBirthNumber("9108273977")
                .withIdNumber("209351641")
                .withIdNumberExpiration("8.3.2028");
        Assertions.assertEquals("0", client.idNumberCheckDigit());
    }

}