Преглед на файлове

Places added to birth certificate forms

Andrew Grant преди 5 месеца
родител
ревизия
8589395954

+ 9 - 0
src/main/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerImpl.java

@@ -27,6 +27,7 @@ import scot.carricksoftware.grants.converters.certificates.birthcertificates.Bir
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 import scot.carricksoftware.grants.validators.certificates.birthcertificate.BirthCertificateCommandValidatorImpl;
 
 @SuppressWarnings("LoggingSimilarMessage")
@@ -40,6 +41,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
     private final BirthCertificateConverterImpl birthCertificateConverter;
     private final BirthCertificateCommandValidatorImpl birthCertificateCommandValidatorImpl;
     private final PersonService personService;
+    private final PlaceService placeService;
     private final OrganisationService organisationService;
     private final Capitalisation capitalisation;
 
@@ -49,6 +51,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
                                               BirthCertificateConverterImpl birthCertificateConverter,
                                               BirthCertificateCommandValidatorImpl birthCertificateCommandValidatorImpl,
                                               PersonService personService,
+                                              PlaceService placeService,
                                               OrganisationService organisationService,
                                               Capitalisation capitalisation) {
         this.birthCertificateService = birthCertificateService;
@@ -58,6 +61,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         this.birthCertificateConverter = birthCertificateConverter;
         this.birthCertificateCommandValidatorImpl = birthCertificateCommandValidatorImpl;
         this.personService = personService;
+        this.placeService = placeService;
         this.organisationService = organisationService;
         this.capitalisation = capitalisation;
     }
@@ -69,6 +73,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         logger.debug("BirthCertificateFormControllerImpl::getNewBirthCertificate");
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, new BirthCertificateCommandImpl());
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
         model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.BIRTH_CERTIFICATE_FORM;
     }
@@ -80,6 +85,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         logger.debug("BirthCertificateFormControllerImpl::birthCertificateEdit");
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, birthCertificateService.findById(Long.valueOf(id)));
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
         model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.BIRTH_CERTIFICATE_FORM;
     }
@@ -98,6 +104,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         if (bindingResult.hasErrors()) {
             bindingResult.getAllErrors().forEach(error -> logger.debug(error.getDefaultMessage()));
             model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+            model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
             model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
             return ViewConstants.BIRTH_CERTIFICATE_FORM;
         }
@@ -105,6 +112,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         BirthCertificateCommand savedCommand = birthCertificateService.saveBirthCertificateCommand(birthCertificateCommand);
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, savedCommand);
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
         model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return MappingConstants.REDIRECT + CertificateMappingConstants.BIRTH_CERTIFICATE_SHOW.replace("{id}", "" + savedCommand.getId());
     }
@@ -118,6 +126,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         BirthCertificateCommand savedCommand = birthCertificateConverter.convert(birthCertificateService.findById(Long.valueOf(id)));
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, savedCommand);
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
         model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.BIRTH_CERTIFICATE_FORM;
     }

+ 0 - 1
src/test/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificatesBirthCertificatesTest.java

@@ -100,7 +100,6 @@ public class DataLoadCertificatesBirthCertificatesTest {
         assertEquals(placeMock, captor.getValue().getWhereBorn());
         assertEquals(motherMock, captor.getValue().getMother());
 
-
     }
 
 

+ 5 - 0
src/test/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerSaveOrUpdateTest.java

@@ -21,6 +21,7 @@ import scot.carricksoftware.grants.converters.certificates.birthcertificates.Bir
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 import scot.carricksoftware.grants.validators.certificates.birthcertificate.BirthCertificateCommandValidatorImpl;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -46,6 +47,9 @@ public class BirthCertificateFormControllerSaveOrUpdateTest {
     @Mock
     private PersonService personServiceMock;
 
+    @Mock
+    private PlaceService placeServiceMock;
+
     @Mock
     private OrganisationService organisationServiceMock;
 
@@ -70,6 +74,7 @@ public class BirthCertificateFormControllerSaveOrUpdateTest {
                 birthCertificateConverterMock,
                 birthCertificateCommandValidatorImplMock,
                 personServiceMock,
+                placeServiceMock,
                 organisationServiceMock,
                 capitalisation);
         birthCertificateCommand = new BirthCertificateCommandImpl();

+ 5 - 0
src/test/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerTest.java

@@ -22,6 +22,7 @@ import scot.carricksoftware.grants.domains.certificates.BirthCertificate;
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 import scot.carricksoftware.grants.validators.certificates.birthcertificate.BirthCertificateCommandValidatorImpl;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -50,6 +51,9 @@ public class BirthCertificateFormControllerTest {
     @Mock
     private PersonService personServiceMock;
 
+    @Mock
+    private PlaceService placeServiceMock;
+
     @Mock
     private OrganisationService organisationServiceMock;
 
@@ -70,6 +74,7 @@ public class BirthCertificateFormControllerTest {
                 birthCertificateConverterMock,
                 birthCertificateCommandValidatorImplMock,
                 personServiceMock,
+                placeServiceMock,
                 organisationServiceMock,
                 capitalisationMock);
     }

+ 5 - 0
src/test/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerValidationTest.java

@@ -21,6 +21,7 @@ import scot.carricksoftware.grants.converters.certificates.birthcertificates.Bir
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
 import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
 import scot.carricksoftware.grants.validators.certificates.birthcertificate.BirthCertificateCommandValidatorImpl;
 
 import static org.mockito.Mockito.verify;
@@ -49,6 +50,9 @@ public class BirthCertificateFormControllerValidationTest {
     @Mock
     private PersonService personServiceMock;
 
+    @Mock
+    private PlaceService placeServiceMock;
+
     @Mock
     private OrganisationService organisationServiceMock;
 
@@ -69,6 +73,7 @@ public class BirthCertificateFormControllerValidationTest {
                 birthCertificateConverterMock,
                 birthCertificateCommandValidatorImplMock,
                 personServiceMock,
+                placeServiceMock,
                 organisationServiceMock,
                 capitalisationMock);
     }