@Test public final void testRun() { Whitebox.setInternalState(underTest, "timeLimitInSeconds", 10); Whitebox.setInternalState(underTest, "simpleDateFormat", new SimpleDateFormat("yyyyMMddHHmmss")); DeletedFileProvider deletedFileProvider = new DeletedFileProvider(); Whitebox.setInternalState(underTest, "deletedFileProvider", deletedFileProvider); File file1 = Mockito.mock(File.class); given(file1.getName()).willReturn("20130701151510.0000resp.txt"); File file2 = Mockito.mock(File.class); given(file2.getName()).willReturn("20130701151510.0000req.txt"); File file3 = Mockito.mock(File.class); given(file3.getName()).willReturn("20130701151513.0000req.txt"); File file4 = Mockito.mock(File.class); given(file4.getName()).willReturn("20130701151513.0000resp.txt"); File[] messageFiles = new File[4]; messageFiles[0] = file1; messageFiles[1] = file2; messageFiles[2] = file3; messageFiles[3] = file4; given(logFilePath.getLogFilePath()).willReturn(path); given(path.toFile()).willReturn(logFolder); given(logFolder.listFiles(fileFilter)).willReturn(messageFiles); Calendar cal = Calendar.getInstance(); cal.set(2013, 6, 1, 15, 15, 21); Date date = cal.getTime(); given(currentDateProvider.getCurrentDate()).willReturn(date); underTest.run(); verify(file1).delete(); verify(file2).delete(); verify(file3, never()).delete(); verify(file4, never()).delete(); }
@Override public void run() { File messagesFolder = logFilePath.getLogFilePath().toFile(); int noDeletedFiles = deleteFilesAboveFileLimit(messagesFolder); deletedFileProvider.setDeletedFilesCount(noDeletedFiles); logMaintenanceResult(noDeletedFiles); }
TimeLimitMaintainerTask implements MaintainerTask { @Override public void run() { File messagesFolder = logFilePath.getLogFilePath().toFile(); int noDeletedFiles = deleteFilesAboveFileLimit(messagesFolder); deletedFileProvider.setDeletedFilesCount(noDeletedFiles); logMaintenanceResult(noDeletedFiles); } }
TimeLimitMaintainerTask implements MaintainerTask { @Override public void run() { File messagesFolder = logFilePath.getLogFilePath().toFile(); int noDeletedFiles = deleteFilesAboveFileLimit(messagesFolder); deletedFileProvider.setDeletedFilesCount(noDeletedFiles); logMaintenanceResult(noDeletedFiles); } TimeLimitMaintainerTask(); }
TimeLimitMaintainerTask implements MaintainerTask { @Override public void run() { File messagesFolder = logFilePath.getLogFilePath().toFile(); int noDeletedFiles = deleteFilesAboveFileLimit(messagesFolder); deletedFileProvider.setDeletedFilesCount(noDeletedFiles); logMaintenanceResult(noDeletedFiles); } TimeLimitMaintainerTask(); @Override void run(); @Override void logParameters(); }
TimeLimitMaintainerTask implements MaintainerTask { @Override public void run() { File messagesFolder = logFilePath.getLogFilePath().toFile(); int noDeletedFiles = deleteFilesAboveFileLimit(messagesFolder); deletedFileProvider.setDeletedFilesCount(noDeletedFiles); logMaintenanceResult(noDeletedFiles); } TimeLimitMaintainerTask(); @Override void run(); @Override void logParameters();  }