FileItemSimilarity implements ItemSimilarity { @Override public double itemSimilarity(long itemID1, long itemID2) throws TasteException { return delegate.itemSimilarity(itemID1, itemID2); } FileItemSimilarity(File dataFile);  FileItemSimilarity(File dataFile, long minReloadIntervalMS); @Override double[] itemSimilarities(long itemID1, long[] itemID2s); @Override long[] allSimilarItemIDs(long itemID); @Override double itemSimilarity(long itemID1, long itemID2); @Override void refresh(Collection<Refreshable> alreadyRefreshed); @Override String toString(); static final long DEFAULT_MIN_RELOAD_INTERVAL_MS; }
@Test public void testNoRefreshAfterFileUpdate() throws Exception { ItemSimilarity similarity = new FileItemSimilarity(testFile, 0L); similarity.itemSimilarity(1L, 5L); Thread.sleep(2000L); writeLines(testFile, changedData); assertEquals(0.5, similarity.itemSimilarity(1L, 7L), EPSILON); assertEquals(0.5, similarity.itemSimilarity(7L, 1L), EPSILON); assertTrue(Double.isNaN(similarity.itemSimilarity(7L, 8L))); }