@Test
public void testWrappingPersistence() {

    Collection<Car> backingCollection = new LinkedHashSet<Car>();
    backingCollection.addAll(CarFactory.createCollectionOfCars(3)); // CarIds 0, 1, 2
    IndexedCollection<Car> indexedCollection = new ConcurrentIndexedCollection<Car>(
            WrappingPersistence.aroundCollection(backingCollection)
    );
    indexedCollection.addIndex(NavigableIndex.onAttribute(Car.CAR_ID));
    ResultSet<Car> results = indexedCollection.retrieve(greaterThan(Car.CAR_ID, 0));
    // Assert that the index will be used...
    assertNotEquals(Integer.MAX_VALUE, results.getRetrievalCost());
    // Assert correct results are returned...
    Set<Integer> expectedCarIds, actualCarIds;
    expectedCarIds = asSet(1, 2);
    actualCarIds = extractCarIds(results, new HashSet<Integer>());
    assertEquals(expectedCarIds, actualCarIds);
    // Add that a new object added to the IndexedCollection...
    indexedCollection.add(CarFactory.createCar(3));
    // Assert the new object was added to the backing collection...
    expectedCarIds = asSet(0, 1, 2, 3);
    actualCarIds = extractCarIds(backingCollection, new HashSet<Integer>());
    assertEquals(expectedCarIds, actualCarIds);
}