DrugGroupController extends BaseRestController { @RequestMapping(value = "/{uuid}", method = RequestMethod.GET, params = "v") @WSDoc("Gets Full representation of Drug Groups for the uuid path") @ResponseBody() public String getAllDrugGroupByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep, HttpServletRequest request) throws ResponseException { initDrugGroupController(); DrugGroup drugGroup = service.getDrugGroupByUuid(uuid); SimpleObject obj = new SimpleObject(); obj.add("uuid", drugGroup.getUuid()); obj.add("name", drugGroup.getName()); obj.add("description", drugGroup.getDescription()); ArrayList drugs = new ArrayList(); List<Drug> drugsInDrugGroup = new ArrayList<Drug>(drugGroup.getDrugs()); for (Drug p : drugsInDrugGroup) { SimpleObject drug = new SimpleObject(); drug.add("uuid", p.getUuid()); drugs.add(drug); } obj.add("drugs", drugs); if (rep.equals("full")) { obj.add("retired", drugGroup.getRetired()); if (drugGroup.getRetired()) { obj.add("retiredBy", drugGroup.getRetiredBy().getUuid()); obj.add("retireReason", drugGroup.getRetireReason()); } SimpleObject auditInfo = new SimpleObject(); auditInfo.add("creator", drugGroup.getCreator().getUuid()); auditInfo.add("dateCreated", df.format(drugGroup.getDateCreated())); if (drugGroup.getChangedBy() != null) { auditInfo.add("changedBy", drugGroup.getChangedBy().getUuid()); auditInfo.add("dateChanged", df.format(drugGroup.getDateChanged())); } obj.add("auditInfo", auditInfo); } obj.add("resourceVersion", getResourceVersion()); return gson.toJson(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);  }
@Test public void getDrugGroupByUuidFull_shouldGetAFullRepresentationOfADrugGroup() throws Exception { String result = controller.getAllDrugGroupByUuidFull(getUuid(), "full", request); SimpleObject drugGroup = SimpleObject.parseJson(result); Assert.assertNotNull(result); Util.log("DrugGroup fetched (full)", result); Assert.assertEquals("68547121-1b70-465d-99ee-c9dfd95e7d30", drugGroup.get("uuid")); Assert.assertEquals("TestDrugGroup1", drugGroup.get("name")); Assert.assertNotNull(drugGroup.get("auditInfo")); }