Helper { public static int[] convertCodePointsToSortedIntArrayNoDuplicates(String line, String range) { if (Strings.isNullOrEmpty(line)) line = range; if (Strings.isNullOrEmpty(line)) throw new IllegalArgumentException("Nothing to work on"); String[] items = line.split("\\s*,\\s*"); SortedSet<Integer> treeSetOfInts = new TreeSet<>(); for (String item : items) { if (item.contains("-")) { int[] temp = convertDashSeparatedValuesToIntArray(item); for (int t : temp) { treeSetOfInts.add(t); } } else { try { treeSetOfInts.add(Integer.parseInt(item)); } catch (NumberFormatException nfe) { } } } int[] arrayOfInts = convertIntegerSetToIntArray(treeSetOfInts); return arrayOfInts; }  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(expected = IllegalArgumentException.class) public void testConvertCodePointsToSortedIntArrayNoDuplicatesFirstBlankSecondNull() throws Exception { Helper.convertCodePointsToSortedIntArrayNoDuplicates("", ""); }
@Test public void testConvertCodePointsToSortedIntArrayNoDuplicates() throws Exception { int[] expected = {1, 2, 3}; int[] actual; assertArrayEquals(expected, Helper.convertCodePointsToSortedIntArrayNoDuplicates(null, "1-3")); assertArrayEquals(expected, Helper.convertCodePointsToSortedIntArrayNoDuplicates("1-3", "4-9")); expected = new int[]{1, 2, 3, 4, 5}; assertArrayEquals(expected, Helper.convertCodePointsToSortedIntArrayNoDuplicates("1-3, 3-5", "4-9")); assertArrayEquals(expected, Helper.convertCodePointsToSortedIntArrayNoDuplicates(", 1-3, 3-5, 3", "4-9")); }
@Test(expected = IllegalArgumentException.class) public void testConvertCodePointsToSortedIntArrayNoDuplicatesBothNull() throws Exception { Helper.convertCodePointsToSortedIntArrayNoDuplicates(null, null); }