changeset 583:0135bf3bd92b 3.2.x

Add minimal test for JSON utility class
author Tom Gottfried <tom@intevation.de>
date Thu, 02 Nov 2023 15:09:22 +0100
parents 0d492fc47869
children efbdaf72aafe
files artifacts-common/pom.xml artifacts-common/src/test/java/org/dive4elements/artifacts/common/utils/JSONTest.java
diffstat 2 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts-common/pom.xml	Tue Jan 17 14:21:14 2023 +0100
+++ b/artifacts-common/pom.xml	Thu Nov 02 15:09:22 2023 +0100
@@ -28,6 +28,12 @@
       <artifactId>commons-codec</artifactId>
       <version>1.4</version>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.13</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts-common/src/test/java/org/dive4elements/artifacts/common/utils/JSONTest.java	Thu Nov 02 15:09:22 2023 +0100
@@ -0,0 +1,29 @@
+package org.dive4elements.artifacts.common.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+public class JSONTest {
+    @Test
+    public void toJSONString() {
+        final Map<String, Object> json = new HashMap<>();
+        json.put("number", 0);
+        json.put("boolean", true);
+        json.put("string", "test");
+        final Map<String, Object> object = new HashMap<>();
+        object.put("test", "test");
+        json.put("object", object);
+
+        assertEquals("{"
+            + "\"number\":0,"
+            + "\"boolean\":true,"
+            + "\"string\":\"test\","
+            + "\"object\":{\"test\":\"test\"}"
+            + "}",
+            JSON.toJSONString(json));
+    }
+}

http://dive4elements.wald.intevation.org