### Question:
DemoPatientController extends BasePatientController { @ModelAttribute("communities") public List<Community> getCommunities() { return JSONLocationSerializer.getAllCommunities(false); }  @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);  }### Answer:
@Test public void testGetCommunities() 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.getAllCommunities(false)).andReturn(Collections.<Community>emptyList()).once(); replay(contextService, motechService); demoPatientController.getCommunities(); verify(contextService, motechService); }