LocalDiskFileStoreService implements FileStoreService { @Override public FileStoreMapper store(File sourceFile, String fileName, String mimeType, String moduleName) { return store(sourceFile, fileName, mimeType, moduleName, true); } @Autowired  LocalDiskFileStoreService(@Value("${filestore.base.dir}") String fileStoreBaseDir); @Override FileStoreMapper store(File sourceFile, String fileName, String mimeType, String moduleName); @Override FileStoreMapper store(InputStream sourceFileStream, String fileName, String mimeType, String moduleName); @Override FileStoreMapper store(byte[] fileBytes, String fileName, String mimeType, String moduleName); @Override FileStoreMapper store(File file, String fileName, String mimeType, String moduleName, boolean deleteFile); @Override FileStoreMapper store(InputStream fileStream, String fileName, String mimeType, String moduleName, boolean closeStream); @Override File fetch(FileStoreMapper fileMapper, String moduleName); @Override Set<File> fetchAll(Set<FileStoreMapper> fileMappers, String moduleName); @Override File fetch(String fileStoreId, String moduleName); @Override Path fetchAsPath(String fileStoreId, String moduleName); @Override void delete(String fileStoreId, String moduleName);  }
@Test public final void testUploadFile() throws IOException { final File newFile = createTempFileWithContent(); final FileStoreMapper map = diskFileService.store(newFile, "fileName", "testmodule", "text/plain"); deleteTempFiles(newFile, map); assertNotNull(map.getFileStoreId()); }
@Test(expected = ApplicationRuntimeException.class) public final void testUploadFileFail() throws IOException { final File newFile = new File("file.txt"); diskFileService.store(newFile, "fileName", "testmodule", "text/plain"); }
@Test public final void testUploadInputStream() throws IOException { final File newFile = createTempFileWithContent(); final FileStoreMapper map = diskFileService.store(new FileInputStream(newFile), "nofile", "text/plain", "testmodule"); deleteTempFiles(newFile, map); assertNotNull(map.getFileStoreId()); }