فهرست منبع

Military attributes added to certificatecommand converter

Andrew Grant 4 ماه پیش
والد
کامیت
bcc1bd33fb

+ 14 - 0
src/main/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandMilitaryConverter.java

@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.converters.certificates.deathcertificates;
+
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+
+public interface DeathCertificateCommandMilitaryConverter {
+
+    void convert(DeathCertificateCommand source, DeathCertificate target);
+}

+ 21 - 0
src/main/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandMilitaryConverterImpl.java

@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.converters.certificates.deathcertificates;
+
+import org.apache.logging.log4j.core.tools.picocli.CommandLine;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
+import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
+
+@CommandLine.Command
+public class DeathCertificateCommandMilitaryConverterImpl implements DeathCertificateCommandMilitaryConverter {
+
+    @Override
+    public void convert(DeathCertificateCommand source, DeathCertificate target) {
+        target.setRegiment(source.getRegiment());
+        target.setServiceNumber(source.getServiceNumber());
+        target.setServiceRank(source.getServiceRank());
+    }
+}

+ 1 - 0
src/main/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateConverterImpl.java

@@ -17,6 +17,7 @@ public class DeathCertificateConverterImpl implements DeathCertificateConverter
 
     private final DeathCertificateMilitaryConverter militaryConverter;
 
+
     public DeathCertificateConverterImpl(DeathCertificateMilitaryConverter militaryConverter) {
         this.militaryConverter = militaryConverter;
     }

+ 48 - 0
src/test/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandMilitaryConverterTest.java

@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. 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.GenerateCertificateRandomValues.GetRandomString;
+
+
+class DeathCertificateCommandMilitaryConverterTest {
+
+
+    private DeathCertificateCommandMilitaryConverter militaryConverter;
+    private DeathCertificateCommand source;
+    private DeathCertificate target;
+
+    @BeforeEach
+    void setUp() {
+        militaryConverter = new DeathCertificateCommandMilitaryConverterImpl();
+        source = new DeathCertificateCommandImpl();
+        target = new DeathCertificate();
+    }
+
+    @Test
+    void convertTest() {
+        String regiment = GetRandomString();
+        String serviceNumber = GetRandomString();
+        String serviceRank = GetRandomString();
+
+        source.setRegiment(regiment);
+        source.setServiceNumber(serviceNumber);
+        source.setServiceRank(serviceRank);
+
+        militaryConverter.convert(source, target);
+
+        assertEquals(regiment, target.getRegiment());
+        assertEquals(serviceNumber, target.getServiceNumber());
+        assertEquals(serviceRank, target.getServiceRank());
+    }
+}