ソースを参照

Birth Certificate whereBorn added

Andrew Grant 5 ヶ月 前
コミット
5dad9b3350

+ 5 - 0
src/main/java/scot/carricksoftware/grants/commands/certificates/birthcertificates/BirthCertificateCommand.java

@@ -7,6 +7,7 @@ package scot.carricksoftware.grants.commands.certificates.birthcertificates;
 
 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.general.Sex;
 import scot.carricksoftware.grants.enums.certificates.CertificateType;
 
@@ -58,6 +59,10 @@ public interface BirthCertificateCommand {
 
     void setWhenBorn(String whenBorn);
 
+    Place getWhereBorn();
+
+    void setWhereBorn(Place whereBorn);
+
     String getUntrackedWhereBorn();
 
     void setUntrackedWhereBorn(String untrackedWhereBorn);

+ 13 - 0
src/main/java/scot/carricksoftware/grants/commands/certificates/birthcertificates/BirthCertificateCommandImpl.java

@@ -7,6 +7,7 @@ package scot.carricksoftware.grants.commands.certificates.birthcertificates;
 
 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.general.Sex;
 import scot.carricksoftware.grants.enums.certificates.CertificateType;
 
@@ -32,6 +33,8 @@ public class BirthCertificateCommandImpl implements BirthCertificateCommand {
 
     private String whenBorn;
 
+    private Place whereBorn;
+
     private String untrackedWhereBorn;
 
     private Sex sex;
@@ -146,6 +149,16 @@ public class BirthCertificateCommandImpl implements BirthCertificateCommand {
         this.whenBorn = whenBorn;
     }
 
+    @Override
+    public Place getWhereBorn() {
+        return whereBorn;
+    }
+
+    @Override
+    public void setWhereBorn(Place whereBorn) {
+        this.whereBorn = whereBorn;
+    }
+
     @Override
     public String getUntrackedWhereBorn() {
         return untrackedWhereBorn;

+ 14 - 0
src/main/java/scot/carricksoftware/grants/domains/certificates/BirthCertificate.java

@@ -15,6 +15,7 @@ import jakarta.persistence.ManyToOne;
 import org.springframework.format.annotation.DateTimeFormat;
 import scot.carricksoftware.grants.constants.ApplicationConstants;
 import scot.carricksoftware.grants.domains.people.Person;
+import scot.carricksoftware.grants.domains.places.Place;
 import scot.carricksoftware.grants.enums.general.Sex;
 
 @Entity
@@ -30,6 +31,11 @@ public class BirthCertificate extends BaseCertificate {
     @DateTimeFormat(pattern = ApplicationConstants.DATE_TIME_FORMAT)
     private String whenBorn;
 
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @ManyToOne
+    @JoinColumn(name = "`where_born_id`")
+    private Place whereBorn;
+
     @SuppressWarnings("JpaDataSourceORMInspection")
     @Column(name = "`untracked_where_born`")
     private String untrackedWhereBorn;
@@ -77,6 +83,14 @@ public class BirthCertificate extends BaseCertificate {
         this.whenBorn = whenBorn;
     }
 
+    public Place getWhereBorn() {
+        return whereBorn;
+    }
+
+    public void setWhereBorn(Place whereBorn) {
+        this.whereBorn = whereBorn;
+    }
+
     public String getUntrackedWhereBorn() {
         return untrackedWhereBorn;
     }

+ 15 - 1
src/test/java/scot/carricksoftware/grants/commands/certificates/BirthCertificateCommandThreeFieldsTest.java

@@ -9,12 +9,14 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
 import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommandImpl;
+import scot.carricksoftware.grants.domains.places.Place;
 import scot.carricksoftware.grants.enums.general.Sex;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static scot.carricksoftware.grants.GenerateCensusEntryRandomEnums.GetRandomCensusEntrySex;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
+import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomPlace;
 
 class BirthCertificateCommandThreeFieldsTest {
 
@@ -51,7 +53,7 @@ class BirthCertificateCommandThreeFieldsTest {
 
     @Test
     public void getSexTest() {
-        assertNull(command.getWhenBorn());
+        assertNull(command.getSex());
     }
 
     @Test
@@ -61,4 +63,16 @@ class BirthCertificateCommandThreeFieldsTest {
         assertEquals(sex, command.getSex());
     }
 
+    @Test
+    public void getWhereBornTest() {
+        assertNull(command.getWhenBorn());
+    }
+
+    @Test
+    void setWhereBorn() {
+        Place whereBorn = GetRandomPlace();
+        command.setWhereBorn(whereBorn);
+        assertEquals(whereBorn, command.getWhereBorn());
+    }
+
 }

+ 13 - 0
src/test/java/scot/carricksoftware/grants/domains/certificates/BirthCertificateRegistrationTest.java

@@ -9,11 +9,13 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import scot.carricksoftware.grants.domains.places.Organisation;
+import scot.carricksoftware.grants.domains.places.Place;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
 import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomOrganisation;
+import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomPlace;
 
 
 class BirthCertificateRegistrationTest {
@@ -61,5 +63,16 @@ class BirthCertificateRegistrationTest {
         assertEquals(number, certificate.getNumber());
     }
 
+    @Test
+    void getWhereBornTest() {
+        assertNull(certificate.getWhereBorn());
+    }
+
+    @Test
+    void setWhereBornTest() {
+        Place whereBorn = GetRandomPlace();
+        certificate.setWhereBorn(whereBorn);
+        assertEquals(whereBorn, certificate.getWhereBorn());
+    }
 
 }