PurgeHistoryTask implements JobExecutor { @Override public JobExecutionResult process(Job job, JobExecutionContext context) { try (ResourceResolver resolver = resolverService.getServiceResourceResolver()) { historyUtil.purgeHistory(resolver, config.daysToKeep()); resolver.commit(); return context.result().message("Purged AECU history entries").succeeded(); } catch (LoginException e) { return context.result().message("Service resolver failed with " + e.getMessage()).failed(); } catch (PersistenceException e) { return context.result().message("Purge failed with " + e.getMessage()).failed(); } }  @Activate void activate(PurgeHistoryConfiguration config); @Override JobExecutionResult process(Job job, JobExecutionContext context);  }
@Test public void process() throws PersistenceException { task.process(null, context); verify(resolver, times(1)).commit(); }
@Test public void process_loginException() throws PersistenceException, LoginException { when(resolverService.getServiceResourceResolver()).thenThrow(LoginException.class); task.process(null, context); verify(resolver, never()).commit(); }