DrugInventoryController extends BaseRestController { @RequestMapping(method = RequestMethod.GET, params = "location") @WSDoc("Fetch all non-retired inventories according to location") @ResponseBody() public String searchByLocation(@RequestParam("location") String location, HttpServletRequest request) throws ResponseException { initDrugInventoryController(); List<DrugInventory> dIs = service.getDrugInventoriesByLocation(Context.getLocationService().getLocationByUuid( location).getId()); return inventoryListToJson(dIs); }  void initDrugInventoryController(); @RequestMapping(method = RequestMethod.POST) @WSDoc("Save DrugInventory") @ResponseBody Object saveDrugInventory(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response); DrugInventory setPostFields(SimpleObject post, DrugInventory drugInventory); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET) @WSDoc("Gets drug inventory for the uuid path") @ResponseBody() String getDrugInventoryByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.POST) @WSDoc("Updates an existing drug inventory") @ResponseBody Object updateDrugInventory(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post,
	        HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) @WSDoc("Get All Unretired Drug Inventories in the system") @ResponseBody() String getAllDrugInventories(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET, params = "location") @WSDoc("Fetch all non-retired inventories according to location") @ResponseBody() String searchByLocation(@RequestParam("location") String location, HttpServletRequest request);  }
@Test public void searchByLocation_shouldGetInventoriesByLocation() throws Exception { String results = controller.searchByLocation("dc5c1fcc-0459-4201-bf70-0b90535ba362", request); LinkedHashMap di = (LinkedHashMap) ((ArrayList) SimpleObject.parseJson(results).get("results")).get(0); Assert.assertEquals("Test drug inventory", di.get("name")); }