Browse Source

Death certificate validators (4)

Andrew Grant 3 months ago
parent
commit
4dc009d937

+ 0 - 1
src/main/java/scot/carricksoftware/grants/validators/certificates/deathcertificate/DeathCertificateDateFieldsValidatorImpl.java

@@ -12,7 +12,6 @@ import org.springframework.validation.BindingResult;
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
 import scot.carricksoftware.grants.constants.ValidationConstants;
 import scot.carricksoftware.grants.validators.helpers.ValidateDateTypes;
-import scot.carricksoftware.grants.validators.helpers.ValidateTypesImpl;
 
 @Component
 public class DeathCertificateDateFieldsValidatorImpl implements DeathCertificateDateFieldsValidator {

+ 1 - 39
src/main/java/scot/carricksoftware/grants/validators/certificates/deathcertificate/DeathCertificateNullFieldsValidatorImpl.java

@@ -11,7 +11,6 @@ import org.springframework.stereotype.Component;
 import org.springframework.validation.BindingResult;
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
 import scot.carricksoftware.grants.constants.ValidationConstants;
-import scot.carricksoftware.grants.validators.helpers.ValidateDateTypes;
 import scot.carricksoftware.grants.validators.helpers.ValidateTypesImpl;
 
 @Component
@@ -20,18 +19,15 @@ public class DeathCertificateNullFieldsValidatorImpl implements DeathCertificate
     private static final Logger logger = LogManager.getLogger(DeathCertificateNullFieldsValidatorImpl.class);
 
     private final ValidateTypesImpl validateTypes;
-    private final ValidateDateTypes validateDateTypes;
 
-    public DeathCertificateNullFieldsValidatorImpl(ValidateTypesImpl validateTypes, ValidateDateTypes validateDateTypes) {
+    public DeathCertificateNullFieldsValidatorImpl(ValidateTypesImpl validateTypes) {
         this.validateTypes = validateTypes;
-        this.validateDateTypes = validateDateTypes;
     }
 
     @Override
     public void validate(DeathCertificateCommand deathCertificateCommand, BindingResult bindingResult) {
         validateCertificateNumber(deathCertificateCommand, bindingResult);
         validateCertificateType(deathCertificateCommand, bindingResult);
-        validateCertificateDate(deathCertificateCommand, bindingResult);
         validateVolume(deathCertificateCommand, bindingResult);
         validateNumber(deathCertificateCommand, bindingResult);
         validateDeceased(deathCertificateCommand, bindingResult);
@@ -40,8 +36,6 @@ public class DeathCertificateNullFieldsValidatorImpl implements DeathCertificate
         validateInformantQualification(deathCertificateCommand, bindingResult);
         validateCertificateSource(deathCertificateCommand, bindingResult);
         validateRegistrationAuthority(deathCertificateCommand, bindingResult);
-        validateWhenBorn(deathCertificateCommand, bindingResult);
-        validateWhenDied(deathCertificateCommand, bindingResult);
     }
 
     private void validateDeceased(DeathCertificateCommand deathCertificateCommand, BindingResult bindingResult) {
@@ -94,36 +88,4 @@ public class DeathCertificateNullFieldsValidatorImpl implements DeathCertificate
         validateTypes.validateCertificateType(deathCertificateCommand.getCertificateType(), "certificateType",ValidationConstants.CERTIFICATE_TYPE_IS_NULL, bindingResult);
     }
 
-    private void validateCertificateDate(DeathCertificateCommand deathCertificateCommand, BindingResult bindingResult) {
-        logger.debug("DeathCertificateNullFieldsValidator::validateCertifixateDate");
-        validateDateTypes.validatePastDate(deathCertificateCommand.getCertificateDate(),
-                "certificateDate",
-                ValidationConstants.CERTIFICATE_DATE_IS_NULL,
-                ValidationConstants.DATE_IS_INVALID,
-                ValidationConstants.DATE_IN_FUTURE,
-                bindingResult);
-    }
-
-    private void validateWhenBorn(DeathCertificateCommand deathCertificateCommand, BindingResult bindingResult) {
-        logger.debug("DeathCertificateNullFieldsValidator::validateWhenBorn");
-        validateDateTypes.validatePastDate(deathCertificateCommand.getWhenBorn(),
-                "whenBorn",
-                ValidationConstants.WHEN_BORN_IS_NULL,
-                ValidationConstants.DATE_IS_INVALID,
-                ValidationConstants.DATE_IN_FUTURE,
-                bindingResult);
-    }
-
-    private void validateWhenDied(DeathCertificateCommand deathCertificateCommand, BindingResult bindingResult) {
-        logger.debug("DeathCertificateNullFieldsValidator::validateWhenDied");
-        validateDateTypes.validatePastDate(deathCertificateCommand.getWhenDied(),
-                "whenDied",
-                ValidationConstants.WHEN_DIED_IS_NULL,
-                ValidationConstants.DATE_IS_INVALID,
-                ValidationConstants.DATE_IN_FUTURE,
-                bindingResult);
-    }
-
-
-
 }

+ 0 - 1
src/test/java/scot/carricksoftware/grants/validators/certificates/deathcertificate/DeathCertificateDateFieldsValidatorImplTest.java

@@ -14,7 +14,6 @@ import org.springframework.validation.BindingResult;
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
 import scot.carricksoftware.grants.validators.helpers.ValidateDateTypes;
-import scot.carricksoftware.grants.validators.helpers.ValidateTypesImpl;
 
 import static org.mockito.Mockito.verify;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;

+ 2 - 11
src/test/java/scot/carricksoftware/grants/validators/certificates/deathcertificate/DeathCertificateFieldsValidatorImplTest.java

@@ -15,9 +15,7 @@ import scot.carricksoftware.grants.commands.certificates.deathcertificates.Death
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
 import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.domains.places.Organisation;
-import scot.carricksoftware.grants.enums.certificates.CertificateType;
 import scot.carricksoftware.grants.enums.general.Sex;
-import scot.carricksoftware.grants.validators.helpers.ValidateDateTypes;
 import scot.carricksoftware.grants.validators.helpers.ValidateTypesImpl;
 
 import static org.mockito.Mockito.verify;
@@ -34,8 +32,6 @@ class DeathCertificateFieldsValidatorImplTest {
     @Mock
     private ValidateTypesImpl validateTypesMock;
 
-    @Mock
-    private ValidateDateTypes validateDateTypesMock;
 
     @Mock
     private BindingResult bindingResultMock;
@@ -48,15 +44,14 @@ class DeathCertificateFieldsValidatorImplTest {
     private String number;
     private String causeOfDeath;
     private String informantQualification;
-    private String whenDied;
     private final Sex sex = Sex.FEMALE;
     private Organisation certificateSource;
+    @SuppressWarnings("unused")
     private Organisation registrationAuthority;
-    private CertificateType certificateType;
 
     @BeforeEach
     void setUp() {
-        deathCertificateNullFieldsValidator = new DeathCertificateNullFieldsValidatorImpl(validateTypesMock, validateDateTypesMock);
+        deathCertificateNullFieldsValidator = new DeathCertificateNullFieldsValidatorImpl(validateTypesMock);
         deathCertificateCommand = new DeathCertificateCommandImpl();
 
         deceased = GetRandomPerson();
@@ -65,11 +60,7 @@ class DeathCertificateFieldsValidatorImplTest {
         number = GetRandomString();
         causeOfDeath = GetRandomString();
         informantQualification = GetRandomString();
-        whenDied = GetRandomString();
         certificateSource = GetRandomOrganisation();
-        certificateType = CertificateType.EXTRACT;
-        registrationAuthority = GetRandomOrganisation();
-        String certificateDate = GetRandomString();
         deathCertificateCommand.setDeceased(deceased);
         deathCertificateCommand.setCertificateNumber(certificateNumber);
         deathCertificateCommand.setVolume(volume);