--- /dev/null
+package de.juplo.jackson;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import java.io.InputStream;
+import java.util.Map.Entry;
+import java.util.Spliterator;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+import org.junit.Test;
+
+
+/**
+ *
+ * @author Kai Moritz
+ */
+public class SimpleMapperTest
+{
+ private final SimpleMapper mapper = new SimpleMapper(new JsonFactory());
+
+
+ @Test
+ public void testConvertEmptyArray() throws Exception
+ {
+ Spliterator<Object> spliterator;
+
+ spliterator = mapper.getArraySpliterator(get("/empty/1.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Object t) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getArraySpliterator(get("/empty/2.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Object t) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getArraySpliterator(get("/empty/3.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Object t) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getArraySpliterator(get("/empty/4.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Object t) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getArraySpliterator(get("/empty/5.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Object t) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ }
+
+ @Test
+ public void testConvertEmptyObject() throws Exception
+ {
+ Spliterator<Entry<String, Object>> spliterator;
+
+ spliterator = mapper.getObjectSpliterator(get("/empty/1.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Entry<String, Object> e) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getObjectSpliterator(get("/empty/2.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Entry<String, Object> e) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getObjectSpliterator(get("/empty/3.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Entry<String, Object> e) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getObjectSpliterator(get("/empty/4.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Entry<String, Object> e) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ spliterator = mapper.getObjectSpliterator(get("/empty/5.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Entry<String, Object> e) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ }
+
+
+ private InputStream get(String resource)
+ {
+ return SimpleMapperTest.class.getResourceAsStream(resource);
+ }
+}