GeneratedContentCleaner implements IAction { public void execute() throws Exception { RepositoryFileTree tree = repository.getTree( ClientRepositoryPaths.getRootFolderPath(), -1, null, true ); ArrayList<RepositoryFile> generatedContentList = new ArrayList<RepositoryFile>(); findGeneratedContent( generatedContentList, tree ); for ( RepositoryFile deleteMe : generatedContentList ) { repository.deleteFile( deleteMe.getId(), true, GeneratedContentCleaner.class.getName() ); logger.info( "GeneratedContentCleaner deleting: " + deleteMe.getPath() ); } } GeneratedContentCleaner(); void execute(); long getAge(); void setAge( long age );  }
@Test public void testExecute_noFilesToDelete() throws Exception { final Date fixedDate = new SimpleDateFormat( "d/m/yyyy" ).parse( "1/1/2015" ); RepositoryFile file = new RepositoryFile.Builder( DEFAULT_STRING, FILE_ID ).folder( false ).createdDate( fixedDate ).build(); RepositoryFileTree tree = new RepositoryFileTree( file, null ); when( repo.getTree( anyString(), eq( -1 ), anyString(), eq( true ) ) ).thenReturn( tree ); generatedContentCleaner.execute(); verify( repo, never() ).deleteFile( any( Serializable.class ), eq( true ), anyString() ); }