Browse Source

DivorceCertificateCommandValidatorTest

Andrew Grant 7 months ago
parent
commit
82aba2413d

+ 6 - 5
src/main/java/scot/carricksoftware/grants/validators/certificates/DivorceCertificateCommandValidator.java

@@ -22,12 +22,13 @@ public class DivorceCertificateCommandValidator {
     public void validate(@SuppressWarnings("unused") DivorceCertificateCommand divorceCertificateCommand, BindingResult bindingResult) {
         logger.debug("Validating death certificate command");
         validateTheTwoPartiesInIsolation(divorceCertificateCommand, bindingResult);
-        if (!bindingResult.hasErrors()) {
-            if (divorceCertificateCommand.getFirstParty() != null &&
-                    divorceCertificateCommand.getSecondParty() != null) {
-                validateThePartiesTogether(divorceCertificateCommand, bindingResult);
-            }
+
+
+        if (divorceCertificateCommand.getFirstParty() != null &&
+                divorceCertificateCommand.getSecondParty() != null) {
+            validateThePartiesTogether(divorceCertificateCommand, bindingResult);
         }
+
     }
 
     private void validateThePartiesTogether(DivorceCertificateCommand divorceCertificateCommand, BindingResult bindingResult) {

+ 9 - 0
src/test/java/scot/carricksoftware/grants/validators/certificates/DivorceCertificateCommandValidatorTest.java

@@ -58,6 +58,15 @@ class DivorceCertificateCommandValidatorTest {
     }
 
 
+    @Test
+    public void notnullFirstPartyTest() {
+        divorceCertificateCommand.setSecondParty(GetRandomPerson());
+        runAndCapture();
+
+        assertEquals("firstParty", stringArgumentCaptor.getValue());
+        assertEquals("The first party cannot be null.", stringArgumentCaptor3.getValue());
+    }
+
     @Test
     public void nullSecondPartyTest() {
         divorceCertificateCommand.setFirstParty(GetRandomPerson());