DrugInventoryController extends BaseRestController { @RequestMapping(method = RequestMethod.POST) @WSDoc("Save DrugInventory") @ResponseBody public Object saveDrugInventory(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response) throws ResponseException { initDrugInventoryController(); DrugInventory drugInventory = setPostFields(post, new DrugInventory()); DrugInventory created; SimpleObject obj = obj = new SimpleObject(); created = service.saveDrugInventory(drugInventory); obj.add("uuid", created.getUuid()); obj.add("drugId", created.getDrugId()); obj.add("quantity", created.getQuantity()); return RestUtil.created(response, obj); }  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 testSaveDrugInventory() throws Exception { int before = service.getAllDrugInventories().size(); String json = "{ \"name\":\"Test Drug Inventory\",\"description\":\"Test drug inventory\", \"drugId\": 2, \"quantity\": 500 }"; SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class); controller.saveDrugInventory(post, request, response); int after = service.getAllDrugInventories().size(); Assert.assertEquals(before + 1, after); }