@Test
@SuppressWarnings("unchecked")
public void testFromObjectStore_IteratorRemove() throws Exception {

    ObjectStore<Car> objectStore = mock(ObjectStore.class);
    CloseableIterator<Car> closeableIterator = mock(CloseableIterator.class);
    when(closeableIterator.hasNext()).thenReturn(true);
    when(closeableIterator.next()).thenReturn(CarFactory.createCar(1));
    when(objectStore.iterator(Mockito.<QueryOptions>any())).thenReturn(closeableIterator);
    ObjectSet<Car> objectSet = ObjectSet.fromObjectStore(objectStore, noQueryOptions());
    CloseableIterator<Car> objectSetIterator = objectSet.iterator();
    Assert.assertTrue(objectSetIterator.hasNext());
    Assert.assertNotNull(objectSetIterator.next());
    objectSetIterator.remove();
    Mockito.verify(closeableIterator, times(1)).remove();
}