ソースを参照

DataLoadOrganisationsTest::LoadDeathCertificates (2)

Andrew Grant 6 ヶ月 前
コミット
9fb1401132

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

@@ -11,9 +11,12 @@ import org.springframework.context.annotation.Profile;
 import org.springframework.stereotype.Component;
 import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
 import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommandImpl;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
 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;
 
@@ -26,13 +29,15 @@ public class DataLoadCertificates {
     private final OrganisationService organisationService;
     private final BirthCertificateService birthCertificateService;
     private final PersonService personService;
+    private final DeathCertificateService deathCertificateService;
 
     public DataLoadCertificates(OrganisationService organisationService,
                                 BirthCertificateService birthCertificateService,
-                                PersonService personService) {
+                                PersonService personService, DeathCertificateService deathCertificateService) {
         this.organisationService = organisationService;
         this.birthCertificateService = birthCertificateService;
         this.personService = personService;
+        this.deathCertificateService = deathCertificateService;
     }
 
     public void load() {
@@ -68,7 +73,9 @@ public class DataLoadCertificates {
 
     private void loadDeathCertificates() {
         logger.debug("DataLoadCertificates::LoadDeathCertificates");
+        DeathCertificateCommand deathCertificateCommand = new DeathCertificateCommandImpl();
 
+        deathCertificateService.saveDeathCertificateCommand(deathCertificateCommand);
     }
 
 

+ 6 - 2
src/test/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificatesTest.java → src/test/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificatesBirthCertificatesTest.java

@@ -12,6 +12,7 @@ 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.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;
 
@@ -21,13 +22,16 @@ import static org.mockito.Mockito.when;
 
 
 @ExtendWith(MockitoExtension.class)
-public class DataLoadCertificatesTest {
+public class DataLoadCertificatesBirthCertificatesTest {
 
     private DataLoadCertificates dataLoadCertificates;
 
     @Mock
     private BirthCertificateService birthCertificateServiceMock;
 
+    @Mock
+    private DeathCertificateService deathCertificateServiceMock;
+
     @Mock
     private OrganisationService organisationServiceMock;
 
@@ -51,7 +55,7 @@ public class DataLoadCertificatesTest {
 
     @BeforeEach
     public void setup() {
-        dataLoadCertificates = new DataLoadCertificates(organisationServiceMock, birthCertificateServiceMock, personServiceMock);
+        dataLoadCertificates = new DataLoadCertificates(organisationServiceMock, birthCertificateServiceMock, personServiceMock, deathCertificateServiceMock);
     }
 
     @Test

+ 46 - 0
src/test/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificatesDeathCertificatesTest.java

@@ -0,0 +1,46 @@
+package scot.carricksoftware.grants.bootstrap;
+
+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.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 static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.verify;
+
+
+@ExtendWith(MockitoExtension.class)
+public class DataLoadCertificatesDeathCertificatesTest {
+
+    private DataLoadCertificates dataLoadCertificates;
+
+    @Mock
+    private BirthCertificateService birthCertificateServiceMock;
+
+    @Mock
+    private DeathCertificateService deathCertificateServiceMock;
+
+    @Mock
+    private OrganisationService organisationServiceMock;
+
+    @Mock
+    private PersonService personServiceMock;
+
+
+    @BeforeEach
+    public void setup() {
+        dataLoadCertificates = new DataLoadCertificates(organisationServiceMock, birthCertificateServiceMock, personServiceMock, deathCertificateServiceMock);
+    }
+
+    @Test
+    void DeathCertificateIsCreatedTest() {
+        dataLoadCertificates.load();
+        verify(deathCertificateServiceMock).saveDeathCertificateCommand(any());
+    }
+
+}