فهرست منبع

DivorceCertificateDateFieldsValidatorTest

Andrew Grant 3 ماه پیش
والد
کامیت
7e38738ece

+ 51 - 0
src/test/java/scot/carricksoftware/grants/validators/certificates/divorcecertificate/DivorceCertificateDateFieldsValidatorTest.java

@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.validators.certificates.divorcecertificate;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.validation.BindingResult;
+import scot.carricksoftware.grants.commands.certificates.divorcecertificates.DivorceCertificateCommand;
+import scot.carricksoftware.grants.commands.certificates.divorcecertificates.DivorceCertificateCommandImpl;
+import scot.carricksoftware.grants.validators.helpers.ValidateDateTypes;
+
+import static org.mockito.Mockito.verify;
+
+@ExtendWith(MockitoExtension.class)
+class DivorceCertificateDateFieldsValidatorTest {
+
+    @Mock
+    private BindingResult bindingResultMock;
+
+    @Mock
+    private ValidateDateTypes validateDateTypesMock;
+
+    private DivorceCertificateCommand divorceCertificateCommand;
+
+    @BeforeEach
+    void setUp() {
+        DivorceCertificateCommandDatesValidator divorceCertificateDateFieldsValidator = new DivorceCertificateCommandDatesValidatorImpl(validateDateTypesMock);
+        divorceCertificateCommand = new DivorceCertificateCommandImpl();
+        divorceCertificateDateFieldsValidator.validate(divorceCertificateCommand, bindingResultMock);
+    }
+
+    @Test
+    void validateDateFieldsTest() {
+        verify(validateDateTypesMock).validatePastDate(divorceCertificateCommand.getFirstPartyDate(), "firstPartyDate",
+                "The first party date cannot be null.", "The format should be dd/MM/yyyy.", "Date should not be in the future.",bindingResultMock);
+        verify(validateDateTypesMock).validatePastDate(divorceCertificateCommand.getSecondPartyDate(), "secondPartyDate",
+                "The second party date cannot be null.", "The format should be dd/MM/yyyy.", "Date should not be in the future.",bindingResultMock);
+        verify(validateDateTypesMock).validatePastDate(divorceCertificateCommand.getRegisteredDate(), "registeredDate",
+                "The registered date cannot be null.", "The format should be dd/MM/yyyy.", "Date should not be in the future.",bindingResultMock);
+    }
+
+
+
+
+}

+ 0 - 5
src/test/java/scot/carricksoftware/grants/validators/helpers/ValidateNotSamePersonTest.java

@@ -42,7 +42,6 @@ class ValidateNotSamePersonTest {
             firstPerson = GetRandomPerson();
             secondPerson = GetRandomPerson();
         } while (firstPerson == secondPerson);
-        secondPerson.setFirstName("blogs");
         firstPersonFieldName = GetRandomString();
         secondPersonFieldName = GetRandomString();
     }
@@ -72,8 +71,4 @@ class ValidateNotSamePersonTest {
         verifyNoInteractions(bindingResultMock);
     }
 
-
-
-
-
 }