PropertyConverter { public static Long toLong(Object value) throws ConversionException { Number n = toNumber(value, Long.class); if (n instanceof Long) { return (Long) n; } else { return new Long(n.longValue()); } } private  PropertyConverter(); static Boolean toBoolean(Object value); static Integer toInteger(Object value); static Long toLong(Object value); static BigInteger toBigInteger(Object value); static List<String> toList(Object value); static Set<String> toSet(Object value);  }
@Test public void testToLong() { assertEquals(Long.valueOf(1), toLong("1")); assertEquals(Long.valueOf(1), toLong(1)); assertEquals(Long.valueOf(1), toLong(Short.valueOf("1"))); assertEquals(Long.valueOf(255), toLong("0xFF")); assertEquals(Long.valueOf(1), toLong("0b1")); }
@Test public void testFailToLong() { Throwable t = assertThrows(ConversionException.class, () -> toLong(BAD_COMPARISON)); assertEquals(expectedMessage(BAD_COMPARISON, Long.class), t.getMessage()); }