Andrew Grant před 5 měsíci
rodič
revize
00c49b66c0

+ 0 - 2
src/main/java/scot/carricksoftware/grantswriter/BaseEntity.java

@@ -17,12 +17,10 @@ public class BaseEntity {
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
 
-    @SuppressWarnings("unused")
     public void setId(Long id) {
         this.id = id;
     }
 
-    @SuppressWarnings("unused")
     public Long getId() {
         return id;
     }

+ 36 - 0
src/test/java/scot/carricksoftware/grantswriter/BaseEntityTest.java

@@ -0,0 +1,36 @@
+/*
+ * Copyright (c)  04 Feb 2025, Andrew Grant of Carrick Software .
+ * All rights reserved.
+ */
+
+package scot.carricksoftware.grantswriter;
+
+
+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.grantswriter.GenerateRandomNumberValues.GetRandomLong;
+
+public class BaseEntityTest {
+
+    private BaseEntity entity;
+
+    @BeforeEach
+    public void setUp() {
+        entity = new BaseEntity();
+    }
+
+    @Test
+    public void getIdTest() {
+        assertNull(entity.getId());
+    }
+
+    @Test
+    public void setIdTest() {
+        Long id = GetRandomLong();
+        entity.setId(id);
+        assertEquals(id, entity.getId());
+    }
+}

+ 23 - 0
src/test/java/scot/carricksoftware/grantswriter/GenerateRandomNumberValues.java

@@ -0,0 +1,23 @@
+/*
+ * Copyright (c)  04 Feb 2025, Andrew Grant of Carrick Software .
+ * All rights reserved.
+ */
+
+package scot.carricksoftware.grantswriter;
+
+import java.util.Random;
+
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class GenerateRandomNumberValues {
+
+    private static final Random rand = new Random();
+
+    public static Long GetRandomLong() {
+        return rand.nextLong();
+    }
+
+
+}

+ 4 - 4
src/test/java/scot/carricksoftware/grantswriter/controllers/IndexControllerTest.java

@@ -26,21 +26,21 @@ class IndexControllerTest {
 
     @Test
     void specifyOutput() {
-        assertEquals("not-available",controller.specifyOutput(modelMock));
+        assertEquals("not-available", controller.specifyOutput(modelMock));
     }
 
     @Test
     void createTex() {
-        assertEquals("not-available",controller.createTex(modelMock));
+        assertEquals("not-available", controller.createTex(modelMock));
     }
 
     @Test
     void buildPDF() {
-        assertEquals("not-available",controller.buildPDF(modelMock));
+        assertEquals("not-available", controller.buildPDF(modelMock));
     }
 
     @Test
     void print() {
-        assertEquals("not-available",controller.print(modelMock));
+        assertEquals("not-available", controller.print(modelMock));
     }
 }