@Test
public void testAttemptToAccessMetadataWithoutIndex() {

    IndexedCollection<Car> cars = createIndexedCollectionOfCars(5);
    @SuppressWarnings("unchecked") Attribute<Car, Integer> ATTRIBUTE = Mockito.mock(SimpleAttribute.class);
    Mockito.when(ATTRIBUTE.toString()).thenReturn("ATTRIBUTE");
    IllegalStateException expected = null;
    try {
        cars.getMetadataEngine().getAttributeMetadata(ATTRIBUTE);
    }
    catch (IllegalStateException e) {
        expected = e;
    }
    assertNotNull(expected);
    assertEquals("A KeyStatisticsAttributeIndex has not been added to the collection, and must be added first, to enable metadata to be examined for attribute: ATTRIBUTE", expected.getMessage());
}