@Test public void testSecureClinicalDocumentsUploadWhenAllChecksSucced() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "orig", null, "bar".getBytes()); doReturn(true).when(xmlValidator).validate(any(InputStream.class)); doReturn("true").when(sut).scanMultipartFile(file); doReturn(false).when(clinicalDocumentService).isDocumentOversized(file); doReturn(true).when(clinicalDocumentService).isDocumentExtensionPermitted(file); doReturn(true).when(recaptchaUtil).checkAnswer(anyString(), anyString(), anyString()); mockMvc.perform(fileUpload("/patients/clinicaldocuments.html").file(file) .param("name", "mocked_name") .param("description", "mocked_description") .param("documentType", "mocked_type") .param("recaptcha_challenge_field", "recaptcha_challenge_field") .param("recaptcha_response_field", "recaptcha_response_field")) .andExpect(view().name("redirect:/patients/clinicaldocuments.html")); }
String scanMultipartFile(MultipartFile file){ Boolean isItClean=null; try (InputStream inputStream = file.getInputStream()){ isItClean = clamAVUtil.fileScanner(inputStream); } catch (ClamAVClientNotAvailableException e){ logger.error(e.getMessage()); return "error"; } catch (Exception e) { logger.error(e.getMessage()); return "error"; } return isItClean.toString(); }
ClinicalDocumentController implements InitializingBean { String scanMultipartFile(MultipartFile file){ Boolean isItClean=null; try (InputStream inputStream = file.getInputStream()){ isItClean = clamAVUtil.fileScanner(inputStream); } catch (ClamAVClientNotAvailableException e){ logger.error(e.getMessage()); return "error"; } catch (Exception e) { logger.error(e.getMessage()); return "error"; } return isItClean.toString(); } }
ClinicalDocumentController implements InitializingBean { String scanMultipartFile(MultipartFile file){ Boolean isItClean=null; try (InputStream inputStream = file.getInputStream()){ isItClean = clamAVUtil.fileScanner(inputStream); } catch (ClamAVClientNotAvailableException e){ logger.error(e.getMessage()); return "error"; } catch (Exception e) { logger.error(e.getMessage()); return "error"; } return isItClean.toString(); } ClinicalDocumentController(
			ClinicalDocumentService clinicalDocumentService,
			PatientService patientService,
			ClinicalDocumentTypeCodeService clinicalDocumentTypeCodeService,
			UserContext userContext,
			AccessReferenceMapper accessReferenceMapper,
			ClamAVService clamAVUtil, RecaptchaService recaptchaUtil,
			EventService eventService, XmlValidation xmlValidator); @SuppressWarnings("unused") private  ClinicalDocumentController(); }
ClinicalDocumentController implements InitializingBean { String scanMultipartFile(MultipartFile file){ Boolean isItClean=null; try (InputStream inputStream = file.getInputStream()){ isItClean = clamAVUtil.fileScanner(inputStream); } catch (ClamAVClientNotAvailableException e){ logger.error(e.getMessage()); return "error"; } catch (Exception e) { logger.error(e.getMessage()); return "error"; } return isItClean.toString(); } ClinicalDocumentController(
			ClinicalDocumentService clinicalDocumentService,
			PatientService patientService,
			ClinicalDocumentTypeCodeService clinicalDocumentTypeCodeService,
			UserContext userContext,
			AccessReferenceMapper accessReferenceMapper,
			ClamAVService clamAVUtil, RecaptchaService recaptchaUtil,
			EventService eventService, XmlValidation xmlValidator); @SuppressWarnings("unused") private  ClinicalDocumentController(); @RequestMapping("/medicalinfo.html") String documentHome(Model model); @RequestMapping("/clinicaldocuments.html") String showSecureClinicalDocuments(
			Model model,
			@RequestParam(value = "notify", required = false) String notification); @RequestMapping(value = "/clinicaldocuments.html", method = RequestMethod.POST) String uploadClinicalDocumentsSecurely(
			HttpServletRequest request,
			@ModelAttribute("document") ClinicalDocumentDto clinicalDocumentDto,
			@RequestParam("file") MultipartFile file,
			@RequestParam("name") String documentName,
			@RequestParam("description") String description,
			@RequestParam("documentType") String documentTypeCode); @RequestMapping(value = "/downloaddoc.html", method = RequestMethod.POST) String download(HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam("download_id") String documentId); @RequestMapping(value = "/deletedoc.html", method = RequestMethod.POST) String remove(@RequestParam("delete_id") String documentId); @Override void afterPropertiesSet(); }
ClinicalDocumentController implements InitializingBean { String scanMultipartFile(MultipartFile file){ Boolean isItClean=null; try (InputStream inputStream = file.getInputStream()){ isItClean = clamAVUtil.fileScanner(inputStream); } catch (ClamAVClientNotAvailableException e){ logger.error(e.getMessage()); return "error"; } catch (Exception e) { logger.error(e.getMessage()); return "error"; } return isItClean.toString(); } ClinicalDocumentController(
			ClinicalDocumentService clinicalDocumentService,
			PatientService patientService,
			ClinicalDocumentTypeCodeService clinicalDocumentTypeCodeService,
			UserContext userContext,
			AccessReferenceMapper accessReferenceMapper,
			ClamAVService clamAVUtil, RecaptchaService recaptchaUtil,
			EventService eventService, XmlValidation xmlValidator); @SuppressWarnings("unused") private  ClinicalDocumentController(); @RequestMapping("/medicalinfo.html") String documentHome(Model model); @RequestMapping("/clinicaldocuments.html") String showSecureClinicalDocuments(
			Model model,
			@RequestParam(value = "notify", required = false) String notification); @RequestMapping(value = "/clinicaldocuments.html", method = RequestMethod.POST) String uploadClinicalDocumentsSecurely(
			HttpServletRequest request,
			@ModelAttribute("document") ClinicalDocumentDto clinicalDocumentDto,
			@RequestParam("file") MultipartFile file,
			@RequestParam("name") String documentName,
			@RequestParam("description") String description,
			@RequestParam("documentType") String documentTypeCode); @RequestMapping(value = "/downloaddoc.html", method = RequestMethod.POST) String download(HttpServletRequest request,
			HttpServletResponse response,
			@RequestParam("download_id") String documentId); @RequestMapping(value = "/deletedoc.html", method = RequestMethod.POST) String remove(@RequestParam("delete_id") String documentId); @Override void afterPropertiesSet(); static final String C32_CDA_XSD_PATH; static final String C32_CDA_XSD_NAME; }