浏览代码

DocumentImage converters tests

apg 3 周之前
父节点
当前提交
648b25a0fd

+ 62 - 0
src/test/java/scot/carricksoftware/grants/converters/images/documentimage/DocumentImageCommandConverterTest.java

@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 28/03/2025, 10:44. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.converters.images.documentimage;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.commands.images.DocumentImageCommand;
+import scot.carricksoftware.grants.commands.images.DocumentImageCommandImpl;
+import scot.carricksoftware.grants.domains.images.DocumentImage;
+import scot.carricksoftware.grants.domains.images.Image;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
+import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
+
+class DocumentImageCommandConverterTest {
+
+    private DocumentImageCommandConverter converter;
+
+    @BeforeEach
+    void setUp() {
+        converter = new DocumentImageCommandConverterImpl();
+    }
+
+    @Test
+    void covertTest() {
+        Long Id = GetRandomLong();
+        Image image = new Image();
+        String level = GetRandomString();
+        String order = GetRandomString();
+        String caption = GetRandomString();
+        String height = GetRandomString();
+        String width = GetRandomString();
+
+
+        DocumentImageCommand source = new DocumentImageCommandImpl();
+
+        source.setId(Id);
+        source.setImage(image);
+        source.setLevel(level);
+        source.setOrder(order);
+        source.setCaption(caption);
+        source.setHeight(height);
+        source.setWidth(width);
+
+
+        DocumentImage target = converter.convert(source);
+
+        assertNotNull(target);
+        assertEquals(Id, target.getId());
+        assertEquals(image, target.getImage());
+        assertEquals(level, target.getLevel());
+        assertEquals(order, target.getOrder());
+        assertEquals(caption, target.getCaption());
+        assertEquals(height, target.getHeight());
+        assertEquals(width, target.getWidth());
+    }
+}

+ 60 - 0
src/test/java/scot/carricksoftware/grants/converters/images/documentimage/DocumentImageConverterTest.java

@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 28/03/2025, 10:44. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.converters.images.documentimage;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import scot.carricksoftware.grants.commands.images.DocumentImageCommand;
+import scot.carricksoftware.grants.domains.images.DocumentImage;
+import scot.carricksoftware.grants.domains.images.Image;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static scot.carricksoftware.grants.GenerateCertificateRandomValues.GetRandomString;
+import static scot.carricksoftware.grants.GenerateRandomNumberValues.GetRandomLong;
+
+class DocumentImageConverterTest {
+
+    private DocumentImageConverter converter;
+
+    @BeforeEach
+    void setUp() {
+        converter = new DocumentImageConverterImpl();
+    }
+
+    @Test
+    void covertTest() {
+        Long Id = GetRandomLong();
+        Image image = new Image();
+        String level = GetRandomString();
+        String order = GetRandomString();
+        String caption = GetRandomString();
+        String height = GetRandomString();
+        String width = GetRandomString();
+
+        DocumentImage source = new DocumentImage();
+
+        source.setId(Id);
+        source.setImage(image);
+        source.setLevel(level);
+        source.setOrder(order);
+        source.setCaption(caption);
+        source.setHeight(height);
+        source.setWidth(width);
+
+        DocumentImageCommand target = converter.convert(source);
+
+        assertNotNull(target);
+        assertEquals(Id, target.getId());
+        assertEquals(image, target.getImage());
+        assertEquals(level, target.getLevel());
+        assertEquals(order, target.getOrder());
+        assertEquals(caption, target.getCaption());
+        assertEquals(height, target.getHeight());
+        assertEquals(width, target.getWidth());
+
+    }
+}