Browse Source

DeathCertificateCommand Converters Test - refactor

Andrew Grant 4 tháng trước cách đây
mục cha
commit
06b2840cea

+ 42 - 0
src/test/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandConverterLongTest.java

@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 24/03/2025, 19:02. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.converters.certificates.deathcertificates;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
+
+class DeathCertificateCommandConverterLongTest {
+
+    private DeathCertificateCommandConverter converter;
+
+    @BeforeEach
+    void setUp() {
+        converter = new DeathCertificateCommandConverterImpl();
+    }
+
+    @Test
+    void convertTest() {
+        Long id = GetRandomLong();
+
+        DeathCertificateCommand source = new DeathCertificateCommandImpl();
+
+        source.setId(id);
+
+        DeathCertificate target = converter.convert(source);
+
+        assert target != null;
+        assertEquals(id,target.getId());
+
+
+    }
+}

+ 58 - 0
src/test/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandConverterPersonTest.java

@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 24/03/2025, 19:02. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.converters.certificates.deathcertificates;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+import scot.carricksoftware.grants.domains.people.Person;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
+import static scot.carricksoftware.grants.GenerateRandomPeopleValues.GetRandomPerson;
+
+class DeathCertificateCommandConverterPersonTest {
+
+    private DeathCertificateCommandConverter converter;
+
+    @BeforeEach
+    void setUp() {
+        converter = new DeathCertificateCommandConverterImpl();
+    }
+
+    @Test
+    void convertTest() {
+        Long id = GetRandomLong();
+        Person person = GetRandomPerson();
+        Person father = GetRandomPerson();
+        Person informant = GetRandomPerson();
+        Person mother = GetRandomPerson();
+        Person spouse = GetRandomPerson();
+
+        DeathCertificateCommand source = new DeathCertificateCommandImpl();
+
+        source.setId(id);
+        source.setDeceased(person);
+        source.setFather(father);
+        source.setInformant(informant);
+        source.setMother(mother);
+        source.setSpouse(spouse);
+
+        DeathCertificate target = converter.convert(source);
+
+        assert target != null;
+        assertEquals(id,target.getId());
+        assertEquals(person,target.getDeceased());
+        assertEquals(father,target.getFather());
+        assertEquals(informant,target.getInformant());
+        assertEquals(mother,target.getMother());
+        assertEquals(spouse,target.getSpouse());
+
+    }
+}

+ 46 - 0
src/test/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandConverterPlaceTest.java

@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 24/03/2025, 19:02. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.converters.certificates.deathcertificates;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+import scot.carricksoftware.grants.domains.places.Place;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomPlace;
+
+class DeathCertificateCommandConverterPlaceTest {
+
+    private DeathCertificateCommandConverter converter;
+
+    @BeforeEach
+    void setUp() {
+        converter = new DeathCertificateCommandConverterImpl();
+    }
+
+    @Test
+    void convertTest() {
+        Place usualResidence = GetRandomPlace();
+        Place whereDied = GetRandomPlace();
+
+        DeathCertificateCommand source = new DeathCertificateCommandImpl();
+
+        source.setUsualResidence(usualResidence);
+        source.setWhereDied(whereDied);
+
+        DeathCertificate target = converter.convert(source);
+
+        assert target != null;
+
+        assertEquals(usualResidence,target.getUsualResidence());
+        assertEquals(whereDied,target.getWhereDied());
+
+    }
+}

+ 44 - 0
src/test/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandConverterSexTest.java

@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 24/03/2025, 19:02. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.converters.certificates.deathcertificates;
+
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+import scot.carricksoftware.grants.enums.general.Sex;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class DeathCertificateCommandConverterSexTest {
+
+    private DeathCertificateCommandConverter converter;
+
+    @BeforeEach
+    void setUp() {
+        converter = new DeathCertificateCommandConverterImpl();
+    }
+
+    @Test
+    void convertTest() {
+
+        Sex sex = Sex.MALE;
+
+        DeathCertificateCommand source = new DeathCertificateCommandImpl();
+
+        source.setSex(sex);
+
+        DeathCertificate target = converter.convert(source);
+
+        assert target != null;
+
+        assertEquals(sex,target.getSex());
+
+        
+    }
+}

+ 1 - 42
src/test/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandConverterTest.java → src/test/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandConverterStringTest.java

@@ -11,17 +11,11 @@ import org.junit.jupiter.api.Test;
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
 import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
-import scot.carricksoftware.grants.domains.people.Person;
-import scot.carricksoftware.grants.domains.places.Place;
-import scot.carricksoftware.grants.enums.general.Sex;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
-import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
-import static scot.carricksoftware.grants.GenerateRandomPeopleValues.GetRandomPerson;
-import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomPlace;
 
-class DeathCertificateCommandConverterTest {
+class DeathCertificateCommandConverterStringTest {
 
     private DeathCertificateCommandConverter converter;
 
@@ -32,18 +26,6 @@ class DeathCertificateCommandConverterTest {
 
     @Test
     void convertTest() {
-        Long id = GetRandomLong();
-        Person person = GetRandomPerson();
-        Person father = GetRandomPerson();
-        Person informant = GetRandomPerson();
-        Person mother = GetRandomPerson();
-        Person spouse = GetRandomPerson();
-
-        Place usualResidence = GetRandomPlace();
-        Place whereDied = GetRandomPlace();
-
-        Sex sex = Sex.MALE;
-
         String age = GetRandomString();
         String causeOfDeath = GetRandomString();
         String fatherOccupation = GetRandomString();
@@ -66,18 +48,6 @@ class DeathCertificateCommandConverterTest {
         
         DeathCertificateCommand source = new DeathCertificateCommandImpl();
 
-        source.setId(id);
-        source.setDeceased(person);
-        source.setFather(father);
-        source.setInformant(informant);
-        source.setMother(mother);
-        source.setSpouse(spouse);
-
-        source.setUsualResidence(usualResidence);
-        source.setWhereDied(whereDied);
-
-        source.setSex(sex);
-
         source.setAge(age);
         source.setCauseOfDeath(causeOfDeath);
         source.setFatherOccupation(fatherOccupation);
@@ -101,17 +71,6 @@ class DeathCertificateCommandConverterTest {
         DeathCertificate target = converter.convert(source);
 
         assert target != null;
-        assertEquals(id,target.getId());
-        assertEquals(person,target.getDeceased());
-        assertEquals(father,target.getFather());
-        assertEquals(informant,target.getInformant());
-        assertEquals(mother,target.getMother());
-        assertEquals(spouse,target.getSpouse());
-
-        assertEquals(usualResidence,target.getUsualResidence());
-        assertEquals(whereDied,target.getWhereDied());
-
-        assertEquals(sex,target.getSex());
 
         assertEquals(age,target.getAge());
         assertEquals(causeOfDeath,target.getCauseOfDeath());