@Test
public void testGetCountForKey() {

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