HistoryUtil { public void purgeHistory(ResourceResolver resolver, int daysToKeep) throws PersistenceException { Resource base = resolver.getResource(HISTORY_BASE); Calendar calendar = new GregorianCalendar(); calendar.add(Calendar.DAY_OF_MONTH, -daysToKeep); LOG.debug("Starting purge with limit " + calendar.getTime().toString()); deleteRecursive(base.listChildren(), calendar, new int[] {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH}); }  HistoryEntry createHistoryEntry(ResourceResolver resolver); void storeExecutionInHistory(HistoryEntry history, ExecutionResult result, ResourceResolver resolver); void finishHistoryEntry(HistoryEntry history, ResourceResolver resolver); List<HistoryEntry> getHistory(int startIndex, int count, ResourceResolver resolver); Resource getHistoryEntryResource(Resource child); HistoryEntry readHistoryEntry(Resource resource); ExecutionResult readHistorySingleResult(Resource resource); void purgeHistory(ResourceResolver resolver, int daysToKeep); void selfCheck(ResourceResolver resolver); static final String HISTORY_BASE; static final String NODE_FALLBACK; static final String ATTR_PATH; }
@Test public void purgeHistory() throws PersistenceException { historyUtil.purgeHistory(resolver, 1); verify(resolver, times(6)).delete(Mockito.any()); }