|
@@ -14,11 +14,13 @@ import org.springframework.validation.BindingResult;
|
|
|
import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
|
|
import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
|
|
|
import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
|
|
import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
|
|
|
import scot.carricksoftware.grants.domains.people.Person;
|
|
import scot.carricksoftware.grants.domains.people.Person;
|
|
|
|
|
+import scot.carricksoftware.grants.domains.places.Place;
|
|
|
import scot.carricksoftware.grants.validators.helpers.ValidateTwoFieldTypes;
|
|
import scot.carricksoftware.grants.validators.helpers.ValidateTwoFieldTypes;
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
import static org.mockito.Mockito.verify;
|
|
|
import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
|
|
import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
|
|
|
import static scot.carricksoftware.grants.GenerateRandomPeopleValues.GetRandomPerson;
|
|
import static scot.carricksoftware.grants.GenerateRandomPeopleValues.GetRandomPerson;
|
|
|
|
|
+import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomPlace;
|
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
class DeathCertificateUntrackedFieldsValidatorTest {
|
|
class DeathCertificateUntrackedFieldsValidatorTest {
|
|
@@ -35,6 +37,10 @@ class DeathCertificateUntrackedFieldsValidatorTest {
|
|
|
|
|
|
|
|
private Person spouse;
|
|
private Person spouse;
|
|
|
private String untrackedSpouse;
|
|
private String untrackedSpouse;
|
|
|
|
|
+ private Person father;
|
|
|
|
|
+ private String untrackedFather;
|
|
|
|
|
+ private Place whereDied;
|
|
|
|
|
+ private String untrackedWhereDied;
|
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach
|
|
@BeforeEach
|
|
@@ -42,10 +48,19 @@ class DeathCertificateUntrackedFieldsValidatorTest {
|
|
|
deathCertificateUntrackedFieldsValidator = new DeathCertificateUntrackedFieldsValidatorImpl(validateTwoFieldTypesMock);
|
|
deathCertificateUntrackedFieldsValidator = new DeathCertificateUntrackedFieldsValidatorImpl(validateTwoFieldTypesMock);
|
|
|
deathCertificateCommand = new DeathCertificateCommandImpl();
|
|
deathCertificateCommand = new DeathCertificateCommandImpl();
|
|
|
spouse = GetRandomPerson();
|
|
spouse = GetRandomPerson();
|
|
|
|
|
+ father = GetRandomPerson();
|
|
|
|
|
+ whereDied = GetRandomPlace();
|
|
|
untrackedSpouse = GetRandomString();
|
|
untrackedSpouse = GetRandomString();
|
|
|
|
|
+ untrackedFather = GetRandomString();
|
|
|
|
|
+ untrackedWhereDied = GetRandomString();
|
|
|
|
|
|
|
|
deathCertificateCommand.setSpouse(spouse);
|
|
deathCertificateCommand.setSpouse(spouse);
|
|
|
deathCertificateCommand.setUntrackedSpouse(untrackedSpouse);
|
|
deathCertificateCommand.setUntrackedSpouse(untrackedSpouse);
|
|
|
|
|
+ deathCertificateCommand.setFather(father);
|
|
|
|
|
+ deathCertificateCommand.setUntrackedFather(untrackedFather);
|
|
|
|
|
+
|
|
|
|
|
+ deathCertificateCommand.setWhereDied(whereDied);
|
|
|
|
|
+ deathCertificateCommand.setUntrackedWhereDied(untrackedWhereDied);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -53,6 +68,10 @@ class DeathCertificateUntrackedFieldsValidatorTest {
|
|
|
deathCertificateUntrackedFieldsValidator.validate(deathCertificateCommand, bindingResultMock);
|
|
deathCertificateUntrackedFieldsValidator.validate(deathCertificateCommand, bindingResultMock);
|
|
|
verify(validateTwoFieldTypesMock).validatePersonAndUntrackedPerson(spouse, untrackedSpouse, "spouse", "untrackedSpouse",
|
|
verify(validateTwoFieldTypesMock).validatePersonAndUntrackedPerson(spouse, untrackedSpouse, "spouse", "untrackedSpouse",
|
|
|
"One and only one spouse and untracked spouse must be specified.", bindingResultMock);
|
|
"One and only one spouse and untracked spouse must be specified.", bindingResultMock);
|
|
|
|
|
+ verify(validateTwoFieldTypesMock).validatePersonAndUntrackedPerson(father, untrackedFather, "father", "untrackedFather",
|
|
|
|
|
+ "One and only one father and untracked father must be specified.", bindingResultMock);
|
|
|
|
|
+ verify(validateTwoFieldTypesMock).validatePlaceAndUntrackedPlace(whereDied, untrackedWhereDied, "whereDied", "untrackedWhereDied",
|
|
|
|
|
+ "One and only one where died and untracked where died must be specified.", bindingResultMock);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|