Bläddra i källkod

CensusEntryCondition in Converters

Andrew Grant 5 månader sedan
förälder
incheckning
9388a15f76

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

@@ -12,6 +12,7 @@ import scot.carricksoftware.grants.domains.census.CensusEntry;
 @Component
 public class CensusEntryCommandConverterImpl implements CensusEntryCommandConverter {
 
+    @SuppressWarnings("DuplicatedCode")
     @Override
     public CensusEntry convert(CensusEntryCommand source) {
         CensusEntry result = new CensusEntry();
@@ -20,6 +21,7 @@ public class CensusEntryCommandConverterImpl implements CensusEntryCommandConver
         result.setCensus(source.getCensus());
         result.setPerson(source.getPerson());
         result.setRelationship(source.getRelationship());
+        result.setCondition(source.getCondition());
         return result;
     }
 

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

@@ -13,6 +13,7 @@ import scot.carricksoftware.grants.domains.census.CensusEntry;
 @Component
 public class CensusEntryConverterImpl implements CensusEntryConverter {
 
+    @SuppressWarnings("DuplicatedCode")
     @Override
     public CensusEntryCommand convert(CensusEntry source) {
         CensusEntryCommand result = new CensusEntryCommandImpl();
@@ -21,6 +22,7 @@ public class CensusEntryConverterImpl implements CensusEntryConverter {
         result.setCensus(source.getCensus());
         result.setPerson(source.getPerson());
         result.setRelationship(source.getRelationship());
+        result.setCondition(source.getCondition());
         return result;
     }
 }

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

@@ -12,9 +12,11 @@ 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.CensusEntryCondition;
 import scot.carricksoftware.grants.enums.censusentry.CensusEntryRelationship;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static scot.carricksoftware.grants.GenerateCensusEntryConditionRandomValue.GetRandomCensusEntryCondition;
 import static scot.carricksoftware.grants.GenerateCensusEntryRelationshipRandomValue.GetRandomCensusEntryRelationship;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
 import static scot.carricksoftware.grants.GenerateRandomCensusValues.GetRandomCensus;
@@ -35,6 +37,7 @@ class CensusEntryCommandConverterTest {
         Long id = GetRandomLong();
         String name = GetRandomString();
         CensusEntryRelationship relationship = GetRandomCensusEntryRelationship();
+        CensusEntryCondition condition = GetRandomCensusEntryCondition();
         CensusEntryCommand source = new CensusEntryCommandImpl();
         Census census = GetRandomCensus();
         Person person = GetRandomPerson();
@@ -45,6 +48,7 @@ class CensusEntryCommandConverterTest {
         source.setCensus(census);
         source.setPerson(person);
         source.setRelationship(relationship);
+        source.setCondition(condition);
 
 
         CensusEntry target = converter.convert(source);
@@ -55,5 +59,6 @@ class CensusEntryCommandConverterTest {
         assertEquals(census, target.getCensus());
         assertEquals(person, target.getPerson());
         assertEquals(relationship, target.getRelationship());
+        assertEquals(condition, target.getCondition());
     }
 }

+ 6 - 1
src/test/java/scot/carricksoftware/grants/converters/census/CensusEntryConverterTest.java

@@ -12,8 +12,10 @@ 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 scot.carricksoftware.grants.enums.censusentry.CensusEntryCondition;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static scot.carricksoftware.grants.GenerateCensusEntryConditionRandomValue.GetRandomCensusEntryCondition;
 import static scot.carricksoftware.grants.GenerateCensusEntryRelationshipRandomValue.GetRandomCensusEntryRelationship;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
 import static scot.carricksoftware.grants.GenerateRandomCensusValues.GetRandomCensus;
@@ -36,6 +38,7 @@ class CensusEntryConverterTest {
         Census census = GetRandomCensus();
         CensusEntry source = new CensusEntry();
         CensusEntryRelationship relationship = GetRandomCensusEntryRelationship();
+        CensusEntryCondition condition = GetRandomCensusEntryCondition();
         Person person = GetRandomPerson();
 
         source.setId(id);
@@ -43,6 +46,7 @@ class CensusEntryConverterTest {
         source.setCensus(census);
         source.setPerson(person);
         source.setRelationship(relationship);
+        source.setCondition(condition);
 
         CensusEntryCommand target = converter.convert(source);
 
@@ -51,6 +55,7 @@ class CensusEntryConverterTest {
         assertEquals(name, target.getName());
         assertEquals(census, target.getCensus());
         assertEquals(person, target.getPerson());
-        assertEquals(relationship, target.getRelationship());
+        assertEquals(person, target.getPerson());
+        assertEquals(condition, target.getCondition());
     }
 }