### Question:
EventCleanupJob implements Job { @Override public void execute(final JobExecutionContext context) { LOGGER.info("Quartz triggered cleanup of database - event records."); final DateTime start = DateTime.now(); try { final Date retention = this.calculateRetentionDate(); final List<Event> oldEvents = this.transactionalEventService.getEventsBeforeDate(retention, this.eventPageSize); if (!oldEvents.isEmpty()) { this.saveEventsToCsvFile(oldEvents); LOGGER.info("Deleting events..."); this.transactionalEventService.deleteEvents(oldEvents); } } catch (final Exception e) { LOGGER.error("Exception during CSV file creation, compression or event deletion.", e); } final DateTime end = DateTime.now(); LOGGER.info("Start: {}, end: {}, duration: {} milliseconds.", start, end, end.getMillis() - start.getMillis()); }  @Override void execute(final JobExecutionContext context);  }### Answer:
@Test public void test() throws IOException { final List<Event> events = this.createEvents(); Mockito.when(this.transactionalEventService.getEventsBeforeDate(any(Date.class), any(Integer.class))) .thenReturn(events); this.eventCleanupJob.execute(null); final String path = this.folder.resolve(JUST_A_FILE).getParent().toString(); final File zipFile = FileUtils.findFileInFolderUsingFilePrefix(path, this.filePrefix); assertThat(zipFile.exists()).isTrue(); assertThat(zipFile).hasExtension("zip"); assertThat(zipFile.length()).isNotZero(); ZipFileReader.extractZipFile(zipFile.getAbsolutePath(), path); zipFile.delete(); final File csvFile = FileUtils.findFileInFolderUsingFilePrefix(path, this.filePrefix); assertThat(csvFile.exists()).isTrue(); assertThat(csvFile).hasExtension("csv"); assertThat(csvFile.length()).isNotZero(); final long numberOfLines = FileUtils.countNumberOfLinesInFile(csvFile); assertThat(numberOfLines).isEqualTo(2l); }