@Test
public void testGetKeysAndValues() {

    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<>();
    Car car1 = new Car(1, "Ford", "Taurus", Car.Color.GREEN, 4, 1000.0, emptyList(), Collections.emptyList());
    Car car2 = new Car(2, "Honda", "Civic", Car.Color.BLUE, 4, 2000.0, emptyList(), Collections.emptyList());
    Car car3 = new Car(3, "Honda", "Accord", Car.Color.RED, 4, 3000.0, emptyList(), Collections.emptyList());
    cars.addAll(asList(car1, car2, car3));
    // Add an unsorted index on Car.MANUFACTURER (a HashIndex)...
    cars.addIndex(HashIndex.onAttribute(Car.MANUFACTURER));
    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.MANUFACTURER);
    // 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(keyValue("Ford", car1), keyValue("Honda", car2), keyValue("Honda", car3)),
            attributeMetadata.getKeysAndValues().collect(toSet())
    );
}