Helper { public static int convertStringToIntOrDefault(String str, int defaultValue) { if (Strings.isNullOrEmpty(str)) return defaultValue; int strToInt; try { strToInt = Integer.parseInt(str); } catch (NumberFormatException nfe) { strToInt = defaultValue; } return strToInt; }  static void shuffleIntArray(int[] arr); static int[] convertIntegerListToIntArray(List<Integer> listOfInts); static Point rotatePoint(Point reference, Point toRotate, int degrees); static void validateCodePointValues(int[] codePoints); static int[] constructCodePointArrayFomMinMaxValues(int minCodePoint, int maxCodePoint); static int convertStringToIntOrDefault(String str, int defaultValue); static int[] convertCodePointsToSortedIntArrayNoDuplicates(String line, String range);  }
@Test public void testConvertStringToIntOrDefault() throws Exception { assertEquals(1, Helper.convertStringToIntOrDefault("1", 1)); assertNotEquals(1, Helper.convertStringToIntOrDefault("1.1", 2)); assertEquals(2, Helper.convertStringToIntOrDefault("1.1", 2)); }