ソースを参照

Birth Certificate family in converters

Andrew Grant 6 ヶ月 前
コミット
f3f5636075

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

@@ -65,4 +65,24 @@ public interface BirthCertificateCommand {
     Sex getSex();
 
     void setSex(Sex sex);
+
+    Person getFather();
+
+    void setFather(Person father);
+
+    String getUntrackedFather();
+
+    void setUntrackedFather(String untrackedFather);
+
+    String getFatherRank();
+
+    void setFatherRank(String fatherRank);
+
+    Person getMother();
+
+    void setMother(Person mother);
+
+    String getDateAndPlaceOfMarriage();
+
+    void setDateAndPlaceOfMarriage(String dateAndPlaceOfMarriage);
 }

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

@@ -36,6 +36,16 @@ public class BirthCertificateCommandImpl implements BirthCertificateCommand {
 
     private Sex sex;
 
+    private Person father;
+
+    private String untrackedFather;
+
+    private String fatherRank;
+
+    private Person mother;
+
+    private String dateAndPlaceOfMarriage;
+
 
     public Long getId() {
         return Id;
@@ -155,4 +165,54 @@ public class BirthCertificateCommandImpl implements BirthCertificateCommand {
     public void setSex(Sex sex) {
         this.sex = sex;
     }
+
+    @Override
+    public Person getFather() {
+        return father;
+    }
+
+    @Override
+    public void setFather(Person father) {
+        this.father = father;
+    }
+
+    @Override
+    public String getUntrackedFather() {
+        return untrackedFather;
+    }
+
+    @Override
+    public void setUntrackedFather(String untrackedFather) {
+        this.untrackedFather = untrackedFather;
+    }
+
+    @Override
+    public String getFatherRank() {
+        return fatherRank;
+    }
+
+    @Override
+    public void setFatherRank(String fatherRank) {
+        this.fatherRank = fatherRank;
+    }
+
+    @Override
+    public Person getMother() {
+        return mother;
+    }
+
+    @Override
+    public void setMother(Person mother) {
+        this.mother = mother;
+    }
+
+    @Override
+    public String getDateAndPlaceOfMarriage() {
+        return dateAndPlaceOfMarriage;
+    }
+
+    @Override
+    public void setDateAndPlaceOfMarriage(String dateAndPlaceOfMarriage) {
+        this.dateAndPlaceOfMarriage = dateAndPlaceOfMarriage;
+    }
 }

+ 6 - 0
src/main/java/scot/carricksoftware/grants/converters/certificates/birthcertificates/BirthCertificateCommandConverterImpl.java

@@ -29,6 +29,12 @@ public class BirthCertificateCommandConverterImpl implements BirthCertificateCom
         target.setSex(source.getSex());
         target.setWhenBorn(source.getWhenBorn());
         target.setWhereBorn(source.getWhereBorn());
+        target.setFather(source.getFather());
+        target.setUntrackedFather(source.getUntrackedFather());
+        target.setFatherRank(source.getFatherRank());
+        target.setMother(source.getMother());
+        target.setDateAndPlaceOfMarriage(source.getDateAndPlaceOfMarriage());
+
 
         return target;
     }

+ 5 - 0
src/main/java/scot/carricksoftware/grants/converters/certificates/birthcertificates/BirthCertificateConverterImpl.java

@@ -33,6 +33,11 @@ public class BirthCertificateConverterImpl implements BirthCertificateConverter
         target.setSex(source.getSex());
         target.setWhenBorn(source.getWhenBorn());
         target.setWhereBorn(source.getWhereBorn());
+        target.setFather(source.getFather());
+        target.setUntrackedFather(source.getUntrackedFather());
+        target.setFatherRank(source.getFatherRank());
+        target.setMother(source.getMother());
+        target.setDateAndPlaceOfMarriage(source.getDateAndPlaceOfMarriage());
 
         return target;
     }

+ 90 - 0
src/test/java/scot/carricksoftware/grants/commands/certificates/BirthCertificateParentsTest.java

