FibonacciNumbers { public int getRecursiveWithCatching(int n) { validateInput(n); if (n <= 1) { return 1; } else if (elements[n] != 0) { return elements[n]; } elements[n] = getRecursiveWithCatching(n - 1) + getRecursiveWithCatching(n - 2); return elements[n]; }  int getRecursive(int n); int getIterative(int n); int getRecursiveWithCatching(int n);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNegativeValuesRecursiveWithCatching() { fibonacciNumbers.getRecursiveWithCatching(-1); }
@Test public void fourthNumberInFibonacciSequenceIsThreeRecursiveWithCatching() { assertEquals(5, fibonacciNumbers.getRecursiveWithCatching(4)); }
@Test public void eleventhNumberInFibonacciSequenceIsRecursiveWithCatching() { assertEquals(144, fibonacciNumbers.getRecursiveWithCatching(11)); }