LastHarvested { public LastHarvested() { } LastHarvested();  LastHarvested(String url, Date timestamp); String getUrl(); Date getTimestamp(); static Option<Date> getLastHarvestDate(PersistenceEnv penv, final String url); static void update(PersistenceEnv penv, final LastHarvested entity); static void cleanup(PersistenceEnv penv, final String[] keepUrls);  }
@Test public void testLastHarvested() { PersistenceEnv penv = newPenv(); assertEquals(Option.none(), LastHarvested.getLastHarvestDate(penv, "bla")); DateTime now = new DateTime(); Date a = now.toDate(); LastHarvested.update(penv, new LastHarvested("url-1", a)); assertEquals(some(a), LastHarvested.getLastHarvestDate(penv, "url-1")); Date b = now.plusMinutes(1).toDate(); LastHarvested.update(penv, new LastHarvested("url-1", b)); assertEquals(some(b), LastHarvested.getLastHarvestDate(penv, "url-1")); LastHarvested.update(penv, new LastHarvested("url-2", a)); assertEquals(some(a), LastHarvested.getLastHarvestDate(penv, "url-2")); LastHarvested.cleanup(penv, "url-1 url-2".split(" ")); assertTrue(LastHarvested.getLastHarvestDate(penv, "url-1").isSome()); assertTrue(LastHarvested.getLastHarvestDate(penv, "url-2").isSome()); LastHarvested.cleanup(penv, "url-2".split(" ")); assertTrue(LastHarvested.getLastHarvestDate(penv, "url-1").isNone()); assertTrue(LastHarvested.getLastHarvestDate(penv, "url-2").isSome()); }