### Question:
Convert { public static BigDecimal toBigDecimal(Object data) { return toBigDecimal(data, null); } private  Convert(); static boolean toBoolean(Object data); static Integer toInteger(Object data); static Long toLong(Object data); static BigDecimal toBigDecimal(Object data); static BigDecimal toBigDecimal(Object data, BigDecimal defaultDecimal); static Date toDate(String dateString);  }### Answer:
@Test public void testToBigDecimal_Object() { System.out.println("toBigDecimal"); Object data = null; BigDecimal expResult = null; BigDecimal result = Convert.toBigDecimal(data); List<String> trueStrings = Arrays.asList("28983", "3", "0.33", "123.48"); List<String> falseStrings = Arrays.asList("Fred", "84.233.4", "A", "1,333", "", "null"); for (String testBigDecimal : trueStrings) { result = Convert.toBigDecimal(testBigDecimal); if (result == null) { fail("Failed on: " + testBigDecimal); } } for (String testBigDecimal : falseStrings) { result = Convert.toBigDecimal(testBigDecimal); assertEquals(expResult, result); } }
@Test public void testToBigDecimalWithDefault() { System.out.println("toBigDecimal"); Object data = null; BigDecimal defaultDecimal = null; BigDecimal expResult = null; BigDecimal result = Convert.toBigDecimal(data, defaultDecimal); List<String> trueStrings = Arrays.asList("47833", "2", "0.00050", "45.67"); List<String> falseStrings = Arrays.asList("Test", "123O", "F", "a", "", "null"); for (String testBigDecimal : trueStrings) { result = Convert.toBigDecimal(testBigDecimal, defaultDecimal); if (result == null) { fail("Failed on: " + testBigDecimal); } } for (String testBigDecimal : falseStrings) { result = Convert.toBigDecimal(testBigDecimal, defaultDecimal); assertEquals(expResult, result); } }