### Question:
TripletInSequenceWithSpecialProperty { public static int[] findTriplet(int[] a) { if ((a == null) || (a.length < 3)) { throw new IllegalArgumentException( "Array should have at least 3 elements"); } if ((a[0] < a[1]) || (a[a.length - 1] < a[a.length - 2])) { throw new IllegalArgumentException( "Array does not have special property"); } if (a.length == 3) { return new int[] { a[0], a[1], a[2] }; } int left = 0; int right = a.length - 2; while (left < right) { int middle = left + ((right - left) >> 1); if (a[middle + 1] - a[middle] < 0) { left = middle + 1; } else { right = middle; } } return new int[] { a[left - 1], a[left], a[left + 1] }; }  static int[] findTriplet(int[] a);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testFindTripletWithNullArray() { findTriplet(null); }
@Test(expected = IllegalArgumentException.class) public void testFindTripletWithEmptyArray() { findTriplet(null); }
@Test(expected = IllegalArgumentException.class) public void testFindTripletWithTwoElementArray() { findTriplet(new int[] { 1, 2 }); }
@Test(expected = IllegalArgumentException.class) public void testFindTripletWithThreeElementsNonSpecialArray() { findTriplet(new int[] { 1, 2, 3 }); }
@Test(expected = IllegalArgumentException.class) public void testFindTripletWithFourElementsNonSpecialArray() { findTriplet(new int[] { 1, 2, 3, 4 }); }
@Test public void testFindTripletWithThreeElementArray() { int[] array = new int[] { 2, 2, 3 }; int[] expected = new int[] { 2, 2, 3 }; int[] res = findTriplet(array); assertThat( "Result is not matched with array " + Arrays.toString(array), res, is(expected)); }
@Test public void testFindTripletWithFourElementArray() { int[] array = new int[] { 2, 2, 1, 3 }; int[] expected = new int[] { 2, 1, 3 }; int[] res = findTriplet(array); assertThat( "Result is not matched with array " + Arrays.toString(array), res, is(expected)); }
@Test public void testFindTripletWithFiveElementArray() { int[] array = new int[] { 2, 2, 1, 3, 5 }; int[] expected = new int[] { 2, 1, 3 }; int[] res = findTriplet(array); assertThat( "Result is not matched with array " + Arrays.toString(array), res, is(expected)); }
@Test public void testFindTripletWithLongArray() { int[] array = new int[] { 9, 8, 5, 4, 3, 2, 6, 7 }; int[] expected = new int[] { 3, 2, 6 }; int[] res = findTriplet(array); assertThat( "Result is not matched with array " + Arrays.toString(array), res, is(expected)); }