@Test
public void testGetCountForKey() {

    IndexedCollection<Car> cars = createIndexedCollectionOfCars(20);
    // Add an unsorted index on Car.MANUFACTURER (a HashIndex)...
    cars.addIndex(HashIndex.onAttribute(Car.MANUFACTURER));
    MetadataEngine<Car> metadataEngine = cars.getMetadataEngine();
    // Count the number of cars manufactured by BMW...
    AttributeMetadata<String, Car> attributeMetadata = metadataEngine.getAttributeMetadata(Car.MANUFACTURER);
    assertEquals(Integer.valueOf(2), attributeMetadata.getCountForKey("BMW"));
}