@Test public void createNewDrugGroup_shouldSaveANewDrugGroup() throws Exception { int before = service.getAllDrugGroup(false).size(); String json = "{ \"name\":\"Test DrugGroup\",\"description\":\"Test Drug Group\"}"; SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class); Object drugGroup = controller.createNewDrugGroup(post, request, response); Util.log("Created Patient List", drugGroup); Assert.assertEquals(before + 1, service.getAllDrugGroup(false).size()); }
@RequestMapping(method = RequestMethod.POST) @WSDoc("Save New DrugGroup") @ResponseBody public Object createNewDrugGroup(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response) throws ResponseException { initDrugGroupController(); DrugGroup drugGroup = new DrugGroup(); drugGroup.setName(post.get("name").toString()); drugGroup.setDescription(post.get("description").toString()); DrugGroup created = service.saveDrugGroup(drugGroup); SimpleObject obj = new SimpleObject(); obj.add("uuid", created.getUuid()); obj.add("name", created.getName()); obj.add("description", created.getDescription()); return RestUtil.created(response, obj); }
DrugGroupController extends BaseRestController { @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New DrugGroup") @ResponseBody public Object createNewDrugGroup(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response) throws ResponseException { initDrugGroupController(); DrugGroup drugGroup = new DrugGroup(); drugGroup.setName(post.get("name").toString()); drugGroup.setDescription(post.get("description").toString()); DrugGroup created = service.saveDrugGroup(drugGroup); SimpleObject obj = new SimpleObject(); obj.add("uuid", created.getUuid()); obj.add("name", created.getName()); obj.add("description", created.getDescription()); return RestUtil.created(response, obj); } }
DrugGroupController extends BaseRestController { @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New DrugGroup") @ResponseBody public Object createNewDrugGroup(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response) throws ResponseException { initDrugGroupController(); DrugGroup drugGroup = new DrugGroup(); drugGroup.setName(post.get("name").toString()); drugGroup.setDescription(post.get("description").toString()); DrugGroup created = service.saveDrugGroup(drugGroup); SimpleObject obj = new SimpleObject(); obj.add("uuid", created.getUuid()); obj.add("name", created.getName()); obj.add("description", created.getDescription()); return RestUtil.created(response, obj); }  }
DrugGroupController extends BaseRestController { @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New DrugGroup") @ResponseBody public Object createNewDrugGroup(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response) throws ResponseException { initDrugGroupController(); DrugGroup drugGroup = new DrugGroup(); drugGroup.setName(post.get("name").toString()); drugGroup.setDescription(post.get("description").toString()); DrugGroup created = service.saveDrugGroup(drugGroup); SimpleObject obj = new SimpleObject(); obj.add("uuid", created.getUuid()); obj.add("name", created.getName()); obj.add("description", created.getDescription()); return RestUtil.created(response, obj); }  void initDrugGroupController(); @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New DrugGroup") @ResponseBody Object createNewDrugGroup(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.POST) @WSDoc("Updates an existing drug group") @ResponseBody Object updateDrugGroup(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post,
	        HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) @WSDoc("Get All Unretired Drug Groups in the system") @ResponseBody() String getAllDrugGroups(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET, params = "q") @WSDoc("Gets Drug Groups by name") @ResponseBody() String getDrugGroupsByName(@RequestParam("q") String query, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET) @WSDoc("Gets Drug Groups for the uuid path") @ResponseBody() String getAllDrugGroupByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET, params = "v") @WSDoc("Gets Full representation of Drug Groups for the uuid path") @ResponseBody() String getAllDrugGroupByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep,
	        HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "!purge") @WSDoc("Retires the Drug Group") @ResponseBody Object retireDrugGroup(@PathVariable("uuid") String uuid,
	        @RequestParam(value = "reason", defaultValue = "web service call") String reason, HttpServletRequest request,
	        HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "purge") @ResponseBody Object purgeDrugGroup(@PathVariable("uuid") String uuid, HttpServletRequest request, HttpServletResponse response); }
DrugGroupController extends BaseRestController { @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New DrugGroup") @ResponseBody public Object createNewDrugGroup(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response) throws ResponseException { initDrugGroupController(); DrugGroup drugGroup = new DrugGroup(); drugGroup.setName(post.get("name").toString()); drugGroup.setDescription(post.get("description").toString()); DrugGroup created = service.saveDrugGroup(drugGroup); SimpleObject obj = new SimpleObject(); obj.add("uuid", created.getUuid()); obj.add("name", created.getName()); obj.add("description", created.getDescription()); return RestUtil.created(response, obj); }  void initDrugGroupController(); @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New DrugGroup") @ResponseBody Object createNewDrugGroup(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.POST) @WSDoc("Updates an existing drug group") @ResponseBody Object updateDrugGroup(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post,
	        HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) @WSDoc("Get All Unretired Drug Groups in the system") @ResponseBody() String getAllDrugGroups(HttpServletRequest request, HttpServletResponse response); @RequestMapping(method = RequestMethod.GET, params = "q") @WSDoc("Gets Drug Groups by name") @ResponseBody() String getDrugGroupsByName(@RequestParam("q") String query, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET) @WSDoc("Gets Drug Groups for the uuid path") @ResponseBody() String getAllDrugGroupByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET, params = "v") @WSDoc("Gets Full representation of Drug Groups for the uuid path") @ResponseBody() String getAllDrugGroupByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep,
	        HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "!purge") @WSDoc("Retires the Drug Group") @ResponseBody Object retireDrugGroup(@PathVariable("uuid") String uuid,
	        @RequestParam(value = "reason", defaultValue = "web service call") String reason, HttpServletRequest request,
	        HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "purge") @ResponseBody Object purgeDrugGroup(@PathVariable("uuid") String uuid, HttpServletRequest request, HttpServletResponse response);  }