RangeIndex extends MultiValueIndex { @SuppressWarnings("unchecked") public List<Object> between(Object lowerBound, Object upperBound) { Set<Object> resultSet = new HashSet<Object>(); NavigableMap<Object, Set<Object>> map = getMap(); Entry<Object, Set<Object>> current = map.higherEntry(lowerBound); while (current != null && ((Comparable<Object>) current.getKey()).compareTo((Comparable<Object>) upperBound) < 0) { synchronized (current) { resultSet.addAll(current.getValue()); current = map.higherEntry(current.getKey()); } } return new ArrayList<Object>(resultSet); } RangeIndex(); List<Object> lessThan(Object value); List<Object> lessThanOrEqualsTo(Object value); List<Object> greaterThan(Object value); List<Object> greaterThanOrEqualsTo(Object value); @SuppressWarnings("unchecked") List<Object> between(Object lowerBound, Object upperBound); NavigableMap<Object, Set<Object>> getMap();  }
@Test public void between() { Comparable<Object> key = comparable; Object value = new Object(); Set<Object> set = new HashSet<Object>(); set.add(value); doReturn(set).when(entry).getValue(); doReturn(key).when(entry).getKey(); doReturn(entry).when(map).higherEntry(lowerBound); doReturn(-1).doReturn(1).when(key).compareTo(upperBound); doReturn(null).when(map).higherEntry(key); List<Object> list = rangeIndex.between(lowerBound, upperBound); assertTrue(list.contains(value)); }