@Test
public void testGetDistinctKeys() {

    IndexedCollection<Car> cars = createIndexedCollectionOfCars(20); // the 20 cars will contain 10 distinct models
    // Add an unsorted index on Car.MODEL (a HashIndex)...
    cars.addIndex(HashIndex.onAttribute(Car.MODEL));
    MetadataEngine<Car> metadataEngine = cars.getMetadataEngine();
    // Access metadata for Car.MODEL attribute.
    // Because we call getAttributeMetadata() (and not getSortedAttributeMetadata()),
    // values will be returned in no particular order...
    AttributeMetadata<String, Car> attributeMetadata = metadataEngine.getAttributeMetadata(Car.MODEL);
    // Call AttributeMetadata.getDistinctKeys() to retrieve distinct keys in no particular order.
    // We retrieve into a Set (not a List), to assert the expected values were returned, without asserting any order...
    assertEquals(
            asSet("Accord", "Avensis", "Civic", "Focus", "Fusion", "Hilux", "Insight", "M6", "Prius", "Taurus"),
            attributeMetadata.getDistinctKeys().collect(toSet())
    );
}