// index a record, then close the db. reopen, then index a changed
// version of the record. now the old version should no longer be
// available.
assertTrue("database claims to be in-memory", !db.isInMemory());
Record record = TestUtils.makeRecord("ID", "1", "NAME", "AND", "EMAIL", "BBBBB");
db.index(record);
db.commit();
db.close();
db = createDatabase(config);
// same id, different values
Record record2 = TestUtils.makeRecord("ID", "1", "NAME", "LARS", "EMAIL", "BARS");
db.index(record2);
db.commit();
Record r = db.findRecordById("1");
assertTrue("record not found", r != null);
assertEquals("wrong ID", "1", r.getValue("ID"));
assertEquals("wrong NAME", "LARS", r.getValue("NAME"));
assertEquals("wrong EMAIL", "BARS", r.getValue("EMAIL"));
Collection<Record> recs = db.findCandidateMatches(record2);
assertEquals("wrong number of records found", 1, recs.size());
r = recs.iterator().next();
assertEquals("wrong ID", "1", r.getValue("ID"));
assertEquals("wrong NAME", "LARS", r.getValue("NAME"));
assertEquals("wrong EMAIL", "BARS", r.getValue("EMAIL"));
recs = db.findCandidateMatches(record);
assertEquals("wrong number of records found", 0, recs.size());
}