UploadManager { public String handleFilterUpload(final MultipartFile file, final String outFileName) throws IOException { return handleFileUpload(file, outFileName, getFilterUploadPath()); } UploadManager(final String uploadPath); String handleDeserializerUpload(final MultipartFile file, final String outFileName); String handleFilterUpload(final MultipartFile file, final String outFileName); String handleKeystoreUpload(final MultipartFile file, final String outFileName); boolean deleteKeyStore(final String keyStoreFile);  }
@Test public void testHandleFilterUpload() throws IOException { final Path tempDirectory = Files.createTempDirectory(null); final String mockContent = "test content"; final MockMultipartFile myFile = new MockMultipartFile( "data", "filename.txt", "text/plain", mockContent.getBytes(StandardCharsets.UTF_8) ); final String outputFilename = "MyUpload.jar"; final String expectedUploadedPath = tempDirectory.toString() + "/filters/" + outputFilename; final UploadManager uploadManager = new UploadManager(tempDirectory.toString()); final String result = uploadManager.handleFilterUpload(myFile, outputFilename); assertEquals("Has expected result filename", expectedUploadedPath, result); final byte[] contentBytes = Files.readAllBytes(new File(result).toPath()); final String contentString = new String(contentBytes, StandardCharsets.UTF_8); assertEquals("Contents are expected", mockContent, contentString); }