view artifacts-common/src/test/java/org/dive4elements/artifacts/common/utils/JSONTest.java @ 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
children efbdaf72aafe
line wrap: on
line source
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