BundleDirectoryManager { public File saveBundleFile(MultipartFile multipartFile) throws IOException { String destFileName = multipartFile.getOriginalFilename(); InputStream is = null; try { is = multipartFile.getInputStream(); return saveBundleStreamToFile(destFileName, is); } finally { IOUtils.closeQuietly(is); } }  @PostConstruct void init(); String getBundleDir(); void setBundleDir(String bundleDir); File saveBundleFile(MultipartFile multipartFile); File saveBundleStreamToFile(String destFileName, InputStream in); boolean removeBundle(Bundle bundle);  }
@Test public void testSaveBundleFile() throws IOException { when(multipartFile.getOriginalFilename()).thenReturn(FILENAME); when(multipartFile.getInputStream()).thenReturn(new ByteArrayInputStream(CONTENT.getBytes())); bundleDirManager.saveBundleFile(multipartFile); verify(multipartFile).getInputStream(); assertEquals(CONTENT, FileUtils.readFileToString(new File(tmpDir, FILENAME))); }