ParsingUtils { public static long convertToLong(final String val) { return convertToLong(val, 0); }  static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue); static boolean convertToBoolean(final String val); static int convertToInt(final String val); static int convertToInt(final String val, final int defaultValue); static long convertToLong(final String val); static long convertToLong(final String val, final int defaultValue); static long convertToLong(final String val, final long defaultValue); static double convertToDouble(final String val); static double convertToDouble(final String val, final double defaultValue); static long convertToCapacity(
      final String str,
      final long defaultValue); static long convertToTime(final String val); static long parse(
      final String val,
      final TimeUnit unit); static final List<ScaleUnit> INTERVALS; }
@Test public void testConvertToLong() { final Object[][] testParameters = new Object[][] {{"1", 1L}, {"10", 10L}, {"100", 100L}, {"Not", 0L}}; for (final Object[] testParameter : testParameters) { long expected = (Long) testParameter[1]; String val = (String) testParameter[0]; assertEquals(expected, ParsingUtils.convertToLong(val)); } }
@Test public void testConvertToLongOnDefaultValue() { final Object[][] testParameters = new Object[][] {{"1", 0L, 1L}, {"10", 1L, 10L}, {"100", 2L, 100L}, {"Not01", 0L, 0L}, {"Not02", 1L, 1L}, {"Not03", 2L, 2L}}; assertEquals(0, ParsingUtils.convertToLong(null, 0)); assertEquals(1, ParsingUtils.convertToLong(null, 1)); for (final Object[] testParameter : testParameters) { long expected = (Long) testParameter[2]; String val = (String) testParameter[0]; long defaultValue = (Long) testParameter[1]; assertEquals(expected, ParsingUtils.convertToLong(val, defaultValue)); } }