Collections.singleton(payload));
Future<List<PageStats>> result = store.addHitsAndSetAccesTime(Collections
.singleton(payload));
List<PageStats> allStats = result.get();
PageStats stats = allStats.get(0);
float fillFactor = stats.getFillFactor();
assertEquals(1.0f, fillFactor, 1e-6);
int lastAccessTimeMinutes = stats.getLastAccessTimeMinutes();
assertEquals(sysUtils.currentTimeMinutes(), lastAccessTimeMinutes);
float frequencyOfUsePerMinute = stats.getFrequencyOfUsePerMinute();
assertEquals(100f, frequencyOfUsePerMinute);
// now 1 minute later...
sysUtils.setCurrentTimeMinutes(sysUtils.currentTimeMinutes() + 2);
sysUtils.setCurrentTimeMillis(sysUtils.currentTimeMillis() + 2 * 60 * 1000);
numHits = 10;
payload.setLastAccessTime(sysUtils.currentTimeMillis() - 1 * 60 * 1000);
payload.setNumHits(numHits);
result = store.addHitsAndSetAccesTime(Collections.singleton(payload));
allStats = result.get();
stats = allStats.get(0);
lastAccessTimeMinutes = stats.getLastAccessTimeMinutes();
assertEquals(11, lastAccessTimeMinutes);
frequencyOfUsePerMinute = stats.getFrequencyOfUsePerMinute();
float expected = 55.0f;// the 100 previous + the 10 added now / the 2 minutes that elapsed
assertEquals(expected, frequencyOfUsePerMinute, 1e-6f);
}