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

    Collection<Car> collection = mock(Collection.class);
    Iterator<Car> iterator = mock(Iterator.class);
    when(iterator.hasNext()).thenReturn(true);
    when(iterator.next()).thenReturn(CarFactory.createCar(1));
    when(collection.iterator()).thenReturn(iterator);
    ObjectSet<Car> objectSet = ObjectSet.fromCollection(collection);
    CloseableIterator<Car> objectSetIterator = objectSet.iterator();
    Assert.assertTrue(objectSetIterator.hasNext());
    Assert.assertNotNull(objectSetIterator.next());
    objectSetIterator.remove();
    Mockito.verify(iterator, times(1)).remove();
}