Browse Source

Add appendixImage to domains

Andrew Grant 1 month ago
parent
commit
a82db4fd95

+ 7 - 0
docs/images.txt

@@ -0,0 +1,7 @@
+Use width 400 as the default
+Images must be :
+    a jpg
+    less than 1M in size
+
+To convert from pdf to jpg use the site https://www.ilovepdf.com/pdf_to_jpg
+To change reduce the size of a jpg use  $ jpegoptim --size=800k

+ 92 - 0
src/main/java/scot/carricksoftware/grants/domains/images/AppendixImage.java

@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 18/03/2025, 01:50. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.domains.images;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+import scot.carricksoftware.grants.BaseEntity;
+
+@Entity
+public class AppendixImage extends BaseEntity {
+
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @ManyToOne
+    @JoinColumn(name = "`image_id`")
+    private Image image;
+
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @Column(name = "`level`")
+    private String level;
+
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @Column(name = "`order`")
+    private String order;
+
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @Column(name = "`caption`")
+    private String caption;
+
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @Column(name = "`height`")
+    private String height;
+
+    @SuppressWarnings("JpaDataSourceORMInspection")
+    @Column(name = "`width`")
+    private String width;
+
+    public Image getImage() {
+        return image;
+    }
+
+    public void setImage(Image image) {
+        this.image = image;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public void setLevel(String level) {
+        this.level = level;
+    }
+
+
+    public String getOrder() {
+        return order;
+    }
+
+    public void setOrder(String order) {
+        this.order = order;
+    }
+
+    public String getCaption() {
+        return caption;
+    }
+
+    public void setCaption(String caption) {
+        this.caption = caption;
+    }
+
+    public String getHeight() {
+        return height;
+    }
+
+    public void setHeight(String height) {
+        this.height = height;
+    }
+
+    public String getWidth() {
+        return width;
+    }
+
+    public void setWidth(String width) {
+        this.width = width;
+    }
+
+
+}

+ 109 - 0
src/test/java/scot/carricksoftware/grants/domains/images/AppendixImageTest.java

@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 28/03/2025, 09:54. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.domains.images;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+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.GenerateRandomNumberValues.GetRandomLong;
+
+class AppendixImageTest {
+
+    private AppendixImage image;
+
+    @BeforeEach
+    void setUp() {
+        image = new AppendixImage();
+    }
+
+    @Test
+    public void getIdTest() {
+        assertNull(image.getId());
+    }
+
+    @Test
+    public void setIdTest() {
+        Long id = GetRandomLong();
+        image.setId(id);
+        assertEquals(id, image.getId());
+    }
+
+    @Test
+    public void getCaptionTest() {
+        assertNull(image.getCaption());
+    }
+
+    @Test
+    public void setCaptionTest() {
+        String caption = GetRandomString();
+        image.setCaption(caption);
+        assertEquals(caption, image.getCaption());
+    }
+
+    @Test
+    public void getHeightTest() {
+        assertNull(image.getHeight());
+    }
+
+    @Test
+    public void setHeightTest() {
+        String height = GetRandomString();
+        image.setHeight(height);
+        assertEquals(height, image.getHeight());
+    }
+
+    @Test
+    public void getWidthTest() {
+        assertNull(image.getWidth());
+    }
+
+    @Test
+    public void setWidthTest() {
+        String width = GetRandomString();
+        image.setWidth(width);
+        assertEquals(width, image.getWidth());
+    }
+
+    @Test
+    public void getImageTest() {
+        assertNull(image.getImage());
+    }
+
+    @Test
+    public void setImageTest() {
+        Image theImage = new Image();
+        image.setImage(theImage);
+        assertEquals(theImage, image.getImage());
+    }
+
+    @Test
+    public void getOrderTest() {
+        assertNull(image.getOrder());
+    }
+
+    @Test
+    public void setOrderTest() {
+        String order = GetRandomString();
+        image.setOrder(order);
+        assertEquals(order, image.getOrder());
+    }
+
+    @Test
+    public void getLevelTest() {
+        assertNull(image.getLevel());
+    }
+
+    @Test
+    public void setLevelTest() {
+        String level = GetRandomString();
+        image.setLevel(level);
+        assertEquals(level, image.getLevel());
+    }
+
+}