Browse Source

place text and place images converters

Andrew Grant 7 months ago
parent
commit
62b3d7ce4f

+ 3 - 0
src/main/java/scot/carricksoftware/grants/converters/places/places/PlaceCommandConverterImpl.java

@@ -14,6 +14,7 @@ import scot.carricksoftware.grants.domains.places.Place;
 @Component
 public class PlaceCommandConverterImpl implements PlaceCommandConverter {
 
+    @SuppressWarnings("DuplicatedCode")
     @Override
     public Place convert(@NotNull PlaceCommand source) {
         Place target = new Place();
@@ -21,6 +22,8 @@ public class PlaceCommandConverterImpl implements PlaceCommandConverter {
         target.setName(source.getName());
         target.setRegion(source.getRegion());
         target.setCensuses(source.getCensuses());
+        target.setPlaceImages(source.getPlaceImages());
+        target.setPlaceTexts(source.getPlaceTexts());
         return target;
     }
 

+ 3 - 0
src/main/java/scot/carricksoftware/grants/converters/places/places/PlaceConverterImpl.java

@@ -14,6 +14,7 @@ import scot.carricksoftware.grants.domains.places.Place;
 @Component
 public class PlaceConverterImpl implements PlaceConverter {
 
+    @SuppressWarnings("DuplicatedCode")
     @Override
     public PlaceCommand convert(Place source) {
         PlaceCommand target = new PlaceCommandImpl();
@@ -21,6 +22,8 @@ public class PlaceConverterImpl implements PlaceConverter {
         target.setName(source.getName());
         target.setRegion(source.getRegion());
         target.setCensuses(source.getCensuses());
+        target.setPlaceImages(source.getPlaceImages());
+        target.setPlaceTexts(source.getPlaceTexts());
         return target;
     }
 }

+ 12 - 0
src/test/java/scot/carricksoftware/grants/converters/places/places/PlaceCommandConverterImplTest.java

@@ -10,8 +10,10 @@ import org.junit.jupiter.api.Test;
 import scot.carricksoftware.grants.commands.places.places.PlaceCommand;
 import scot.carricksoftware.grants.commands.places.places.PlaceCommandImpl;
 import scot.carricksoftware.grants.domains.census.Census;
+import scot.carricksoftware.grants.domains.images.PlaceImage;
 import scot.carricksoftware.grants.domains.places.Place;
 import scot.carricksoftware.grants.domains.places.Region;
+import scot.carricksoftware.grants.domains.text.PlaceText;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -19,8 +21,10 @@ import java.util.List;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
 import static scot.carricksoftware.grants.GenerateRandomCensusValues.GetRandomCensus;
+import static scot.carricksoftware.grants.GenerateRandomImageValues.GetRandomPlaceImage;
 import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
 import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomRegion;
+import static scot.carricksoftware.grants.GenerateRandomTextValues.GetRandomPlaceText;
 
 
 public class PlaceCommandConverterImplTest {
@@ -40,12 +44,18 @@ public class PlaceCommandConverterImplTest {
         Region region = GetRandomRegion();
         List<Census> censuses = new ArrayList<>();
         censuses.add(GetRandomCensus());
+        List<PlaceImage> placeImages = new ArrayList<>();
+        placeImages.add(GetRandomPlaceImage());
+        List<PlaceText> placeTexts = new ArrayList<>();
+        placeTexts.add(GetRandomPlaceText());
 
         source.setCensuses(censuses);
         source.setId(id);
         source.setName(name);
         source.setRegion(region);
         source.setCensuses(censuses);
+        source.setPlaceTexts(placeTexts);
+        source.setPlaceImages(placeImages);
 
         Place target = converter.convert(source);
 
@@ -54,5 +64,7 @@ public class PlaceCommandConverterImplTest {
         assertEquals(name, target.getName());
         assertEquals(region, target.getRegion());
         assertEquals(censuses, target.getCensuses());
+        assertEquals(placeTexts, target.getPlaceTexts());
+        assertEquals(placeImages, target.getPlaceImages());
     }
 }

+ 12 - 0
src/test/java/scot/carricksoftware/grants/converters/places/places/PlaceConverterImplTest.java

@@ -11,8 +11,10 @@ import org.junit.jupiter.api.Test;
 import org.springframework.stereotype.Component;
 import scot.carricksoftware.grants.commands.places.places.PlaceCommand;
 import scot.carricksoftware.grants.domains.census.Census;
+import scot.carricksoftware.grants.domains.images.PlaceImage;
 import scot.carricksoftware.grants.domains.places.Place;
 import scot.carricksoftware.grants.domains.places.Region;
+import scot.carricksoftware.grants.domains.text.PlaceText;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -20,8 +22,10 @@ import java.util.List;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
 import static scot.carricksoftware.grants.GenerateRandomCensusValues.GetRandomCensus;
+import static scot.carricksoftware.grants.GenerateRandomImageValues.GetRandomPlaceImage;
 import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
 import static scot.carricksoftware.grants.GenerateRandomPlaceValues.GetRandomRegion;
+import static scot.carricksoftware.grants.GenerateRandomTextValues.GetRandomPlaceText;
 
 
 @Component
@@ -42,11 +46,17 @@ public class PlaceConverterImplTest {
         Region region = GetRandomRegion();
         List<Census> censuses = new ArrayList<>();
         censuses.add(GetRandomCensus());
+        List<PlaceImage> placeImages = new ArrayList<>();
+        placeImages.add(GetRandomPlaceImage());
+        List<PlaceText> placeTexts = new ArrayList<>();
+        placeTexts.add(GetRandomPlaceText());
 
         source.setId(id);
         source.setName(name);
         source.setRegion(region);
         source.setCensuses(censuses);
+        source.setPlaceTexts(placeTexts);
+        source.setPlaceImages(placeImages);
 
         PlaceCommand target = converter.convert(source);
 
@@ -55,6 +65,8 @@ public class PlaceConverterImplTest {
         assertEquals(name, target.getName());
         assertEquals(region, target.getRegion());
         assertEquals(censuses, target.getCensuses());
+        assertEquals(placeTexts, target.getPlaceTexts());
+        assertEquals(placeImages, target.getPlaceImages());
     }
 
 }