@Test public void shouldSave() throws Exception { EquipmentTypeProduct pep = new EquipmentTypeProduct(); doNothing().when(service).Save(pep); ResponseEntity<OpenLmisResponse> response = controller.save(pep, request); assertThat(response.getBody().getSuccessMsg(), is(notNullValue())); assertThat(pep, is(response.getBody().getData().get("programEquipmentProduct"))); }
@RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentTypeProduct equipmentTypeProduct, HttpServletRequest request){ Date date = new Date(); Long userId = loggedInUserId(request); ResponseEntity<OpenLmisResponse> successResponse; if(equipmentTypeProduct.getId() == null){ equipmentTypeProduct.setCreatedDate(date); equipmentTypeProduct.setCreatedBy(userId); } equipmentTypeProduct.setModifiedDate(date); equipmentTypeProduct.setModifiedBy(userId); try{ programEquipmentTypeProductService.Save(equipmentTypeProduct); } catch (DataException e){ return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } successResponse = OpenLmisResponse.success("message.equipment.association.pep.saved"); successResponse.getBody().addData(PROGRAM_EQUIPMENT_PRODUCT, equipmentTypeProduct); return successResponse; }
ProgramEquipmentTypeProductController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentTypeProduct equipmentTypeProduct, HttpServletRequest request){ Date date = new Date(); Long userId = loggedInUserId(request); ResponseEntity<OpenLmisResponse> successResponse; if(equipmentTypeProduct.getId() == null){ equipmentTypeProduct.setCreatedDate(date); equipmentTypeProduct.setCreatedBy(userId); } equipmentTypeProduct.setModifiedDate(date); equipmentTypeProduct.setModifiedBy(userId); try{ programEquipmentTypeProductService.Save(equipmentTypeProduct); } catch (DataException e){ return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } successResponse = OpenLmisResponse.success("message.equipment.association.pep.saved"); successResponse.getBody().addData(PROGRAM_EQUIPMENT_PRODUCT, equipmentTypeProduct); return successResponse; } }
ProgramEquipmentTypeProductController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentTypeProduct equipmentTypeProduct, HttpServletRequest request){ Date date = new Date(); Long userId = loggedInUserId(request); ResponseEntity<OpenLmisResponse> successResponse; if(equipmentTypeProduct.getId() == null){ equipmentTypeProduct.setCreatedDate(date); equipmentTypeProduct.setCreatedBy(userId); } equipmentTypeProduct.setModifiedDate(date); equipmentTypeProduct.setModifiedBy(userId); try{ programEquipmentTypeProductService.Save(equipmentTypeProduct); } catch (DataException e){ return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } successResponse = OpenLmisResponse.success("message.equipment.association.pep.saved"); successResponse.getBody().addData(PROGRAM_EQUIPMENT_PRODUCT, equipmentTypeProduct); return successResponse; }  }
ProgramEquipmentTypeProductController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentTypeProduct equipmentTypeProduct, HttpServletRequest request){ Date date = new Date(); Long userId = loggedInUserId(request); ResponseEntity<OpenLmisResponse> successResponse; if(equipmentTypeProduct.getId() == null){ equipmentTypeProduct.setCreatedDate(date); equipmentTypeProduct.setCreatedBy(userId); } equipmentTypeProduct.setModifiedDate(date); equipmentTypeProduct.setModifiedBy(userId); try{ programEquipmentTypeProductService.Save(equipmentTypeProduct); } catch (DataException e){ return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } successResponse = OpenLmisResponse.success("message.equipment.association.pep.saved"); successResponse.getBody().addData(PROGRAM_EQUIPMENT_PRODUCT, equipmentTypeProduct); return successResponse; }  @RequestMapping(value="getByProgramEquipment/{programEquipmentId}",headers = ACCEPT_JSON,method = RequestMethod.GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getByProgramEquipmentId(@PathVariable(value="programEquipmentId") Long programEquipmentId); @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentTypeProduct equipmentTypeProduct, HttpServletRequest request); @RequestMapping(value="remove/{programEquipmentId}") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> remove(@PathVariable(value = "programEquipmentId") Long programEquipmentId); @RequestMapping(value="possible-products",headers = ACCEPT_JSON,method = RequestMethod.GET) ResponseEntity<OpenLmisResponse> getProducts(@RequestParam("program") Long programId, @RequestParam(value = "equipment", defaultValue = "0") Long equipmentId ); }
ProgramEquipmentTypeProductController extends BaseController { @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") public ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentTypeProduct equipmentTypeProduct, HttpServletRequest request){ Date date = new Date(); Long userId = loggedInUserId(request); ResponseEntity<OpenLmisResponse> successResponse; if(equipmentTypeProduct.getId() == null){ equipmentTypeProduct.setCreatedDate(date); equipmentTypeProduct.setCreatedBy(userId); } equipmentTypeProduct.setModifiedDate(date); equipmentTypeProduct.setModifiedBy(userId); try{ programEquipmentTypeProductService.Save(equipmentTypeProduct); } catch (DataException e){ return OpenLmisResponse.error(e, HttpStatus.BAD_REQUEST); } successResponse = OpenLmisResponse.success("message.equipment.association.pep.saved"); successResponse.getBody().addData(PROGRAM_EQUIPMENT_PRODUCT, equipmentTypeProduct); return successResponse; }  @RequestMapping(value="getByProgramEquipment/{programEquipmentId}",headers = ACCEPT_JSON,method = RequestMethod.GET) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> getByProgramEquipmentId(@PathVariable(value="programEquipmentId") Long programEquipmentId); @RequestMapping(value = "save", method = RequestMethod.POST, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> save(@RequestBody EquipmentTypeProduct equipmentTypeProduct, HttpServletRequest request); @RequestMapping(value="remove/{programEquipmentId}") @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_EQUIPMENT_SETTINGS')") ResponseEntity<OpenLmisResponse> remove(@PathVariable(value = "programEquipmentId") Long programEquipmentId); @RequestMapping(value="possible-products",headers = ACCEPT_JSON,method = RequestMethod.GET) ResponseEntity<OpenLmisResponse> getProducts(@RequestParam("program") Long programId, @RequestParam(value = "equipment", defaultValue = "0") Long equipmentId ); static final String PROGRAM_EQUIPMENT_PRODUCT; static final String PRODUCTS; }