RaxaDrugController extends BaseRestController { @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New Drug") @ResponseBody public Object createNewDrug(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response) throws ResponseException { initDrugController(); String conceptUuid = post.get("concept").toString(); Concept concept = service.getConceptByUuid(conceptUuid); if (concept == null) { throw new ObjectNotFoundException(); } Drug drug = new Drug(); drug.setConcept(concept); updateDrugFieldsFromPostData(drug, post); Drug drugJustCreated = service.saveDrug(drug); if (post.get("drugInfo") != null) { this.createNewDrugInfo(drugJustCreated, (LinkedHashMap) post.get("drugInfo")); } return RestUtil.created(response, getDrugAsSimpleObject(drugJustCreated)); }  void initDrugController(); @RequestMapping(method = RequestMethod.POST) @WSDoc("Save New Drug") @ResponseBody Object createNewDrug(@RequestBody SimpleObject post, HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.POST) @WSDoc("Updates an existing drug") @ResponseBody Object updateDrug(@PathVariable("uuid") String uuid, @RequestBody SimpleObject post, HttpServletRequest request,
	        HttpServletResponse response); @RequestMapping(method = RequestMethod.GET) @WSDoc("Get All Unretired Drug in the system") @ResponseBody() String getAllDrugs(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET) @WSDoc("Gets Drug for the uuid path") @ResponseBody() String getDrugByUuid(@PathVariable("uuid") String uuid, HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.GET, params = "v") @WSDoc("Gets Full representation of Drug for the uuid path") @ResponseBody() String getDrugByUuidFull(@PathVariable("uuid") String uuid, @RequestParam("v") String rep,
	        HttpServletRequest request); @RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE, params = "!purge") @WSDoc("Retires the Drug") @ResponseBody Object retireDrug(@PathVariable("uuid") String uuid,
	        @RequestParam(value = "reason", defaultValue = "web service call") String reason, HttpServletRequest request,
	        HttpServletResponse response);  }
@Test public void createNewDrug_shouldCreateNewDrugInfo() throws Exception { String json = "{\"concept\":\"0cbe2ed3-cd5f-4f46-9459-26127c9265ab\",\"name\":\"New Drug name\",\"dosageForm\":\"0cbe2ed3-cd5f-4f46-9459-26127c9265ab\",\"minimumDailyDose\":\"10\",\"maximumDailyDose\":\"100\",\"units\":\"mg\", \"drugInfo\":{ \"name\":\"Inner DrugInfo\",\"description\":\"Test Drug Group\", \"drug\":\"3cfcf118-931c-46f7-8ff6-7b876f0d4202\"} }"; SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class); Object drug = controller.createNewDrug(post, request, response); List<DrugInfo> drugInfos = Context.getService(DrugInfoService.class).getAllDrugInfo(true); Boolean foundNewDrugInfo = false; for (int i = 0; i < drugInfos.size(); i++) { DrugInfo di = drugInfos.get(i); if (di.getName().equals("Inner DrugInfo")) { foundNewDrugInfo = true; } } Assert.assertEquals(true, foundNewDrugInfo); }