ParserUtil { public static int getIntValue(String intStr, int defaultVal) { int paramVal = 0; try { if ((intStr != null) && (!intStr.equals(""))) { paramVal = Integer.parseInt(intStr); } else { paramVal = defaultVal; } } catch (NumberFormatException e) { paramVal = defaultVal; } return paramVal; }  static long getLongValue(String numStr, long defaultVal); static int getIntValue(String intStr, int defaultVal);  }
@Test public void testGetIntValue_1() { String intStr = "10"; int defaultVal = 1; int result = ParserUtil.getIntValue(intStr, defaultVal); assertEquals(10, result); }
@Test public void testGetIntValue_3() { String intStr = null; int defaultVal = 1; int result = ParserUtil.getIntValue(intStr, defaultVal); assertEquals(1, result); }