TileSet tileSet = testTileSet;
TilePage page = new TilePage(tileSet.getId(), 0, 0, (byte) 0);
PageStatsPayload payload = new PageStatsPayload(page);
int numHits = 100;
payload.setTileSet(tileSet);
payload.setLastAccessTime(sysUtils.currentTimeMillis() - 1 * 60 * 1000);
payload.setNumHits(numHits);
payload.setNumTiles(1);
store.addToQuotaAndTileCounts(tileSet, new Quota(1, StorageUnit.MiB),
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);