浏览代码

Person to string with year of death

Andrew Grant 4 月之前
父节点
当前提交
cdaea4ea08

+ 1 - 1
src/main/java/scot/carricksoftware/grants/domains/people/Person.java

@@ -97,8 +97,8 @@ public class Person extends BaseEntity {
         }
         }
         builder.append("-");
         builder.append("-");
         if (certifiedYearOfDeath != null && !certifiedYearOfDeath.isEmpty())  {
         if (certifiedYearOfDeath != null && !certifiedYearOfDeath.isEmpty())  {
-            builder.append(certifiedYearOfDeath);
             builder.append(" ");
             builder.append(" ");
+            builder.append(certifiedYearOfDeath);
         }
         }
 
 
         return builder.toString();
         return builder.toString();

+ 11 - 0
src/test/java/scot/carricksoftware/grants/domains/people/PersonToStringTest.java

@@ -18,6 +18,7 @@ class PersonToStringTest {
     final String lastName = "Last";
     final String lastName = "Last";
     final String recordedBirth = "1920";
     final String recordedBirth = "1920";
     final String certifiedBirth = "1930";
     final String certifiedBirth = "1930";
+    final String certifiedDeath = "1940";
 
 
 
 
     @BeforeEach
     @BeforeEach
@@ -60,5 +61,15 @@ class PersonToStringTest {
         assertEquals(requiredResult, person.toString());
         assertEquals(requiredResult, person.toString());
     }
     }
 
 
+    @Test
+    public void witheDeathTest() {
+        String requiredResult = "Last, First, " + certifiedBirth + " - " + certifiedDeath;
+        person.setCertifiedYearOfBirth(certifiedBirth);
+        person.setRecordedYearOfBirth(recordedBirth);
+        person.setCertifiedYearOfDeath(certifiedDeath);
+
+        assertEquals(requiredResult, person.toString());
+    }
+
 
 
 }
 }