CombinationsOfChange { public List<List<Integer>> get(int[] availableChange, int value) { validateInputData(availableChange, value); List<List<Integer>> changeCombinations = new LinkedList<List<Integer>>(); for (int i = 0; i < availableChange.length; i++) { int[] availableMoneys = Arrays.copyOfRange(availableChange, 0, availableChange.length - i); List<Integer> change = getChange(availableMoneys, value); changeCombinations.add(change); } return changeCombinations; } CombinationsOfChange(); List<List<Integer>> get(int[] availableChange, int value);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullArrays() { combinationsOfChange.get(null, 7); }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptValueToChangeMinorOrEqualsToZero() { combinationsOfChange.get(new int[9], -3); }
@Test public void shouldReturnAnEmptyCollectionIfArrayOfMoneysIsEmpty() { List<List<Integer>> combinations = combinationsOfChange.get(new int[0], 1); assertTrue(combinations.isEmpty()); }
@Test public void shouldReturnEveryCombinationOfChange() { int[] moneys = { 5, 10, 15, 50 }; List<List<Integer>> combinations = combinationsOfChange.get(moneys, 60); assertContainsChange(combinations, new Integer[] { 50, 10 }, new Integer[] { 15, 15, 15, 15 }, new Integer[] { 10, 10, 10, 10, 10, 10 }, new Integer[] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }); }