@Test
public void testGetKeysAndValues(){

    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MANUFACTURER,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));
    Multimap<String, Car> expected = MultimapBuilder.SetMultimapBuilder.linkedHashKeys().hashSetValues().build();
    expected.put("BMW", CarFactory.createCar(9));
    expected.put("Ford", CarFactory.createCar(0));
    expected.put("Ford", CarFactory.createCar(1));
    expected.put("Ford", CarFactory.createCar(2));
    expected.put("Honda", CarFactory.createCar(3));
    expected.put("Honda", CarFactory.createCar(4));
    expected.put("Honda", CarFactory.createCar(5));
    expected.put("Toyota", CarFactory.createCar(6));
    expected.put("Toyota", CarFactory.createCar(7));
    expected.put("Toyota", CarFactory.createCar(8));
    Multimap<String, Car> actual = MultimapBuilder.SetMultimapBuilder.linkedHashKeys().hashSetValues().build();
    CloseableIterable<KeyValue<String, Car>> keysAndValues = offHeapIndex.getKeysAndValues(createQueryOptions(connectionManager));
    for (KeyValue<String, Car> keyValue : keysAndValues) {
        actual.put(keyValue.getKey(), keyValue.getValue());
    }
    assertEquals("keys and values", expected, actual);
    List<String> expectedKeysOrder = Lists.newArrayList(expected.keySet());
    List<String> actualKeysOrder = Lists.newArrayList(actual.keySet());
    assertEquals("key order", expectedKeysOrder, actualKeysOrder);
}