Browse Source

Person domain image added

Andrew Grant 2 months ago
parent
commit
37f3bf309e

+ 16 - 0
src/main/java/scot/carricksoftware/grants/domains/people/Person.java

@@ -8,6 +8,8 @@ package scot.carricksoftware.grants.domains.people;
 import jakarta.persistence.CascadeType;
 import jakarta.persistence.Column;
 import jakarta.persistence.Entity;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
 import jakarta.persistence.OneToMany;
 import scot.carricksoftware.grants.BaseEntity;
 import scot.carricksoftware.grants.domains.census.CensusEntry;
@@ -15,6 +17,7 @@ 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.Image;
 import scot.carricksoftware.grants.domains.images.PersonImage;
 import scot.carricksoftware.grants.domains.text.PersonText;
 
@@ -24,6 +27,11 @@ import java.util.List;
 @Entity
 public class Person extends BaseEntity {
 
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @ManyToOne
+    @JoinColumn(name = "`image_id`")
+    private Image image;
+
     @Column(name = "`first_name`")
     private String firstName;
 
@@ -182,4 +190,12 @@ public class Person extends BaseEntity {
     public void setCertifiedYearOfDeath(String certifiedYearOfDeath) {
         this.certifiedYearOfDeath = certifiedYearOfDeath;
     }
+
+    public Image getImage() {
+        return image;
+    }
+
+    public void setImage(Image image) {
+        this.image = image;
+    }
 }

+ 13 - 0
src/test/java/scot/carricksoftware/grants/domains/people/PersonTest.java

@@ -7,6 +7,7 @@ package scot.carricksoftware.grants.domains.people;
 
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.domains.images.Image;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -70,4 +71,16 @@ class PersonTest {
         assertEquals(string, person.getCertifiedYearOfBirth());
     }
 
+    @Test
+    void getImageTest() {
+        assertNull(person.getImage());
+    }
+
+    @Test
+    void setImageTest() {
+        Image image = new Image();
+        person.setImage(image);
+        assertEquals(image, person.getImage());
+    }
+
 }