ConvertUtil { public static <T> T convert(Object obj, Class<T> clazz) throws IllegalArgumentException { return convert(obj, clazz, true); }  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 testConvertObjectClass01() throws Exception { try { ConvertUtil.convert("object", null); fail("IllegalArgumentExceptionがスローされませんでした。"); } catch (IllegalArgumentException e) { assertEquals(IllegalArgumentException.class.getName(), e.getClass() .getName()); assertEquals("Argument 'clazz' (" + Object.class.getName() + ") is null", e.getMessage()); } }
@Test public void testConvertObjectClass02() throws Exception { assertNull(ConvertUtil.convert(null, Object.class)); }
@Test public void testConvertObjectClass03() throws Exception { List<?> list = new ArrayList<Object>(); List<?> result = ConvertUtil.convert(list, ArrayList.class); assertSame(list, result); }
@Test public void testConvertObjectClass04() throws Exception { Thread thread = new Thread(); try { ConvertUtil.convert(thread, AlgorithmParameterGenerator.class); fail(); } catch (IllegalArgumentException e) { } }
@Test public void testConvertIfNotNull04() throws Exception { Thread thread = new Thread(); try { ConvertUtil.convert(thread, AlgorithmParameterGenerator.class); fail(); } catch (IllegalArgumentException e) { e.printStackTrace(); } }
@Test public void testConvertObjectClassboolean01() throws Exception { try { ConvertUtil.convert(null, null, true); fail("IllegalArgumentExceptionがスローされませんでした。"); } catch (IllegalArgumentException e) { assertEquals(IllegalArgumentException.class.getName(), e.getClass() .getName()); assertEquals("Argument 'clazz' (" + Object.class.getName() + ") is null", e.getMessage()); } }
@Test public void testConvertObjectClassboolean02() throws Exception { try { ConvertUtil.convert(null, Object.class, false); fail("IllegalArgumentExceptionがスローされませんでした。"); } catch (IllegalArgumentException e) { assertEquals(IllegalArgumentException.class.getName(), e.getClass() .getName()); assertEquals("Unable to cast 'null' to '" + Object.class.getName() + "'", e.getMessage()); assertEquals(ClassCastException.class.getName(), e.getCause() .getClass().getName()); assertEquals("Unable to cast 'null' to '" + Object.class.getName() + "'", e.getCause().getMessage()); } }
@Test public void testConvertObjectClassboolean03() throws Exception { assertNull(ConvertUtil.convert(null, Object.class, true)); }
@Test public void testConvertObjectClassboolean04() throws Exception { Thread thread = new Thread(); Thread result = ConvertUtil.convert(thread, Thread.class, true); assertSame(thread, result); }
@Test public void testConvertObjectClassboolean05() throws Exception { List<?> list = new ArrayList<Object>(); List<?> result = ConvertUtil.convert(list, ArrayList.class, true); assertNotNull(result); assertSame(list, result); }
@Test public void testConvertObjectClassboolean06() throws Exception { Thread thread = new Thread(); try { ConvertUtil.convert(thread, AlgorithmParameterGenerator.class, true); fail(); } catch (IllegalArgumentException e) { } }
@Test public void testConvertObjectClassboolean07() throws Exception { try { ConvertUtil.convert("abc", BigInteger.class, false); fail("IllegalArgumentExceptionがスローされませんでした。"); } catch (IllegalArgumentException e) { assertEquals(IllegalArgumentException.class.getName(), e.getClass() .getName()); assertTrue(e.getCause() instanceof ConversionException); } }