@Test(expected = UniqueIndex.UniqueConstraintViolatedException.class)
public void testDuplicateObjectDetection_SimpleAttribute() {

    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>();
    // Add some indexes...
    cars.addIndex(UniqueIndex.onAttribute(Car.CAR_ID));
    // Add some objects to the collection...
    cars.add(new Car(1, "ford focus", "great condition, low mileage", Arrays.asList("spare tyre", "sunroof")));
    cars.add(new Car(2, "ford taurus", "dirty and unreliable, flat tyre", Arrays.asList("spare tyre", "radio")));
    cars.add(new Car(3, "honda civic", "has a flat tyre and high mileage", Arrays.asList("radio")));
    cars.add(new Car(2, "some other car", "foo", Arrays.asList("bar")));
}