Parcourir la source

CensusEntry Converters

Andrew Grant il y a 5 mois
Parent
commit
62544bb752

+ 3 - 1
docs/enums.txt

@@ -5,4 +5,6 @@
 5: Test getter and setter in Domain Enums Test
 6: Command
 8: Command getter and setter in Command Enums Test
-9:
+9: Converter
+10: Converter Test
+11: Bootstrap

+ 2 - 0
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadCensus.java

@@ -14,6 +14,7 @@ import scot.carricksoftware.grants.commands.census.CensusCommandImpl;
 import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
 import scot.carricksoftware.grants.commands.census.CensusEntryCommandImpl;
 import scot.carricksoftware.grants.domains.places.Place;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 import scot.carricksoftware.grants.services.census.CensusEntryService;
 import scot.carricksoftware.grants.services.census.CensusService;
 import scot.carricksoftware.grants.services.people.PersonService;
@@ -65,6 +66,7 @@ public class DataLoadCensus {
         censusEntryCommand.setName("Archie Grant");
         censusEntryCommand.setCensus(censusService.findById(1L));
         censusEntryCommand.setPerson(personService.findById(1L));
+        censusEntryCommand.setRelationship(CensusEntryRelationship.COUSIN);
         censusEntryService.saveCensusEntryCommand(censusEntryCommand);
     }
 

+ 1 - 0
src/main/java/scot/carricksoftware/grants/converters/census/CensusEntryCommandConverterImpl.java

@@ -19,6 +19,7 @@ public class CensusEntryCommandConverterImpl implements CensusEntryCommandConver
         result.setName(source.getName());
         result.setCensus(source.getCensus());
         result.setPerson(source.getPerson());
+        result.setRelationship(source.getRelationship());
         return result;
     }
 

+ 1 - 0
src/main/java/scot/carricksoftware/grants/converters/census/CensusEntryConverterImpl.java

@@ -20,6 +20,7 @@ public class CensusEntryConverterImpl implements CensusEntryConverter {
         result.setName(source.getName());
         result.setCensus(source.getCensus());
         result.setPerson(source.getPerson());
+        result.setRelationship(source.getRelationship());
         return result;
     }
 }

+ 5 - 0
src/test/java/scot/carricksoftware/grants/converters/census/CensusEntryCommandConverterTest.java

@@ -12,8 +12,10 @@ import scot.carricksoftware.grants.commands.census.CensusEntryCommandImpl;
 import scot.carricksoftware.grants.domains.census.Census;
 import scot.carricksoftware.grants.domains.census.CensusEntry;
 import scot.carricksoftware.grants.domains.people.Person;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static scot.carricksoftware.grants.GenerateCensusEntryRelationshipRandomValue.GetRandomCensusEntryRelationship;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
 import static scot.carricksoftware.grants.GenerateRandomCensusValues.GetRandomCensus;
 import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
@@ -32,6 +34,7 @@ class CensusEntryCommandConverterTest {
     void convertTest() {
         Long id = GetRandomLong();
         String name = GetRandomString();
+        CensusEntryRelationship relationship = GetRandomCensusEntryRelationship();
         CensusEntryCommand source = new CensusEntryCommandImpl();
         Census census = GetRandomCensus();
         Person person = GetRandomPerson();
@@ -41,6 +44,7 @@ class CensusEntryCommandConverterTest {
         source.setName(name);
         source.setCensus(census);
         source.setPerson(person);
+        source.setRelationship(relationship);
 
 
         CensusEntry target = converter.convert(source);
@@ -50,5 +54,6 @@ class CensusEntryCommandConverterTest {
         assertEquals(name, target.getName());
         assertEquals(census, target.getCensus());
         assertEquals(person, target.getPerson());
+        assertEquals(relationship, target.getRelationship());
     }
 }

+ 5 - 0
src/test/java/scot/carricksoftware/grants/converters/census/CensusEntryConverterTest.java

@@ -11,8 +11,10 @@ import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
 import scot.carricksoftware.grants.domains.census.Census;
 import scot.carricksoftware.grants.domains.census.CensusEntry;
 import scot.carricksoftware.grants.domains.people.Person;
+import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static scot.carricksoftware.grants.GenerateCensusEntryRelationshipRandomValue.GetRandomCensusEntryRelationship;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
 import static scot.carricksoftware.grants.GenerateRandomCensusValues.GetRandomCensus;
 import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
@@ -33,12 +35,14 @@ class CensusEntryConverterTest {
         String name = GetRandomString();
         Census census = GetRandomCensus();
         CensusEntry source = new CensusEntry();
+        CensusEntryRelationship relationship = GetRandomCensusEntryRelationship();
         Person person = GetRandomPerson();
 
         source.setId(id);
         source.setName(name);
         source.setCensus(census);
         source.setPerson(person);
+        source.setRelationship(relationship);
 
         CensusEntryCommand target = converter.convert(source);
 
@@ -47,5 +51,6 @@ class CensusEntryConverterTest {
         assertEquals(name, target.getName());
         assertEquals(census, target.getCensus());
         assertEquals(person, target.getPerson());
+        assertEquals(relationship, target.getRelationship());
     }
 }