}
+ @Test
+ public void testConvertEmptyObjectToArraySpliterator() throws Exception
+ {
+ try
+ {
+ SimpleMapper.getArraySpliterator(get("/object/empty/1.json"));
+ fail("it must not be possible, to get an array-spliterator for an object");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+
+ try
+ {
+ SimpleMapper.getArraySpliterator(get("/object/empty/2.json"));
+ fail("it must not be possible, to get an array-spliterator for an object");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+
+ try
+ {
+ SimpleMapper.getArraySpliterator(get("/object/empty/3.json"));
+ fail("it must not be possible, to get an array-spliterator for an object");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+
+ try
+ {
+ SimpleMapper.getArraySpliterator(get("/object/empty/4.json"));
+ fail("it must not be possible, to get an array-spliterator for an object");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testConvertEmptyObjectToList() throws Exception
+ {
+ try
+ {
+ SimpleMapper.convertArray(get("/object/empty/1.json"));
+ fail("it must not be possible, to get a list for an array");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+
+ try
+ {
+ SimpleMapper.convertArray(get("/object/empty/2.json"));
+ fail("it must not be possible, to get a list for an array");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+
+ try
+ {
+ SimpleMapper.convertArray(get("/object/empty/3.json"));
+ fail("it must not be possible, to get a list for an array");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+
+ try
+ {
+ SimpleMapper.convertArray(get("/object/empty/4.json"));
+ fail("it must not be possible, to get a list for an array");
+ }
+ catch(IllegalArgumentException e)
+ {
+ LOG.info(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testConvertEmptyObjectToObjectSpliterator() throws Exception
+ {
+ Spliterator<Entry<String, Object>> spliterator;
+
+ spliterator = SimpleMapper.getObjectSpliterator(get("/object/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 = SimpleMapper.getObjectSpliterator(get("/object/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 = SimpleMapper.getObjectSpliterator(get("/object/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 = SimpleMapper.getObjectSpliterator(get("/object/empty/4.json"));
+ assertFalse(
+ "The created splitter should have no entries",
+ spliterator.tryAdvance((Entry<String, Object> e) ->
+ {
+ fail("The consumer should never be called!");
+ }));
+ }
+
+ @Test
+ public void testConvertEmptyObjectToMap() throws Exception
+ {
+ Map<String, Object> map;
+
+ map = SimpleMapper.convertObject(get("/object/empty/1.json"));
+ assertEquals(0, map.size());
+ map = SimpleMapper.convertObject(get("/object/empty/2.json"));
+ assertEquals(0, map.size());
+ map = SimpleMapper.convertObject(get("/object/empty/3.json"));
+ assertEquals(0, map.size());
+ map = SimpleMapper.convertObject(get("/object/empty/4.json"));
+ assertEquals(0, map.size());
+ }
+
+ @Test
+ public void testConvertEmptyObject() throws Exception
+ {
+ Object object;
+
+ object = SimpleMapper.convert(get("/object/empty/1.json"));
+ assertNotNull(object);
+ assertTrue("the returned object should be a list", object instanceof Map);
+ assertEquals(0, ((Map)object).size());
+ object = SimpleMapper.convert(get("/object/empty/2.json"));
+ assertNotNull(object);
+ assertTrue("the returned object should be a list", object instanceof Map);
+ assertEquals(0, ((Map)object).size());
+ object = SimpleMapper.convert(get("/object/empty/3.json"));
+ assertNotNull(object);
+ assertTrue("the returned object should be a list", object instanceof Map);
+ assertEquals(0, ((Map)object).size());
+ object = SimpleMapper.convert(get("/object/empty/4.json"));
+ assertNotNull(object);
+ assertTrue("the returned object should be a list", object instanceof Map);
+ assertEquals(0, ((Map)object).size());
+ }
+
+
private JsonParser get(String resource) throws IOException
{
InputStream is = SimpleMapperTest.class.getResourceAsStream(resource);