@Test public void testViewDiseaseTrait() throws Exception { when(diseaseTraitRepository.findOne(Matchers.anyLong())).thenReturn(DISEASE_TRAIT_1); mockMvc.perform(get("/diseasetraits/799").accept(MediaType.TEXT_HTML_VALUE)) .andExpect(status().isOk()) .andExpect(view().name("edit_disease_trait")) .andExpect(model().attributeExists("diseaseTrait")) .andExpect(model().attribute("diseaseTrait", instanceOf(DiseaseTrait.class))) .andExpect(model().attribute("diseaseTrait", hasProperty("trait", is("Asthma")))); verifyZeroInteractions(studyRepository); }
@RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public String viewDiseaseTrait(Model model, @PathVariable Long diseaseTraitId) { DiseaseTrait diseaseTraitToView = diseaseTraitRepository.findOne(diseaseTraitId); model.addAttribute("diseaseTrait", diseaseTraitToView); return "edit_disease_trait"; }
DiseaseTraitController { @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public String viewDiseaseTrait(Model model, @PathVariable Long diseaseTraitId) { DiseaseTrait diseaseTraitToView = diseaseTraitRepository.findOne(diseaseTraitId); model.addAttribute("diseaseTrait", diseaseTraitToView); return "edit_disease_trait"; } }
DiseaseTraitController { @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public String viewDiseaseTrait(Model model, @PathVariable Long diseaseTraitId) { DiseaseTrait diseaseTraitToView = diseaseTraitRepository.findOne(diseaseTraitId); model.addAttribute("diseaseTrait", diseaseTraitToView); return "edit_disease_trait"; } @Autowired  DiseaseTraitController(DiseaseTraitRepository diseaseTraitRepository, StudyRepository studyRepository); }
DiseaseTraitController { @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public String viewDiseaseTrait(Model model, @PathVariable Long diseaseTraitId) { DiseaseTrait diseaseTraitToView = diseaseTraitRepository.findOne(diseaseTraitId); model.addAttribute("diseaseTrait", diseaseTraitToView); return "edit_disease_trait"; } @Autowired  DiseaseTraitController(DiseaseTraitRepository diseaseTraitRepository, StudyRepository studyRepository); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String allDiseaseTraits(Model model); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String addDiseaseTrait(@Valid @ModelAttribute DiseaseTrait diseaseTrait,
                                  BindingResult bindingResult,
                                  Model model, RedirectAttributes redirectAttributes); @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewDiseaseTrait(Model model, @PathVariable Long diseaseTraitId); @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String editDiseaseTrait(@Valid @ModelAttribute DiseaseTrait diseaseTrait,
                                   BindingResult bindingResult, @PathVariable Long diseaseTraitId); @RequestMapping(value = "/{diseaseTraitId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewDiseaseTraitToDelete(Model model, @PathVariable Long diseaseTraitId); @RequestMapping(value = "/{diseaseTraitId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String deleteDiseaseTrait(@PathVariable Long diseaseTraitId, RedirectAttributes redirectAttributes); @ModelAttribute("diseaseTraits") List<DiseaseTrait> populateDiseaseTraits(); }
DiseaseTraitController { @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) public String viewDiseaseTrait(Model model, @PathVariable Long diseaseTraitId) { DiseaseTrait diseaseTraitToView = diseaseTraitRepository.findOne(diseaseTraitId); model.addAttribute("diseaseTrait", diseaseTraitToView); return "edit_disease_trait"; } @Autowired  DiseaseTraitController(DiseaseTraitRepository diseaseTraitRepository, StudyRepository studyRepository); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String allDiseaseTraits(Model model); @RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String addDiseaseTrait(@Valid @ModelAttribute DiseaseTrait diseaseTrait,
                                  BindingResult bindingResult,
                                  Model model, RedirectAttributes redirectAttributes); @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewDiseaseTrait(Model model, @PathVariable Long diseaseTraitId); @RequestMapping(value = "/{diseaseTraitId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String editDiseaseTrait(@Valid @ModelAttribute DiseaseTrait diseaseTrait,
                                   BindingResult bindingResult, @PathVariable Long diseaseTraitId); @RequestMapping(value = "/{diseaseTraitId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET) String viewDiseaseTraitToDelete(Model model, @PathVariable Long diseaseTraitId); @RequestMapping(value = "/{diseaseTraitId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST) String deleteDiseaseTrait(@PathVariable Long diseaseTraitId, RedirectAttributes redirectAttributes); @ModelAttribute("diseaseTraits") List<DiseaseTrait> populateDiseaseTraits();  }