|
@@ -12,12 +12,14 @@ import org.mockito.Mock;
|
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.validation.BindingResult;
|
|
|
import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
|
|
import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
|
|
|
|
|
+import scot.carricksoftware.grants.domains.people.Person;
|
|
|
import scot.carricksoftware.grants.enums.general.Sex;
|
|
import scot.carricksoftware.grants.enums.general.Sex;
|
|
|
import scot.carricksoftware.grants.validators.helpers.ValidateTypes;
|
|
import scot.carricksoftware.grants.validators.helpers.ValidateTypes;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
import static org.mockito.Mockito.verify;
|
|
|
import static org.mockito.Mockito.when;
|
|
import static org.mockito.Mockito.when;
|
|
|
import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
|
|
import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
|
|
|
|
|
+import static scot.carricksoftware.grants.GenerateRandomPeopleValues.GetRandomPerson;
|
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
class BirthCertificateCommandPartThreeValidatorTest {
|
|
class BirthCertificateCommandPartThreeValidatorTest {
|
|
@@ -62,5 +64,15 @@ class BirthCertificateCommandPartThreeValidatorTest {
|
|
|
verify(validateTypesMock).validatePastDateAndTime(whenBorn, "whenBorn", "When born cannot be null.", "The format should be dd/MM/yyyy hh:mm.", "Date should not be in the future.", bindingResultMock);
|
|
verify(validateTypesMock).validatePastDateAndTime(whenBorn, "whenBorn", "When born cannot be null.", "The format should be dd/MM/yyyy hh:mm.", "Date should not be in the future.", bindingResultMock);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void validateFatherAndUntrackedFatherTest() {
|
|
|
|
|
+ String untrackedFather = GetRandomString();
|
|
|
|
|
+ Person father = GetRandomPerson();
|
|
|
|
|
+ when(birthCertificateCommandMock.getUntrackedFather()).thenReturn(untrackedFather);
|
|
|
|
|
+ when(birthCertificateCommandMock.getFather()).thenReturn(father);
|
|
|
|
|
+ validator.validate(birthCertificateCommandMock, bindingResultMock);
|
|
|
|
|
+ verify(validateTypesMock).validatePersonAndUntrackedPerson(father, untrackedFather, "father", "unTrackedFather","One and only one father and untracked father must be specified.", bindingResultMock);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|