@Test public void testParseMultiPartFilesShouldReturnWithMsgWhenParamListIsEmpty() throws IOException { String actual = underTest.parseMultiPartFiles(uploadedFiles); assertEquals(actual, "No file uploaded"); }
public String parseMultiPartFiles(final List<FileItem> fields) throws IOException { String msg = ""; Iterator<FileItem> it = fields.iterator(); if (!fields.isEmpty() && it.hasNext()) { while (it.hasNext()) { FileItem fileItem = it.next(); if (!fileItem.isFormField()) { String uploadedFileName = fileItem.getName(); InputStream uploadedResource = fileItem.getInputStream(); String contentType = fileItem.getContentType(); String fieldName = fileItem.getFieldName(); msg += multiPartFileProcessor.processUploadedFile(uploadedResource, contentType, fieldName, uploadedFileName); } } } else { msg = "No file uploaded"; } return msg; }
MultiPartFileParser { public String parseMultiPartFiles(final List<FileItem> fields) throws IOException { String msg = ""; Iterator<FileItem> it = fields.iterator(); if (!fields.isEmpty() && it.hasNext()) { while (it.hasNext()) { FileItem fileItem = it.next(); if (!fileItem.isFormField()) { String uploadedFileName = fileItem.getName(); InputStream uploadedResource = fileItem.getInputStream(); String contentType = fileItem.getContentType(); String fieldName = fileItem.getFieldName(); msg += multiPartFileProcessor.processUploadedFile(uploadedResource, contentType, fieldName, uploadedFileName); } } } else { msg = "No file uploaded"; } return msg; } }
MultiPartFileParser { public String parseMultiPartFiles(final List<FileItem> fields) throws IOException { String msg = ""; Iterator<FileItem> it = fields.iterator(); if (!fields.isEmpty() && it.hasNext()) { while (it.hasNext()) { FileItem fileItem = it.next(); if (!fileItem.isFormField()) { String uploadedFileName = fileItem.getName(); InputStream uploadedResource = fileItem.getInputStream(); String contentType = fileItem.getContentType(); String fieldName = fileItem.getFieldName(); msg += multiPartFileProcessor.processUploadedFile(uploadedResource, contentType, fieldName, uploadedFileName); } } } else { msg = "No file uploaded"; } return msg; } @Autowired  MultiPartFileParser(final MultiPartFileProcessor multiPartFileProcessor); }
MultiPartFileParser { public String parseMultiPartFiles(final List<FileItem> fields) throws IOException { String msg = ""; Iterator<FileItem> it = fields.iterator(); if (!fields.isEmpty() && it.hasNext()) { while (it.hasNext()) { FileItem fileItem = it.next(); if (!fileItem.isFormField()) { String uploadedFileName = fileItem.getName(); InputStream uploadedResource = fileItem.getInputStream(); String contentType = fileItem.getContentType(); String fieldName = fileItem.getFieldName(); msg += multiPartFileProcessor.processUploadedFile(uploadedResource, contentType, fieldName, uploadedFileName); } } } else { msg = "No file uploaded"; } return msg; } @Autowired  MultiPartFileParser(final MultiPartFileProcessor multiPartFileProcessor); String parseMultiPartFiles(final List<FileItem> fields); }
MultiPartFileParser { public String parseMultiPartFiles(final List<FileItem> fields) throws IOException { String msg = ""; Iterator<FileItem> it = fields.iterator(); if (!fields.isEmpty() && it.hasNext()) { while (it.hasNext()) { FileItem fileItem = it.next(); if (!fileItem.isFormField()) { String uploadedFileName = fileItem.getName(); InputStream uploadedResource = fileItem.getInputStream(); String contentType = fileItem.getContentType(); String fieldName = fileItem.getFieldName(); msg += multiPartFileProcessor.processUploadedFile(uploadedResource, contentType, fieldName, uploadedFileName); } } } else { msg = "No file uploaded"; } return msg; } @Autowired  MultiPartFileParser(final MultiPartFileProcessor multiPartFileProcessor); String parseMultiPartFiles(final List<FileItem> fields);  }