@Test public void testGetRegions() throws Exception { ContextService contextService = createMock(ContextService.class); MotechService motechService = createMock(MotechService.class); JSONLocationSerializer JSONLocationSerializer = new JSONLocationSerializer(); JSONLocationSerializer.setContextService(contextService); demoPatientController.setContextService(contextService); demoPatientController.setJSONLocationSerializer(JSONLocationSerializer); expect(contextService.getMotechService()).andReturn(motechService); expect(motechService.getAllRegions()).andReturn(Collections.<String>emptyList()).once(); replay(contextService, motechService); demoPatientController.getRegions(); verify(contextService, motechService); }
@ModelAttribute("regions") public List<String> getRegions() { return JSONLocationSerializer.getAllRegions(); }
DemoPatientController extends BasePatientController { @ModelAttribute("regions") public List<String> getRegions() { return JSONLocationSerializer.getAllRegions(); } }
DemoPatientController extends BasePatientController { @ModelAttribute("regions") public List<String> getRegions() { return JSONLocationSerializer.getAllRegions(); }  }
DemoPatientController extends BasePatientController { @ModelAttribute("regions") public List<String> getRegions() { return JSONLocationSerializer.getAllRegions(); }  @Autowired void setContextService(ContextService contextService); void setRegistrarBean(RegistrarBean registrarBean); void setWebModelConverter(WebModelConverter webModelConverter); @InitBinder void initBinder(WebDataBinder binder); @ModelAttribute("regions") List<String> getRegions(); @ModelAttribute("districts") List<String> getDistricts(); @ModelAttribute("communities") List<Community> getCommunities(); @RequestMapping(method = RequestMethod.GET) void viewForm(@RequestParam(required = false) Integer id,ModelMap model); @ModelAttribute("patient") WebPatient getWebPatient(@RequestParam(required = false) Integer id); @RequestMapping(method = RequestMethod.POST) String submitForm(@ModelAttribute("patient") WebPatient patient,
			Errors errors, ModelMap model, SessionStatus status,
			HttpSession session); }
DemoPatientController extends BasePatientController { @ModelAttribute("regions") public List<String> getRegions() { return JSONLocationSerializer.getAllRegions(); }  @Autowired void setContextService(ContextService contextService); void setRegistrarBean(RegistrarBean registrarBean); void setWebModelConverter(WebModelConverter webModelConverter); @InitBinder void initBinder(WebDataBinder binder); @ModelAttribute("regions") List<String> getRegions(); @ModelAttribute("districts") List<String> getDistricts(); @ModelAttribute("communities") List<Community> getCommunities(); @RequestMapping(method = RequestMethod.GET) void viewForm(@RequestParam(required = false) Integer id,ModelMap model); @ModelAttribute("patient") WebPatient getWebPatient(@RequestParam(required = false) Integer id); @RequestMapping(method = RequestMethod.POST) String submitForm(@ModelAttribute("patient") WebPatient patient,
			Errors errors, ModelMap model, SessionStatus status,
			HttpSession session);  }