Parcourir la source

CensusEntry Worker added to enum and domain

Andrew Grant il y a 5 mois
Parent
commit
f8c77ca763

+ 12 - 0
src/main/java/scot/carricksoftware/grants/domains/census/CensusEntry.java

@@ -11,6 +11,7 @@ import scot.carricksoftware.grants.domains.people.Person;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryGaelic;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryCondition;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryWorker;
 
 @Entity
 public class CensusEntry extends BaseEntity {
@@ -36,6 +37,9 @@ public class CensusEntry extends BaseEntity {
     @Enumerated(EnumType.STRING)
     private CensusEntryCondition condition;
 
+    @Enumerated(EnumType.STRING)
+    private CensusEntryWorker worker;
+
     public Person getPerson() {
         return person;
     }
@@ -87,4 +91,12 @@ public class CensusEntry extends BaseEntity {
     public void setGaelic(CensusEntryGaelic gaelic) {
         this.gaelic = gaelic;
     }
+
+    public CensusEntryWorker getWorker() {
+        return worker;
+    }
+
+    public void setWorker(CensusEntryWorker worker) {
+        this.worker = worker;
+    }
 }

+ 1 - 1
src/main/java/scot/carricksoftware/grants/enums/censusentry/CensusEntryGaelic.java

@@ -7,7 +7,7 @@ package scot.carricksoftware.grants.enums.censusentry;
 
 public enum CensusEntryGaelic {
     @SuppressWarnings("unused") GAELIC("Gaelic"),
-    @SuppressWarnings({"unused", "SpellCheckingInspection"}) GAELICANDENGLISH("Gaelic and English");
+    GAELIC_AND_ENGLISH("Gaelic and English");
 
     @SuppressWarnings("unused")
     public final String label;

+ 20 - 0
src/main/java/scot/carricksoftware/grants/enums/censusentry/CensusEntryWorker.java

@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.enums.censusentry;
+
+public enum CensusEntryWorker {
+    @SuppressWarnings("unused") WORKER("Worker"),
+    @SuppressWarnings("unused") EMPLOYER("Widower"),
+    @SuppressWarnings("unused") OWN_ACCOUNT("Own Account"),;
+
+    @SuppressWarnings("unused")
+    public final String label;
+
+    @SuppressWarnings("unused")
+    CensusEntryWorker(String label) {
+        this.label = label;
+    }
+}

+ 1 - 1
src/main/resources/application.properties

@@ -2,7 +2,7 @@ spring.application.name=grants
 server.port=8086
 server.servlet.context-path=/grants
 spring.mvc.format.date=dd-MM-yyyy
-spring.profiles.active=uat
+spring.profiles.active=dev
 logging.level.scot.carricksoftware=debug
 
 

+ 9 - 1
src/test/java/scot/carricksoftware/grants/GenerateCensusEntryRandomEnums.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryCondition;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryGaelic;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryWorker;
 
 import java.util.Random;
 
@@ -33,7 +34,6 @@ public class GenerateCensusEntryRandomEnums {
         return gaelicArray[randomInt];
     }
 
-
     public static CensusEntryRelationship GetRandomCensusEntryRelationship() {
         CensusEntryRelationship[] relationships = CensusEntryRelationship.values();
 
@@ -41,4 +41,12 @@ public class GenerateCensusEntryRandomEnums {
         int randomInt = random.nextInt(0, relationships.length );
         return relationships[randomInt];
     }
+
+    public static CensusEntryWorker GetRandomCensusEntryWorker() {
+        CensusEntryWorker[] workers = CensusEntryWorker.values();
+
+        Random random = new Random();
+        int randomInt = random.nextInt(0, workers.length );
+        return workers[randomInt];
+    }
 }

+ 13 - 0
src/test/java/scot/carricksoftware/grants/domains/census/CensusEntryEnumTest.java

@@ -12,6 +12,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryCondition;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryGaelic;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryWorker;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -63,4 +64,16 @@ class CensusEntryEnumTest {
         assertEquals(gaelic, entry.getGaelic());
     }
 
+    @Test
+    void getWorkerTest() {
+        assertNull(entry.getCondition());
+    }
+
+    @Test
+    void setWorkerTest() {
+        CensusEntryWorker worker = GetRandomCensusEntryWorker();
+        entry.setWorker(worker);
+        assertEquals(worker, entry.getWorker());
+    }
+
 }