@Test public void testHandleFileRemovalNotFound() { fileUploadManager.handleFileRemoval("123"); verify(facesContext, times(1)).addMessage(any(String.class), any(FacesMessage.class)); }
public void handleFileRemoval(String id) { try { UploadFile uploadedFile = findUploadedFile(id); uploadedFiles.remove(uploadedFile); currentFileLimit++; LOGGER.debug("removed: {}", uploadedFile); FacesMessage message = new FacesMessage( FacesMessage.SEVERITY_INFO, "File removed", uploadedFile.getName() + " is successfuly removed"); FacesContext.getCurrentInstance().addMessage(null, message); } catch (Exception exception) { LOGGER.error("unable to remove file with id: {}", id, exception); FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Removal failed", "File with id:" + id + " not found")); } }
FileUploadManager implements Serializable { public void handleFileRemoval(String id) { try { UploadFile uploadedFile = findUploadedFile(id); uploadedFiles.remove(uploadedFile); currentFileLimit++; LOGGER.debug("removed: {}", uploadedFile); FacesMessage message = new FacesMessage( FacesMessage.SEVERITY_INFO, "File removed", uploadedFile.getName() + " is successfuly removed"); FacesContext.getCurrentInstance().addMessage(null, message); } catch (Exception exception) { LOGGER.error("unable to remove file with id: {}", id, exception); FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Removal failed", "File with id:" + id + " not found")); } } }
FileUploadManager implements Serializable { public void handleFileRemoval(String id) { try { UploadFile uploadedFile = findUploadedFile(id); uploadedFiles.remove(uploadedFile); currentFileLimit++; LOGGER.debug("removed: {}", uploadedFile); FacesMessage message = new FacesMessage( FacesMessage.SEVERITY_INFO, "File removed", uploadedFile.getName() + " is successfuly removed"); FacesContext.getCurrentInstance().addMessage(null, message); } catch (Exception exception) { LOGGER.error("unable to remove file with id: {}", id, exception); FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Removal failed", "File with id:" + id + " not found")); } }  }
FileUploadManager implements Serializable { public void handleFileRemoval(String id) { try { UploadFile uploadedFile = findUploadedFile(id); uploadedFiles.remove(uploadedFile); currentFileLimit++; LOGGER.debug("removed: {}", uploadedFile); FacesMessage message = new FacesMessage( FacesMessage.SEVERITY_INFO, "File removed", uploadedFile.getName() + " is successfuly removed"); FacesContext.getCurrentInstance().addMessage(null, message); } catch (Exception exception) { LOGGER.error("unable to remove file with id: {}", id, exception); FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Removal failed", "File with id:" + id + " not found")); } }  @PostConstruct void init(); List<UploadFile> getUploadedFiles(); String getUploadId(); void handleFileUpload(FileUploadEvent event); void handleFileRemoval(String id); String handleFileSubmit(); String getCurrentFileLimit(); StreamedContent getImage(); }
FileUploadManager implements Serializable { public void handleFileRemoval(String id) { try { UploadFile uploadedFile = findUploadedFile(id); uploadedFiles.remove(uploadedFile); currentFileLimit++; LOGGER.debug("removed: {}", uploadedFile); FacesMessage message = new FacesMessage( FacesMessage.SEVERITY_INFO, "File removed", uploadedFile.getName() + " is successfuly removed"); FacesContext.getCurrentInstance().addMessage(null, message); } catch (Exception exception) { LOGGER.error("unable to remove file with id: {}", id, exception); FacesContext.getCurrentInstance().addMessage( null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Removal failed", "File with id:" + id + " not found")); } }  @PostConstruct void init(); List<UploadFile> getUploadedFiles(); String getUploadId(); void handleFileUpload(FileUploadEvent event); void handleFileRemoval(String id); String handleFileSubmit(); String getCurrentFileLimit(); StreamedContent getImage(); static final int FILE_LIMIT; }