DataHelper { public static Long tryParseLong(String value) { try { return Long.parseLong(value); } catch (NumberFormatException e) { return null; } } private  DataHelper(); static String createUuid(); static boolean isSame(HasUuid left, HasUuid right); static boolean equal(Object a, Object b); @SuppressWarnings("unchecked") static int compare(Comparable<T> a, Comparable<T> b); static String toStringNullable(Object nullable); static boolean isNullOrEmpty(String string); static boolean isValueType(Class<?> type); static byte[] longToBytes(long x, long y); static String getShortUuid(EntityDto domainObject); static String getShortUuid(String uuid); static String convertStreamToString(InputStream is); static String capitalize(String input); static String lowercaseFirst(String input); static BigDecimal getTruncatedBigDecimal(BigDecimal number); static List<Integer> buildIntegerList(int min, int max); static List<Integer> buildIntegerList(int min, int max, int step); static SortedSet<Map.Entry<K, V>> entriesSortedByValues(Map<K, V> map); static String parseNumberToString(int number); static String parseBoolean(Boolean value); static String getSexAndAgeGroupString(AgeGroup ageGroup, Sex sex); static String getHumanClassName(Class<?> classType); static String getHumanClassCaption(Class<?> classType); static Integer tryParseInt(String value); static Long tryParseLong(String value); static boolean isParseableInt(String value);  }
@Test public void testTryParseLong() { assertNull(DataHelper.tryParseLong(null)); assertNull(DataHelper.tryParseLong("null")); assertNull(DataHelper.tryParseLong("null1")); assertNull(DataHelper.tryParseLong("1null")); assertEquals((Long) 1l, DataHelper.tryParseLong("1")); assertEquals((Long) Long.MAX_VALUE, DataHelper.tryParseLong(String.valueOf(Long.MAX_VALUE))); assertNull(DataHelper.tryParseLong(String.valueOf(Long.MAX_VALUE) + "0")); }