Prechádzať zdrojové kódy

Enum Relationship in Command

Andrew Grant 5 mesiacov pred
rodič
commit
ea15c25938

+ 5 - 3
docs/enums.txt

@@ -1,6 +1,8 @@
 1:Create Enum
 2: Domain
 3: Domain getter and setter
-4 : Random Value
-5: test getter and setter
-6: Enums Test
+4 :Random Value
+5: Test getter and setter in Domain Enums Test
+6: Command
+8: Command getter and setter in Command Enums Test
+9:

+ 5 - 0
src/main/java/scot/carricksoftware/grants/commands/census/CensusEntryCommand.java

@@ -7,6 +7,7 @@ package scot.carricksoftware.grants.commands.census;
 
 import scot.carricksoftware.grants.domains.census.Census;
 import scot.carricksoftware.grants.domains.people.Person;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 
 public interface CensusEntryCommand {
 
@@ -25,4 +26,8 @@ public interface CensusEntryCommand {
     Person getPerson();
 
     void setPerson(Person person);
+
+    CensusEntryRelationship getRelationship();
+
+    void setRelationship(CensusEntryRelationship relationship);
 }

+ 13 - 0
src/main/java/scot/carricksoftware/grants/commands/census/CensusEntryCommandImpl.java

@@ -7,6 +7,7 @@ package scot.carricksoftware.grants.commands.census;
 
 import scot.carricksoftware.grants.domains.census.Census;
 import scot.carricksoftware.grants.domains.people.Person;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 
 public class CensusEntryCommandImpl implements CensusEntryCommand {
 
@@ -18,6 +19,8 @@ public class CensusEntryCommandImpl implements CensusEntryCommand {
 
     private Person person;
 
+    private CensusEntryRelationship relationship;
+
     public Long getId() {
         return id;
     }
@@ -55,4 +58,14 @@ public class CensusEntryCommandImpl implements CensusEntryCommand {
     public void setPerson(Person person) {
         this.person = person;
     }
+
+    @Override
+    public CensusEntryRelationship getRelationship() {
+        return relationship;
+    }
+
+    @Override
+    public void setRelationship(CensusEntryRelationship relationship) {
+        this.relationship = relationship;
+    }
 }

+ 38 - 0
src/test/java/scot/carricksoftware/grants/commands/census/CensusEntryCommandEnumTest.java

@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 20/03/2025, 11:15. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.commands.census;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static scot.carricksoftware.grants.GenerateCensusEntryRelationshipRandomValue.GetRandomCensusEntryRelationship;
+
+class CensusEntryCommandEnumTest {
+
+    private CensusEntryCommand command;
+
+    @BeforeEach
+    void setUp() {
+        command = new CensusEntryCommandImpl();
+    }
+
+    @Test
+    void getRelationshipTest() {
+        assertNull(command.getRelationship());
+    }
+
+    @Test
+    void setNameTest() {
+        CensusEntryRelationship relationship = GetRandomCensusEntryRelationship();
+        command.setRelationship(relationship);
+        assertEquals(relationship, command.getRelationship());
+    }
+
+}