### Question:
Convert { public static Integer toInteger(Object data) { if (data != null) { try { if (data instanceof Integer) { return (Integer) data; } else if (data instanceof String) { return Integer.parseInt(data.toString()); } else if (data instanceof BigDecimal) { return ((BigDecimal) data).intValue(); } else if (data instanceof BigInteger) { return ((BigInteger) data).intValue(); } else if (data instanceof Number) { return ((Number) data).intValue(); } } 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 testToInteger() { System.out.println("toInteger"); Object data = null; Integer expResult = null; Integer result = Convert.toInteger(data); assertEquals(expResult, result); List<String> trueStrings = Arrays.asList("1", "5000"); List<String> falseStrings = Arrays.asList("F", "1.1.2", "1.", "test", "", "null"); for (String test : trueStrings) { result = Convert.toInteger(test); if (result == null) { fail("Failed on: " + test); } } for (String test : falseStrings) { result = Convert.toInteger(test); assertEquals(expResult, result); } }