ParsingUtils { public static int convertToInt(final String val) { return convertToInt(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 testConvertToInt() { final Object[][] testParameters = new Object[][] {{"1", 1}, {"10", 10}, {"100", 100}, {"Not", 0}}; for (final Object[] testParameter : testParameters) { int expected = (Integer) testParameter[1]; String val = (String) testParameter[0]; assertEquals(expected, ParsingUtils.convertToInt(val)); } }
@Test public void testConvertToIntOnDefaultValue() { final Object[][] testParameters = new Object[][] {{"1", 0, 1}, {"10", 1, 10}, {"100", 2, 100}, {"Not01", 0, 0}, {"Not02", 1, 1}, {"Not03", 2, 2}}; assertEquals(0, ParsingUtils.convertToInt(null, 0)); assertEquals(1, ParsingUtils.convertToInt(null, 1)); for (final Object[] testParameter : testParameters) { int expected = (Integer) testParameter[2]; String val = (String) testParameter[0]; int defaultValue = (Integer) testParameter[1]; assertEquals(expected, ParsingUtils.convertToInt(val, defaultValue)); } }