@Test public void viewPrintableDetailsOfStudy() throws Exception { SnpAssociationTableView snpAssociationTableView1 = new SnpAssociationTableView(); snpAssociationTableView1.setBetaNum((float) 0.012); SnpAssociationTableView snpAssociationTableView2 = new SnpAssociationTableView(); snpAssociationTableView1.setOrPerCopyNum((float) 5.97); when(studyRepository.findOne(STUDY.getId())).thenReturn(STUDY); Collection<Ancestry> initialStudyAncestryDescriptions = new ArrayList<>(); Collection<Ancestry> replicationStudyAncestryDescriptions = new ArrayList<>(); initialStudyAncestryDescriptions.add(ETH1); replicationStudyAncestryDescriptions.add(ETH2); replicationStudyAncestryDescriptions.add(ETH3); when(ancestryRepository.findByStudyIdAndType(STUDY.getId(), "initial")).thenReturn( initialStudyAncestryDescriptions); when(ancestryRepository.findByStudyIdAndType(STUDY.getId(), "replication")).thenReturn( replicationStudyAncestryDescriptions); when(studyPrintService.generatePrintView(STUDY.getId())).thenReturn(Arrays.asList(snpAssociationTableView1, snpAssociationTableView2)); MvcResult mvcResult = this.mockMvc.perform(get("/studies/101/printview").accept(MediaType.TEXT_HTML_VALUE)) .andExpect(request().asyncStarted()) .andExpect(request().asyncResult("study_printview")) .andReturn(); this.mockMvc.perform(asyncDispatch(mvcResult)) .andExpect(status().isOk()) .andExpect(forwardedUrl("study_printview")) .andExpect(model().attributeExists("studiesToPrint")) .andExpect(model().attribute("studiesToPrint", instanceOf(Hashtable.class))); }
@RequestMapping(value = "/studies/{studyId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public Callable<String> viewPrintableDetailsOfStudy(Model model, @PathVariable Long studyId) { return () -> { Hashtable<String, ArrayList<Object>> listStudies = new Hashtable<String, ArrayList<Object>>(); Study studyToPrint = studyRepository.findOne(studyId); ArrayList<Object> infoToPrint = getStudyInfoToPrint(studyToPrint); listStudies.put(studyToPrint.getId().toString(), infoToPrint); model.addAttribute("studiesToPrint", listStudies); return "study_printview"; }; }
PrintController { @RequestMapping(value = "/studies/{studyId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public Callable<String> viewPrintableDetailsOfStudy(Model model, @PathVariable Long studyId) { return () -> { Hashtable<String, ArrayList<Object>> listStudies = new Hashtable<String, ArrayList<Object>>(); Study studyToPrint = studyRepository.findOne(studyId); ArrayList<Object> infoToPrint = getStudyInfoToPrint(studyToPrint); listStudies.put(studyToPrint.getId().toString(), infoToPrint); model.addAttribute("studiesToPrint", listStudies); return "study_printview"; }; } }
PrintController { @RequestMapping(value = "/studies/{studyId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public Callable<String> viewPrintableDetailsOfStudy(Model model, @PathVariable Long studyId) { return () -> { Hashtable<String, ArrayList<Object>> listStudies = new Hashtable<String, ArrayList<Object>>(); Study studyToPrint = studyRepository.findOne(studyId); ArrayList<Object> infoToPrint = getStudyInfoToPrint(studyToPrint); listStudies.put(studyToPrint.getId().toString(), infoToPrint); model.addAttribute("studiesToPrint", listStudies); return "study_printview"; }; } @Autowired  PrintController(StudyRepository studyRepository,
                           AncestryRepository ancestryRepository,
                           StudyPrintService studyPrintService,
                           PublicationService publicationService); }
PrintController { @RequestMapping(value = "/studies/{studyId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public Callable<String> viewPrintableDetailsOfStudy(Model model, @PathVariable Long studyId) { return () -> { Hashtable<String, ArrayList<Object>> listStudies = new Hashtable<String, ArrayList<Object>>(); Study studyToPrint = studyRepository.findOne(studyId); ArrayList<Object> infoToPrint = getStudyInfoToPrint(studyToPrint); listStudies.put(studyToPrint.getId().toString(), infoToPrint); model.addAttribute("studiesToPrint", listStudies); return "study_printview"; }; } @Autowired  PrintController(StudyRepository studyRepository,
                           AncestryRepository ancestryRepository,
                           StudyPrintService studyPrintService,
                           PublicationService publicationService); @RequestMapping(value = "/studies/{studyId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) Callable<String> viewPrintableDetailsOfStudy(Model model, @PathVariable Long studyId); @RequestMapping(value = "/pubmed/{pubmedId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) Callable<String> viewPrintableDetailsOfPubmed(Model model, @PathVariable String pubmedId); }
PrintController { @RequestMapping(value = "/studies/{studyId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public Callable<String> viewPrintableDetailsOfStudy(Model model, @PathVariable Long studyId) { return () -> { Hashtable<String, ArrayList<Object>> listStudies = new Hashtable<String, ArrayList<Object>>(); Study studyToPrint = studyRepository.findOne(studyId); ArrayList<Object> infoToPrint = getStudyInfoToPrint(studyToPrint); listStudies.put(studyToPrint.getId().toString(), infoToPrint); model.addAttribute("studiesToPrint", listStudies); return "study_printview"; }; } @Autowired  PrintController(StudyRepository studyRepository,
                           AncestryRepository ancestryRepository,
                           StudyPrintService studyPrintService,
                           PublicationService publicationService); @RequestMapping(value = "/studies/{studyId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) Callable<String> viewPrintableDetailsOfStudy(Model model, @PathVariable Long studyId); @RequestMapping(value = "/pubmed/{pubmedId}/printview", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) Callable<String> viewPrintableDetailsOfPubmed(Model model, @PathVariable String pubmedId);  }