ChangeDateValidator implements Validator { @Override public boolean isCacheVersionValid(StoreInfo info) { return Math.abs(changeDate - info.getChangeDate()) < 500; } ChangeDateValidator(long changeDate); @Override boolean isCacheVersionValid(StoreInfo info);  }
@Test public void testIsCacheVersionValid() throws Exception { final long date = 123456789; StoreInfoAndData info = new StoreInfoAndData((byte[]) null, date, false); assertTrue(new ChangeDateValidator(date).isCacheVersionValid(info)); info = new StoreInfoAndData((byte[]) null, date + 600, false); assertFalse(new ChangeDateValidator(date).isCacheVersionValid(info)); info = new StoreInfoAndData((byte[]) null, date - 600, false); assertFalse(new ChangeDateValidator(date).isCacheVersionValid(info)); info = new StoreInfoAndData((byte[]) null, date - 99, false); assertTrue(new ChangeDateValidator(date).isCacheVersionValid(info)); }