LocalDiskFileStoreService implements FileStoreService { @Override public File fetch(FileStoreMapper fileMapper, String moduleName) { return this.fetch(fileMapper.getFileStoreId(), moduleName); } @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 testFetch() throws IOException { final File newFile = createTempFileWithContent(); final FileStoreMapper map = diskFileService.store(newFile, "fileName", "text/plain", "test"); final File file = diskFileService.fetch(map, "testmodule"); assertNotNull(file); assertTrue(file.getName().equals(map.getFileStoreId().toString())); deleteTempFiles(newFile, map); }
@Test(expected = ApplicationRuntimeException.class) public final void testFetchFailNonExisting() throws IOException { final FileStoreMapper map = new FileStoreMapper(UUID.randomUUID().toString(), "fileName"); diskFileService.fetch(map, "testmoduleNo"); }