@Test void deleteFilesEntriesWithoutContentTest() throws Exception { FileEntry noContent = addTestFile(SPACE_1, NAMESPACE_1); FileEntry noContent2 = addTestFile(SPACE_2, NAMESPACE_1); addTestFile(SPACE_1, NAMESPACE_2); addTestFile(SPACE_2, NAMESPACE_2); Mockito.when(fileStorage.getFileEntriesWithoutContent(Mockito.anyList())) .thenReturn(List.of(noContent, noContent2)); int deleteWithoutContent = fileService.deleteFilesEntriesWithoutContent(); assertEquals(2, deleteWithoutContent); assertNull(fileService.getFile(SPACE_1, noContent.getId())); assertNull(fileService.getFile(SPACE_2, noContent2.getId())); }
public int deleteFilesEntriesWithoutContent() throws FileStorageException { try { List<FileEntry> entries = getSqlQueryExecutor().execute(getSqlFileQueryProvider().getListAllFilesQuery()); List<FileEntry> missing = fileStorage.getFileEntriesWithoutContent(entries); return deleteFileEntries(missing); } catch (SQLException e) { throw new FileStorageException(Messages.ERROR_GETTING_ALL_FILES, e); } }
FileService { public int deleteFilesEntriesWithoutContent() throws FileStorageException { try { List<FileEntry> entries = getSqlQueryExecutor().execute(getSqlFileQueryProvider().getListAllFilesQuery()); List<FileEntry> missing = fileStorage.getFileEntriesWithoutContent(entries); return deleteFileEntries(missing); } catch (SQLException e) { throw new FileStorageException(Messages.ERROR_GETTING_ALL_FILES, e); } } }
FileService { public int deleteFilesEntriesWithoutContent() throws FileStorageException { try { List<FileEntry> entries = getSqlQueryExecutor().execute(getSqlFileQueryProvider().getListAllFilesQuery()); List<FileEntry> missing = fileStorage.getFileEntriesWithoutContent(entries); return deleteFileEntries(missing); } catch (SQLException e) { throw new FileStorageException(Messages.ERROR_GETTING_ALL_FILES, e); } } FileService(DataSourceWithDialect dataSourceWithDialect, FileStorage fileStorage);  FileService(String tableName, DataSourceWithDialect dataSourceWithDialect, FileStorage fileStorage); protected  FileService(DataSourceWithDialect dataSourceWithDialect, SqlFileQueryProvider sqlFileQueryProvider, FileStorage fileStorage); }
FileService { public int deleteFilesEntriesWithoutContent() throws FileStorageException { try { List<FileEntry> entries = getSqlQueryExecutor().execute(getSqlFileQueryProvider().getListAllFilesQuery()); List<FileEntry> missing = fileStorage.getFileEntriesWithoutContent(entries); return deleteFileEntries(missing); } catch (SQLException e) { throw new FileStorageException(Messages.ERROR_GETTING_ALL_FILES, e); } } FileService(DataSourceWithDialect dataSourceWithDialect, FileStorage fileStorage);  FileService(String tableName, DataSourceWithDialect dataSourceWithDialect, FileStorage fileStorage); protected  FileService(DataSourceWithDialect dataSourceWithDialect, SqlFileQueryProvider sqlFileQueryProvider, FileStorage fileStorage); FileEntry addFile(String space, String namespace, String name, InputStream inputStream); FileEntry addFile(String space, String namespace, String name, File existingFile); List<FileEntry> listFiles(String space, String namespace); FileEntry getFile(String space, String id); void consumeFileContent(String space, String id, FileContentConsumer fileContentConsumer); T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor); int deleteBySpaceAndNamespace(String space, String namespace); int deleteBySpace(String space); int deleteModifiedBefore(Date modificationTime); boolean deleteFile(String space, String id); int deleteFilesEntriesWithoutContent(); }
FileService { public int deleteFilesEntriesWithoutContent() throws FileStorageException { try { List<FileEntry> entries = getSqlQueryExecutor().execute(getSqlFileQueryProvider().getListAllFilesQuery()); List<FileEntry> missing = fileStorage.getFileEntriesWithoutContent(entries); return deleteFileEntries(missing); } catch (SQLException e) { throw new FileStorageException(Messages.ERROR_GETTING_ALL_FILES, e); } } FileService(DataSourceWithDialect dataSourceWithDialect, FileStorage fileStorage);  FileService(String tableName, DataSourceWithDialect dataSourceWithDialect, FileStorage fileStorage); protected  FileService(DataSourceWithDialect dataSourceWithDialect, SqlFileQueryProvider sqlFileQueryProvider, FileStorage fileStorage); FileEntry addFile(String space, String namespace, String name, InputStream inputStream); FileEntry addFile(String space, String namespace, String name, File existingFile); List<FileEntry> listFiles(String space, String namespace); FileEntry getFile(String space, String id); void consumeFileContent(String space, String id, FileContentConsumer fileContentConsumer); T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor); int deleteBySpaceAndNamespace(String space, String namespace); int deleteBySpace(String space); int deleteModifiedBefore(Date modificationTime); boolean deleteFile(String space, String id); int deleteFilesEntriesWithoutContent();  }