### Question:
ObservationFinder { static int binarySearch(long[] values, long value) { int low = 0; int high = values.length - 1; while (low <= high) { final int mid = (high + low) >> 1; final long midValue = values[mid]; if (midValue <= value) { low = mid + 1; } else { high = mid - 1; } } return high; } ObservationFinder(PersistenceManager persistenceManager); void findPrimarySensorObservations(List<SamplingPoint> samples, Parameter parameter); void findSecondarySensorObservations(List<SamplingPoint> samples, Parameter parameter); void findObservations(List<SamplingPoint> samples, Parameter parameter, boolean primarySensor);  }### Answer:
@Test public void testBinarySearch() throws Exception { final long[] values = {2, 3, 4, 6, 9, 11, 12}; assertEquals(0, ObservationFinder.binarySearch(values, 2)); assertEquals(1, ObservationFinder.binarySearch(values, 3)); assertEquals(2, ObservationFinder.binarySearch(values, 4)); assertEquals(3, ObservationFinder.binarySearch(values, 6)); assertEquals(4, ObservationFinder.binarySearch(values, 9)); assertEquals(5, ObservationFinder.binarySearch(values, 11)); assertEquals(6, ObservationFinder.binarySearch(values, 12)); assertEquals(2, ObservationFinder.binarySearch(values, 5)); assertEquals(3, ObservationFinder.binarySearch(values, 7)); assertEquals(3, ObservationFinder.binarySearch(values, 8)); assertEquals(4, ObservationFinder.binarySearch(values, 10)); assertEquals(6, ObservationFinder.binarySearch(values, 13)); assertEquals(6, ObservationFinder.binarySearch(values, 14)); assertEquals(-1, ObservationFinder.binarySearch(values, 0)); assertEquals(-1, ObservationFinder.binarySearch(values, 1)); }