DefaultIndexHandler implements IndexHandler<K, V> { public void addIndex(final String attributeName, final IndexType type) { if (type == IndexType.UNIQUE_HASH) { indexes.put(attributeName, new UniqueHashIndex()); } else if (type == IndexType.NON_UNIQUE_HASH) { indexes.put(attributeName, new NonUniqueHashIndex()); } else if (type == IndexType.RANGE_INDEX) { indexes.put(attributeName, new RangeIndex()); } } DefaultIndexHandler(); void addIndex(final String attributeName, final IndexType type); void add(final K key, final V value); void remove(final K key, final V value); void clear(); @SuppressWarnings("unchecked") List<K> execute(final Query query);  }
@Test public void addIndexUniqueHash() { doReturn(null).when(indexes).put(anyString(), any(CacheIndex.class)); handler.addIndex("a", IndexType.UNIQUE_HASH); verify(indexes).put(anyString(), any(UniqueHashIndex.class)); }
@Test public void addIndexNonUniqueHash() { doReturn(null).when(indexes).put(anyString(), any(CacheIndex.class)); handler.addIndex("a", IndexType.NON_UNIQUE_HASH); verify(indexes).put(anyString(), any(NonUniqueHashIndex.class)); }
@Test public void addIndexRange() { doReturn(null).when(indexes).put(anyString(), any(CacheIndex.class)); handler.addIndex("a", IndexType.RANGE_INDEX); verify(indexes).put(anyString(), any(RangeIndex.class)); }