add test to determine field classes in map

This commit is contained in:
Jörg Prante 2023-12-13 11:34:19 +01:00
parent 3432b46c7d
commit 38abb654d6
2 changed files with 22 additions and 1 deletions

View file

@ -16,7 +16,7 @@ import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class JsonBuilderTest {
public class BuilderTest {
@Test
public void testUmlautEncoding() throws IOException{

View file

@ -1,6 +1,9 @@
package org.xbib.datastructures.json.tiny.test;
import org.junit.jupiter.api.Test;
import org.xbib.datastructures.api.Builder;
import org.xbib.datastructures.json.tiny.Json;
import org.xbib.datastructures.json.tiny.JsonBuilder;
import org.xbib.datastructures.json.tiny.StreamParser;
import org.xbib.datastructures.json.tiny.StringParser;
import java.io.BufferedReader;
@ -8,11 +11,16 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class ParserTest {
private static final Logger logger = Logger.getLogger(ParserTest.class.getName());
@Test
public void testStringParser() throws IOException {
try (InputStream inputStream = ParserTest.class.getResourceAsStream("/org/xbib/datastructures/json/tiny/test/test.json")) {
@ -40,4 +48,17 @@ public class ParserTest {
}
}
}
@Test
public void testMap() throws IOException {
Builder builder = JsonBuilder.builder()
.beginMap()
.fieldIfNotNull("a", "Hello World")
.endMap();
Map<String, Object> map = Json.toMap(builder.build());
for (Map.Entry<String, Object> e : map.entrySet()) {
logger.log(Level.INFO, "value class " + e.getValue().getClass().getName());
}
}
}