Browse Source

Added The other side of person relationship - domain tests

Andrew Grant 6 months ago
parent
commit
68c4a26060

+ 38 - 0
src/main/java/scot/carricksoftware/grants/commands/people/PersonCommand.java

@@ -5,6 +5,16 @@
 
 package scot.carricksoftware.grants.commands.people;
 
+import scot.carricksoftware.grants.domains.census.CensusEntry;
+import scot.carricksoftware.grants.domains.certificates.BirthCertificate;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+import scot.carricksoftware.grants.domains.certificates.DivorceCertificate;
+import scot.carricksoftware.grants.domains.certificates.MarriageCertificate;
+import scot.carricksoftware.grants.domains.images.PersonImage;
+import scot.carricksoftware.grants.domains.text.PersonText;
+
+import java.util.List;
+
 public interface PersonCommand {
 
     Long getId();
@@ -26,4 +36,32 @@ public interface PersonCommand {
     String getCertifiedYearOfBirth();
 
     void setCertifiedYearOfBirth(String certifiedYearOfBirth);
+
+    List<BirthCertificate> getBirthCertificates();
+
+    void setBirthCertificates(List<BirthCertificate> birthCertificates);
+
+    List<DeathCertificate> getDeathCertificates();
+
+    void setDeathCertificates(List<DeathCertificate> deathCertificates);
+
+    List<MarriageCertificate> getMarriageCertificates();
+
+    void setMarriageCertificates(List<MarriageCertificate> marriageCertificates);
+
+    List<DivorceCertificate> getDivorceCertificates();
+
+    void setDivorceCertificates(List<DivorceCertificate> divorceCertificates);
+
+    List<CensusEntry> getCensusEntries();
+
+    void setCensusEntries(List<CensusEntry> censusEntries);
+
+    List<PersonImage> getPersonImages();
+
+    void setPersonImages(List<PersonImage> personImages);
+
+    List<PersonText> getPersonTexts();
+
+    void setPersonTexts(List<PersonText> personTexts);
 }

+ 100 - 5
src/main/java/scot/carricksoftware/grants/commands/people/PersonCommandImpl.java

@@ -5,17 +5,42 @@
 
 package scot.carricksoftware.grants.commands.people;
 
+import scot.carricksoftware.grants.domains.census.CensusEntry;
+import scot.carricksoftware.grants.domains.certificates.BirthCertificate;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+import scot.carricksoftware.grants.domains.certificates.DivorceCertificate;
+import scot.carricksoftware.grants.domains.certificates.MarriageCertificate;
+import scot.carricksoftware.grants.domains.images.PersonImage;
+import scot.carricksoftware.grants.domains.text.PersonText;
+
+import java.util.ArrayList;
+import java.util.List;
+
 public class PersonCommandImpl implements PersonCommand {
 
-    Long Id;
+    private Long Id;
+
+    private String firstName;
+
+    private String lastName;
+
+    private String recordedYearOfBirth;
+
+    private String certifiedYearOfBirth;
+
+    private List<BirthCertificate> birthCertificates = new ArrayList<>();
 
-    String firstName;
+    private List<DeathCertificate> deathCertificates = new ArrayList<>();
 
-    String lastName;
+    private List<MarriageCertificate> marriageCertificates = new ArrayList<>();
 
-    String recordedYearOfBirth;
+    private List<DivorceCertificate> divorceCertificates = new ArrayList<>();
 
-    String certifiedYearOfBirth;
+    private List<CensusEntry> censusEntries = new ArrayList<>();
+
+    private List<PersonImage> personImages = new ArrayList<>();
+
+    private List<PersonText> personTexts = new ArrayList<>();
 
 
     public Long getId() {
@@ -66,5 +91,75 @@ public class PersonCommandImpl implements PersonCommand {
         this.certifiedYearOfBirth = certifiedYearOfBirth;
     }
 
+    @Override
+    public List<BirthCertificate> getBirthCertificates() {
+        return birthCertificates;
+    }
+
+    @Override
+    public void setBirthCertificates(List<BirthCertificate> birthCertificates) {
+        this.birthCertificates = birthCertificates;
+    }
+
+    @Override
+    public List<DeathCertificate> getDeathCertificates() {
+        return deathCertificates;
+    }
+
+    @Override
+    public void setDeathCertificates(List<DeathCertificate> deathCertificates) {
+        this.deathCertificates = deathCertificates;
+    }
+
+    @Override
+    public List<MarriageCertificate> getMarriageCertificates() {
+        return marriageCertificates;
+    }
+
+    @Override
+    public void setMarriageCertificates(List<MarriageCertificate> marriageCertificates) {
+        this.marriageCertificates = marriageCertificates;
+    }
+
+   @Override
+   public List<DivorceCertificate> getDivorceCertificates() {
+        return divorceCertificates;
+    }
+
+    @Override
+    public void setDivorceCertificates(List<DivorceCertificate> divorceCertificates) {
+        this.divorceCertificates = divorceCertificates;
+    }
+
+    @Override
+    public List<CensusEntry> getCensusEntries() {
+        return censusEntries;
+    }
+
+    @Override
+    public void setCensusEntries(List<CensusEntry> censusEntries) {
+        this.censusEntries = censusEntries;
+    }
+
+    @Override
+    public List<PersonImage> getPersonImages() {
+        return personImages;
+    }
+
+    @Override
+    public void setPersonImages(List<PersonImage> personImages) {
+        this.personImages = personImages;
+    }
+
+    @Override
+    public List<PersonText> getPersonTexts() {
+        return personTexts;
+    }
+
+    @Override
+    public void setPersonTexts(List<PersonText> personTexts) {
+        this.personTexts = personTexts;
+    }
+
 
 }

+ 87 - 0
src/test/java/scot/carricksoftware/grants/commands/people/PersonCommandReverseRelationshipSettersTest.java

@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 18/03/2025, 01:54. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.commands.people;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.domains.census.CensusEntry;
+import scot.carricksoftware.grants.domains.certificates.BirthCertificate;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+import scot.carricksoftware.grants.domains.certificates.DivorceCertificate;
+import scot.carricksoftware.grants.domains.certificates.MarriageCertificate;
+import scot.carricksoftware.grants.domains.images.PersonImage;
+import scot.carricksoftware.grants.domains.text.PersonText;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class PersonCommandReverseRelationshipSettersTest {
+
+    PersonCommand command;
+
+    @BeforeEach
+    void setUp() {
+        command = new PersonCommandImpl();
+    }
+
+    @Test
+    void setBirthCertificatesTest() {
+        List<BirthCertificate> certificates = new ArrayList<>();
+        certificates.add(new BirthCertificate());
+        command.setBirthCertificates(certificates);
+        assertEquals(certificates, command.getBirthCertificates());
+    }
+
+    @Test
+    void getDeathCertificatesTest() {
+        List<DeathCertificate> certificates = new ArrayList<>();
+        certificates.add(new DeathCertificate());
+        command.setDeathCertificates(certificates);
+        assertEquals(certificates, command.getDeathCertificates());
+    }
+
+    @Test
+    void getMarriageCertificatesTest() {
+        List<MarriageCertificate> certificates = new ArrayList<>();
+        certificates.add(new MarriageCertificate());
+        command.setMarriageCertificates(certificates);
+        assertEquals(certificates, command.getMarriageCertificates());
+    }
+
+    @Test
+    void getDivorceCertificatesTest() {
+        List<DivorceCertificate> certificates = new ArrayList<>();
+        certificates.add(new DivorceCertificate());
+        command.setDivorceCertificates(certificates);
+        assertEquals(certificates, command.getDivorceCertificates());
+    }
+
+    @Test
+    void getCensusEntriesTest() {
+        List<CensusEntry> certificates = new ArrayList<>();
+        certificates.add(new CensusEntry());
+        command.setCensusEntries(certificates);
+        assertEquals(certificates, command.getCensusEntries());
+    }
+
+    @Test
+    void getPersonImagesTest() {
+        List<PersonImage> certificates = new ArrayList<>();
+        certificates.add(new PersonImage());
+        command.setPersonImages(certificates);
+        assertEquals(certificates, command.getPersonImages());
+    }
+
+    @Test
+    void getPersonTextsTest() {
+        List<PersonText> certificates = new ArrayList<>();
+        certificates.add(new PersonText());
+        command.setPersonTexts(certificates);
+        assertEquals(certificates, command.getPersonTexts());
+    }
+}