Ver código fonte

GatherMarriageCertificateTimeLineDataTest

Andrew Grant 1 mês atrás
pai
commit
abbc8919ab

+ 1 - 1
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/GatherMarriageCertificateTimeLineDataImpl.java

@@ -36,7 +36,7 @@ public class GatherMarriageCertificateTimeLineDataImpl implements GatherMarriage
     }
 
     private void gatherBride(Person person) {
-        logger.debug("GatherDeathCertificateTimeLineDataImpl::gatherDeceased");
+        logger.debug("GatherDeathCertificateTimeLineDataImpl::gatherBride");
         List<MarriageCertificate> marriageCertificates = marriageCertificateService.findAllByBride(person);
         if (!marriageCertificates.isEmpty()) {
             gatherMarriageCertificateBrideTimeLineData.gather(marriageCertificates);

+ 79 - 0
src/test/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/GatherMarriageCertificateTimeLineDataTest.java

@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers;
+
+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 scot.carricksoftware.grantswriter.domains.certificates.marriagecertificate.MarriageCertificate;
+import scot.carricksoftware.grantswriter.domains.people.Person;
+import scot.carricksoftware.grantswriter.services.certificates.marriagecertificate.MarriageCertificateService;
+import scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2.marriagecertificate.GatherMarriageCertificateBrideTimeLineData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.when;
+import static scot.carricksoftware.grantswriter.GenerateRandomPeopleValues.GetRandomPerson;
+
+@ExtendWith(MockitoExtension.class)
+class GatherMarriageCertificateTimeLineDataTest {
+
+    private GatherMarriageCertificateTimeLineData gatherMarriageCertificateTimeLineData;
+
+    @Mock
+    private MarriageCertificateService marriageCertificateServiceMock;
+
+    @Mock
+    private GatherMarriageCertificateBrideTimeLineData gatherMarriageCertificateBrideTimeLineDataMock;
+
+    List<MarriageCertificate> marriageCertificates;
+    Person person;
+
+    @BeforeEach
+    void setUp() {
+        gatherMarriageCertificateTimeLineData = new GatherMarriageCertificateTimeLineDataImpl(
+                marriageCertificateServiceMock,
+                gatherMarriageCertificateBrideTimeLineDataMock);
+        marriageCertificates = new ArrayList<>();
+
+        person = GetRandomPerson();
+    }
+
+    @Test
+    void notNullTest() {
+        MarriageCertificate marriageCertificate = new MarriageCertificate();
+        marriageCertificate.setBride(GetRandomPerson());
+        marriageCertificates.add(marriageCertificate);
+        when(marriageCertificateServiceMock.findAllByBride(person)).thenReturn(marriageCertificates);
+
+        gatherMarriageCertificateTimeLineData.gather(person);
+        verify(gatherMarriageCertificateBrideTimeLineDataMock).gather(marriageCertificates);
+    }
+
+    @Test
+    void nullTest() {
+        when(marriageCertificateServiceMock.findAllByBride(person)).thenReturn(marriageCertificates);
+        gatherMarriageCertificateTimeLineData.gather(person);
+        verifyNoInteractions(gatherMarriageCertificateBrideTimeLineDataMock);
+    }
+
+    @Test
+    void gatherMarriageCertificateBrideIsCalledTest() {
+        MarriageCertificate marriageCertificate = new MarriageCertificate();
+        marriageCertificate.setBride(GetRandomPerson());
+        marriageCertificates.add(marriageCertificate);
+        when(marriageCertificateServiceMock.findAllByBride(person)).thenReturn(marriageCertificates);
+        gatherMarriageCertificateTimeLineData.gather(person);
+        verify(gatherMarriageCertificateBrideTimeLineDataMock).gather(marriageCertificates);
+    }
+
+
+}