@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 24/03/2025, 17:20. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.commands.certificates;
+
+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.people.Person;
+
+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.GenerateRandomPeopleValues.GetRandomPerson;
+
+
+class BirthCertificateParentsTest {
+
+    private BirthCertificateCommand command;
+
+    @BeforeEach
+    void setUp() {
+        command = new BirthCertificateCommandImpl();
+    }
+
+    @Test
+    void getFatherTest() {
+        assertNull(command.getFather());
+    }
+
+    @Test
+    void setFatherTest() {
+        Person father = GetRandomPerson();
+        command.setFather(father);
+        assertEquals(father, command.getFather());
+    }
+
+    @Test
+    void getUntrackedFatherTest() {
+        assertNull(command.getUntrackedFather());
+    }
+
+    @Test
+    void setUntrackedFatherTest() {
+        String untrackedFather = GetRandomString();
+        command.setUntrackedFather(untrackedFather);
+        assertEquals(untrackedFather, command.getUntrackedFather());
+    }
+
+    @Test
+    void getFatherRankTest() {
+        assertNull(command.getFatherRank());
+    }
+
+    @Test
+    void setFatherRankTest() {
+        String fatherRank = GetRandomString();
+        command.setFatherRank(fatherRank);
+        assertEquals(fatherRank, command.getFatherRank());
+    }
+
+    @Test
+    void MotherTest() {
+        assertNull(command.getMother());
+    }
+
+    @Test
+    void setMotherTest() {
+        Person mother = GetRandomPerson();
+        command.setMother(mother);
+        assertEquals(mother, command.getMother());
+    }
+
+    @Test
+    void getDateAndPlaceOfMarriageTest() {
+        assertNull(command.getDateAndPlaceOfMarriage());
+    }
+
+    @Test
+    void setDateAndPLaceOfMarriageTest() {
+        String dateAndPLaceOfMarriage = GetRandomString();
+        command.setDateAndPlaceOfMarriage(dateAndPLaceOfMarriage);
+        assertEquals(dateAndPLaceOfMarriage, command.getDateAndPlaceOfMarriage());
+    }
+
+
+}

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

