@Test
public void testLastHarvested() {

  PersistenceEnv penv = newPenv();
  assertEquals(Option.none(), LastHarvested.getLastHarvestDate(penv, "bla"));
  DateTime now = new DateTime();
  Date a = now.toDate();
  // save
  LastHarvested.update(penv, new LastHarvested("url-1", a));
  assertEquals(some(a), LastHarvested.getLastHarvestDate(penv, "url-1"));
  // now update
  Date b = now.plusMinutes(1).toDate();
  LastHarvested.update(penv, new LastHarvested("url-1", b));
  assertEquals(some(b), LastHarvested.getLastHarvestDate(penv, "url-1"));
  // save another
  LastHarvested.update(penv, new LastHarvested("url-2", a));
  assertEquals(some(a), LastHarvested.getLastHarvestDate(penv, "url-2"));
  // cleanup 1
  LastHarvested.cleanup(penv, "url-1 url-2".split(" "));
  assertTrue(LastHarvested.getLastHarvestDate(penv, "url-1").isSome());
  assertTrue(LastHarvested.getLastHarvestDate(penv, "url-2").isSome());
  // cleanup 2
  LastHarvested.cleanup(penv, "url-2".split(" "));
  assertTrue(LastHarvested.getLastHarvestDate(penv, "url-1").isNone());
  assertTrue(LastHarvested.getLastHarvestDate(penv, "url-2").isSome());
}