### Question:
RadiologyModalityFormController { @RequestMapping(method = RequestMethod.GET) protected ModelAndView getRadiologyModality() { final ModelAndView modelAndView = new ModelAndView(RADIOLOGY_MODALITY_FORM_VIEW); modelAndView.addObject(new RadiologyModality()); return modelAndView; }   static final String RADIOLOGY_MODALITY_FORM_REQUEST_MAPPING; }### Answer:
@Test public void shouldPopulateModelAndViewWithNewRadiologyModality() throws Exception { ModelAndView modelAndView = radiologyModalityFormController.getRadiologyModality(); assertNotNull(modelAndView); assertThat(modelAndView.getViewName(), is(RadiologyModalityFormController.RADIOLOGY_MODALITY_FORM_VIEW)); assertThat(modelAndView.getModelMap(), hasKey("radiologyModality")); RadiologyModality modality = (RadiologyModality) modelAndView.getModelMap() .get("radiologyModality"); assertNull(modality.getModalityId()); }
@Test public void shouldPopulateModelAndViewWithGivenRadiologyModality() throws Exception { ModelAndView modelAndView = radiologyModalityFormController.getRadiologyModality(radiologyModality); assertNotNull(modelAndView); assertThat(modelAndView.getViewName(), is(RadiologyModalityFormController.RADIOLOGY_MODALITY_FORM_VIEW)); assertThat(modelAndView.getModelMap(), hasKey("radiologyModality")); RadiologyModality modality = (RadiologyModality) modelAndView.getModelMap() .get("radiologyModality"); assertThat(modality, is(radiologyModality)); }