### Question:
Convert { public static Long toLong(Object data) { if (data != null) { try { if (data instanceof Integer) { return Long.parseLong(Integer.toString((Integer) data)); } else if (data instanceof String) { return Long.parseLong(data.toString()); } else if (data instanceof BigDecimal) { return ((BigDecimal) data).longValue(); } else if (data instanceof BigInteger) { return ((BigInteger) data).longValue(); } else if (data instanceof Number) { return ((Number) data).longValue(); } } catch (NumberFormatException e) { return null; } } return 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 testToLong() { System.out.println("toLong"); Object data = null; Long expResult = null; Long result = Convert.toLong(data); List<String> trueStrings = Arrays.asList("10023", "4788294", "3"); List<String> falseStrings = Arrays.asList("123.456", "fName", "C", "1.23.3", "9223372036854775909", "", "null"); for (String testLong : trueStrings) { result = Convert.toLong(testLong); if (result == null) { fail("Failed on: " + testLong); } } for (String testLong : falseStrings) { result = Convert.toLong(testLong); assertEquals(expResult, result); } }