@@ -62,8 +62,6 @@ public class BirthCertificateFormControllerSaveOrUpdateTest {
     private BirthCertificateCommand birthCertificateCommand;
 
 
-
-
     @BeforeEach
     public void setUp() {
         Capitalisation capitalisation = new CapitalisationImpl();

+ 16 - 0
src/test/java/scot/carricksoftware/grants/converters/certificates/birthcertificates/BirthCertificateCommandConverterTest.java

@@ -46,6 +46,12 @@ class BirthCertificateCommandConverterTest {
         Sex sex = Sex.MALE;
         String whenBorn = GetRandomString();
         String whereBorn = GetRandomString();
+        Person father = GetRandomPerson();
+        Person mother = GetRandomPerson();
+        String dateAndPlaceOfMarriage = GetRandomString();
+        String fatherRank = GetRandomString();
+        String untrackedFather = GetRandomString();
+
 
         source.setId(id);
         source.setNewBorn(person);
@@ -59,6 +65,11 @@ class BirthCertificateCommandConverterTest {
         source.setSex(sex);
         source.setWhenBorn(whenBorn);
         source.setWhereBorn(whereBorn);
+        source.setFather(father);
+        source.setMother(mother);
+        source.setDateAndPlaceOfMarriage(dateAndPlaceOfMarriage);
+        source.setFatherRank(fatherRank);
+        source.setUntrackedFather(untrackedFather);
 
 
         BirthCertificate target = converter.convert(source);
@@ -76,5 +87,10 @@ class BirthCertificateCommandConverterTest {
         assertEquals(sex, target.getSex());
         assertEquals(whereBorn, target.getWhereBorn());
         assertEquals(whenBorn, target.getWhenBorn());
+        assertEquals(dateAndPlaceOfMarriage, target.getDateAndPlaceOfMarriage());
+        assertEquals(fatherRank, target.getFatherRank());
+        assertEquals(untrackedFather, target.getUntrackedFather());
+        assertEquals(father, target.getFather());
+        assertEquals(mother, target.getMother());
     }
 }

+ 16 - 0
src/test/java/scot/carricksoftware/grants/converters/certificates/birthcertificates/BirthCertificateConverterTest.java

@@ -45,6 +45,12 @@ class BirthCertificateConverterTest {
         Sex sex = Sex.MALE;
         String whenBorn = GetRandomString();
         String whereBorn = GetRandomString();
+        Person father = GetRandomPerson();
+        Person mother = GetRandomPerson();
+        String dateAndPlaceOfMarriage = GetRandomString();
+        String fatherRank = GetRandomString();
+        String untrackedFather = GetRandomString();
+
 
         source.setId(id);
         source.setNewBorn(person);
@@ -58,6 +64,11 @@ class BirthCertificateConverterTest {
         source.setSex(sex);
         source.setWhenBorn(whenBorn);
         source.setWhereBorn(whereBorn);
+        source.setFather(father);
+        source.setMother(mother);
+        source.setDateAndPlaceOfMarriage(dateAndPlaceOfMarriage);
+        source.setFatherRank(fatherRank);
+        source.setUntrackedFather(untrackedFather);
 
 
         BirthCertificateCommand target = converter.convert(source);
@@ -75,6 +86,11 @@ class BirthCertificateConverterTest {
         assertEquals(sex, target.getSex());
         assertEquals(whereBorn, target.getWhereBorn());
         assertEquals(whenBorn, target.getWhenBorn());
+        assertEquals(dateAndPlaceOfMarriage, target.getDateAndPlaceOfMarriage());
+        assertEquals(fatherRank, target.getFatherRank());
+        assertEquals(untrackedFather, target.getUntrackedFather());
+        assertEquals(father, target.getFather());
+        assertEquals(mother, target.getMother());
 
     }
 }

+ 3 - 3
src/test/java/scot/carricksoftware/grants/validators/certificates/birthcertificate/BirthCertificateCommandPartThreeValidatorTest.java

@@ -43,7 +43,7 @@ class BirthCertificateCommandPartThreeValidatorTest {
         String where = GetRandomString();
         when(birthCertificateCommandMock.getWhereBorn()).thenReturn(where);
         validator.validate(birthCertificateCommandMock, bindingResultMock);
-        verify(validateTypesMock).validateNullOrEmptyString(where, "whereBorn","Where born cannot be null.", bindingResultMock);
+        verify(validateTypesMock).validateNullOrEmptyString(where, "whereBorn", "Where born cannot be null.", bindingResultMock);
     }
 
     @Test
@@ -51,7 +51,7 @@ class BirthCertificateCommandPartThreeValidatorTest {
         Sex sex = Sex.MALE;
         when(birthCertificateCommandMock.getSex()).thenReturn(sex);
         validator.validate(birthCertificateCommandMock, bindingResultMock);
-        verify(validateTypesMock).validateSex(sex, "sex","Sex cannot be null.", bindingResultMock);
+        verify(validateTypesMock).validateSex(sex, "sex", "Sex cannot be null.", bindingResultMock);
     }
 
     @Test
@@ -59,7 +59,7 @@ class BirthCertificateCommandPartThreeValidatorTest {
         String whenBorn = GetRandomString();
         when(birthCertificateCommandMock.getWhenBorn()).thenReturn(whenBorn);
         validator.validate(birthCertificateCommandMock, bindingResultMock);
-        verify(validateTypesMock).validatePastDateAndTime(whenBorn, "whenBorn","When born cannot be null.", "The format should be dd/MM/yyyy hh:mm.","Date should not be in the future.",bindingResultMock);
+        verify(validateTypesMock).validatePastDateAndTime(whenBorn, "whenBorn", "When born cannot be null.", "The format should be dd/MM/yyyy hh:mm.", "Date should not be in the future.", bindingResultMock);
     }