# HG changeset patch # User Tom Gottfried # Date 1698934162 -3600 # 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 @@ commons-codec 1.4 + + junit + junit + 4.13 + test + 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 json = new HashMap<>(); + json.put("number", 0); + json.put("boolean", true); + json.put("string", "test"); + final Map object = new HashMap<>(); + object.put("test", "test"); + json.put("object", object); + + assertEquals("{" + + "\"number\":0," + + "\"boolean\":true," + + "\"string\":\"test\"," + + "\"object\":{\"test\":\"test\"}" + + "}", + JSON.toJSONString(json)); + } +}