[PATCH 1 of 2] Add minimal test for JSON utility class
Wald Commits
scm-commit at wald.intevation.org
Thu Nov 2 17:42:46 CET 2023
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1698934162 -3600
# Thu Nov 02 15:09:22 2023 +0100
# Branch 3.2.x
# Node ID 0135bf3bd92b203ce2aa0a601fcf4f1de4f9ac9c
# Parent 0d492fc47869b6869272e7c130e487bc18d74202
Add minimal test for JSON utility class
diff -r 0d492fc47869 -r 0135bf3bd92b artifacts-common/pom.xml
--- 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>
diff -r 0d492fc47869 -r 0135bf3bd92b artifacts-common/src/test/java/org/dive4elements/artifacts/common/utils/JSONTest.java
--- /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));
+ }
+}
More information about the Dive4Elements-commits
mailing list