ConvertUtil { public static Object[] toArray(Object obj) { if (obj == null) { return new Object[0]; } else if (obj.getClass().isArray()) { return (Object[]) obj; } else if (obj instanceof Collection) { return ((Collection<?>) obj).toArray(); } return new Object[]{ obj }; }  static Object[] toArray(Object obj); @SuppressWarnings("unchecked") static List<E> toList(Object obj, Class<E> elementClass); static T convert(Object obj, Class<T> clazz); static T convertIfNotNull(Object obj, Class<T> clazz); @SuppressWarnings("unchecked") static T convert(
            Object obj, Class<T> clazz, boolean allowsNull); static Object convertPrimitiveArrayToList(Object value); @SuppressWarnings("unchecked") static List<Map<String, Object>> toListOfMap(Object obj); static final String CLASS_FIELDNAME; }
@Test public void testToArray01() throws Exception { Object[] result = ConvertUtil.toArray(null); assertEquals(0, result.length); }
@Test public void testToArray02() throws Exception { Object[] result = ConvertUtil.toArray(""); assertEquals(1, result.length); assertEquals("", result[0]); }
@Test public void testToArray03() throws Exception { Object[] result = ConvertUtil.toArray(" "); assertEquals(1, result.length); assertEquals(" ", result[0]); }
@Test public void testToArray04() throws Exception { Object[] result = ConvertUtil.toArray("array"); assertEquals(1, result.length); assertEquals("array", result[0]); }
@Test public void testToArray05() throws Exception { Object obj = new Object[0]; Object[] result = ConvertUtil.toArray(obj); assertEquals(0, result.length); }
@Test public void testToArray06() throws Exception { String[] obj = { "array" }; Object[] result = ConvertUtil.toArray(obj); assertEquals(1, result.length); assertEquals("array", result[0]); }
@Test public void testToArray07() throws Exception { Object[] obj = new Object[3]; obj[0] = "array"; obj[1] = 1; Map<String, String> map = new HashMap<String, String>(); map.put("foo", "something"); obj[2] = map; Object[] result = ConvertUtil.toArray(obj); assertEquals(3, result.length); assertEquals("array", result[0]); assertEquals(1, result[1]); assertEquals(map, result[2]); Map<?, ?> mapResult = (Map<?, ?>) result[2]; assertEquals("something", mapResult.get("foo")); }
@Test public void testToArray08() throws Exception { Collection<?> obj = new Vector<Object>(); Object[] result = ConvertUtil.toArray(obj); assertEquals(0, result.length); }
@Test public void testToArray09() throws Exception { Collection<String> obj = new Vector<String>(); obj.add("collection"); Object[] result = ConvertUtil.toArray(obj); assertEquals(1, result.length); assertEquals("collection", result[0]); }
@Test public void testToArray10() throws Exception { Collection<Object> obj = new Vector<Object>(); obj.add("collection"); obj.add(1); Map<String, String> map = new HashMap<String, String>(); map.put("foo", "something"); obj.add(map); Object[] result = ConvertUtil.toArray(obj); assertEquals(3, result.length); assertEquals("collection", result[0]); assertEquals(1, result[1]); Map<?, ?> mapResult = (Map<?, ?>) result[2]; assertEquals("something", mapResult.get("foo")); }