@Test
public void testRemoveIndex() {

    CollectionQueryEngine<Car> queryEngine = new CollectionQueryEngine<Car>();
    queryEngine.init(emptyObjectStore(), queryOptionsWithOnHeapPersistence());
    HashIndex<String, Car> index1 = HashIndex.onAttribute(Car.MANUFACTURER);
    queryEngine.addIndex(index1, noQueryOptions());
    UniqueIndex<Integer, Car> index2 = UniqueIndex.onAttribute(Car.CAR_ID);
    queryEngine.addIndex(index2, noQueryOptions());
    StandingQueryIndex<Car> index3 = StandingQueryIndex.onQuery(equal(Car.MODEL, "Focus"));
    queryEngine.addIndex(index3, noQueryOptions());
    CompoundIndex<Car> index4 = CompoundIndex.onAttributes(Car.MANUFACTURER, Car.MODEL);
    queryEngine.addIndex(index4, noQueryOptions());
    HashIndex<Boolean, Car> index5 = HashIndex.onAttribute(forStandingQuery(equal(Car.MANUFACTURER, "Ford")));
    queryEngine.addIndex(index5, noQueryOptions());
    Assert.assertEquals(5, countElements(queryEngine.getIndexes()));
    queryEngine.removeIndex(index1, noQueryOptions());
    Assert.assertEquals(4, countElements(queryEngine.getIndexes()));
    queryEngine.removeIndex(index2, noQueryOptions());
    Assert.assertEquals(3, countElements(queryEngine.getIndexes()));
    queryEngine.removeIndex(index3, noQueryOptions());
    Assert.assertEquals(2, countElements(queryEngine.getIndexes()));
    queryEngine.removeIndex(index4, noQueryOptions());
    Assert.assertEquals(1, countElements(queryEngine.getIndexes()));
    queryEngine.removeIndex(index5, noQueryOptions());
    Assert.assertEquals(0, countElements(queryEngine.getIndexes()));
}