Andrew Grant 5 месяцев назад
Родитель
Сommit
ee6b3c4e04

+ 6 - 1
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificates.java

@@ -19,6 +19,7 @@ import scot.carricksoftware.grants.services.certificates.birthcertificates.Birth
 import scot.carricksoftware.grants.services.certificates.deathcertificates.DeathCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 
 
 @Component
@@ -29,14 +30,16 @@ public class DataLoadCertificates {
     private final OrganisationService organisationService;
     private final BirthCertificateService birthCertificateService;
     private final PersonService personService;
+    private final PlaceService placeService;
     private final DeathCertificateService deathCertificateService;
 
     public DataLoadCertificates(OrganisationService organisationService,
                                 BirthCertificateService birthCertificateService,
-                                PersonService personService, DeathCertificateService deathCertificateService) {
+                                PersonService personService, PlaceService placeService, DeathCertificateService deathCertificateService) {
         this.organisationService = organisationService;
         this.birthCertificateService = birthCertificateService;
         this.personService = personService;
+        this.placeService = placeService;
         this.deathCertificateService = deathCertificateService;
     }
 
@@ -67,6 +70,8 @@ public class DataLoadCertificates {
         birthCertificateCommand.setUntrackedFather("Untracked Father");
 
         birthCertificateCommand.setMother(personService.findById(2L));
+        birthCertificateCommand.setWhereBorn(placeService.findById(1L));
+        birthCertificateCommand.setUntrackedWhereBorn("Birth Place");
 
         birthCertificateService.saveBirthCertificateCommand(birthCertificateCommand);
     }

+ 17 - 2
src/test/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificatesBirthCertificatesTest.java

@@ -9,12 +9,14 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
 import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.domains.places.Organisation;
+import scot.carricksoftware.grants.domains.places.Place;
 import scot.carricksoftware.grants.enums.certificates.CertificateType;
 import scot.carricksoftware.grants.enums.general.Sex;
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.certificates.deathcertificates.DeathCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.verify;
@@ -38,6 +40,9 @@ public class DataLoadCertificatesBirthCertificatesTest {
     @Mock
     private PersonService personServiceMock;
 
+    @Mock
+    private PlaceService placeServiceMock;
+
     @Mock
     private Person fatherMock;
 
@@ -47,6 +52,9 @@ public class DataLoadCertificatesBirthCertificatesTest {
     @Mock
     private Person newBornMock;
 
+    @Mock
+    private Place placeMock;
+
     @Mock
     private Organisation registrationAuthorityMock;
 
@@ -55,7 +63,11 @@ public class DataLoadCertificatesBirthCertificatesTest {
 
     @BeforeEach
     public void setup() {
-        dataLoadCertificates = new DataLoadCertificates(organisationServiceMock, birthCertificateServiceMock, personServiceMock, deathCertificateServiceMock);
+        dataLoadCertificates = new DataLoadCertificates(organisationServiceMock,
+                birthCertificateServiceMock,
+                personServiceMock,
+                placeServiceMock,
+                deathCertificateServiceMock);
     }
 
     @Test
@@ -64,9 +76,11 @@ public class DataLoadCertificatesBirthCertificatesTest {
         when(personServiceMock.findById(1L)).thenReturn(fatherMock);
         when(personServiceMock.findById(2L)).thenReturn(motherMock);
         when(personServiceMock.findById(3L)).thenReturn(newBornMock);
+        when(placeServiceMock.findById(1L)).thenReturn(placeMock);
         when(organisationServiceMock.findByName("Registration Authority")).thenReturn(registrationAuthorityMock);
         when(organisationServiceMock.findByName("Certificate Source")).thenReturn(certificateSourceMock);
 
+
         dataLoadCertificates.load();
 
         verify(birthCertificateServiceMock).saveBirthCertificateCommand(captor.capture());
@@ -80,9 +94,10 @@ public class DataLoadCertificatesBirthCertificatesTest {
         assertEquals(newBornMock, captor.getValue().getNewBorn());
         assertEquals(Sex.MALE, captor.getValue().getSex());
         assertEquals("25/01/1953 01:01", captor.getValue().getWhenBorn());
-        assertEquals("Edinburgh", captor.getValue().getUntrackedWhereBorn());
         assertEquals(fatherMock, captor.getValue().getFather());
         assertEquals("Untracked Father", captor.getValue().getUntrackedFather());
+        assertEquals("Birth Place", captor.getValue().getUntrackedWhereBorn());
+        assertEquals(placeMock, captor.getValue().getWhereBorn());
         assertEquals(motherMock, captor.getValue().getMother());
 
 

+ 10 - 1
src/test/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificatesDeathCertificatesTest.java

@@ -9,6 +9,7 @@ import scot.carricksoftware.grants.services.certificates.birthcertificates.Birth
 import scot.carricksoftware.grants.services.certificates.deathcertificates.DeathCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.verify;
@@ -31,10 +32,18 @@ public class DataLoadCertificatesDeathCertificatesTest {
     @Mock
     private PersonService personServiceMock;
 
+    @Mock
+    private PlaceService placeServiceMock;
+
 
     @BeforeEach
     public void setup() {
-        dataLoadCertificates = new DataLoadCertificates(organisationServiceMock, birthCertificateServiceMock, personServiceMock, deathCertificateServiceMock);
+        dataLoadCertificates = new DataLoadCertificates(
+                organisationServiceMock,
+                birthCertificateServiceMock,
+                personServiceMock,
+                placeServiceMock,
+                deathCertificateServiceMock);
     }
 
     @Test