import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import java.io.IOException;
-import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Spliterator;
import static java.util.Spliterator.IMMUTABLE;
-import java.util.Spliterators;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
JsonToken token = parser.nextToken();
if (token == null)
- {
- LOG.warn("empty input");
- return Spliterators.emptySpliterator();
- }
+ return null;
if (!JsonToken.START_ARRAY.equals(token))
fail(parser, "The root-element must be an array!");
JsonToken token = parser.nextToken();
if (token == null)
- {
- LOG.warn("empty input");
- return Spliterators.emptySpliterator();
- }
+ return null;
if (!JsonToken.START_OBJECT.equals(token))
fail(parser, "The root-element must be an object!");
JsonToken token = parser.nextToken();
if (token == null)
- {
- LOG.warn("empty input");
- return Collections.EMPTY_LIST;
- }
+ return null;
if (!JsonToken.START_ARRAY.equals(token))
fail(parser, "The root-element must be an array!");
JsonToken token = parser.nextToken();
if (token == null)
- {
- LOG.warn("empty input");
- return Collections.EMPTY_MAP;
- }
+ return null;
if (!JsonToken.START_OBJECT.equals(token))
fail(parser, "The root-element must be an object!");
JsonToken token = parser.nextToken();
if (token == null)
- {
- LOG.warn("empty input");
return null;
- }
switch (token)
{
import java.util.Map;
import java.util.Map.Entry;
import java.util.Spliterator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
import org.junit.Test;
Spliterator<Object> spliterator;
spliterator = SimpleMapper.getArraySpliterator(get("/empty/1.json"));
- assertFalse(
- "The created splitter should have no entries",
- spliterator.tryAdvance((Object t) ->
- {
- fail("The consumer should never be called!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.getArraySpliterator(get("/empty/2.json"));
- assertFalse(
- "The created splitter should have no entries",
- spliterator.tryAdvance((Object t) ->
- {
- fail("The consumer should never be called!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.getArraySpliterator(get("/empty/3.json"));
- assertFalse(
- "The created splitter should have no entries",
- spliterator.tryAdvance((Object t) ->
- {
- fail("The consumer should never be called!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.getArraySpliterator(get("/empty/4.json"));
- assertFalse(
- "The created splitter should have no entries",
- spliterator.tryAdvance((Object t) ->
- {
- fail("The consumer should never be called!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.getArraySpliterator(get("/empty/5.json"));
- assertFalse(
- "The created splitter should have no entries",
- spliterator.tryAdvance((Object t) ->
- {
- fail("The consumer should never be called!");
- }));
+ assertNull(spliterator);
}
@Test
List<Object> list;
list = SimpleMapper.convertArray(get("/empty/1.json"));
- assertEquals(0, list.size());
+ assertNull(list);
list = SimpleMapper.convertArray(get("/empty/2.json"));
- assertEquals(0, list.size());
+ assertNull(list);
list = SimpleMapper.convertArray(get("/empty/3.json"));
- assertEquals(0, list.size());
+ assertNull(list);
list = SimpleMapper.convertArray(get("/empty/4.json"));
- assertEquals(0, list.size());
+ assertNull(list);
list = SimpleMapper.convertArray(get("/empty/5.json"));
- assertEquals(0, list.size());
+ assertNull(list);
}
@Test
Spliterator<Entry<String, Object>> spliterator;
spliterator = SimpleMapper.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!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.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!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.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!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.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!");
- }));
+ assertNull(spliterator);
spliterator = SimpleMapper.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!");
- }));
+ assertNull(spliterator);
}
@Test
Map<String, Object> map;
map = SimpleMapper.convertObject(get("/empty/1.json"));
- assertEquals(0, map.size());
+ assertNull(map);
map = SimpleMapper.convertObject(get("/empty/2.json"));
- assertEquals(0, map.size());
+ assertNull(map);
map = SimpleMapper.convertObject(get("/empty/3.json"));
- assertEquals(0, map.size());
+ assertNull(map);
map = SimpleMapper.convertObject(get("/empty/4.json"));
- assertEquals(0, map.size());
+ assertNull(map);
map = SimpleMapper.convertObject(get("/empty/5.json"));
- assertEquals(0, map.size());
+ assertNull(map);
}
@Test