@Test public void test_update() throws IOException, Exception { List<VoucherSubType> voucherSubTypes = getVoucherSubTypes(); voucherSubTypes.get(0).setVoucherName("BankToBankk"); when(voucherSubTypeService.update(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(voucherSubTypes); mockMvc.perform(post("/vouchersubtype/_update") .content(resources.readRequest("vouchersubtype/vouchersubtype_update_valid_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content() .json(resources.readResponse("vouchersubtype/vouchersubtype_update_valid_response.json"))); }
@PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { voucherSubTypeRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); voucherSubTypeResponse.setResponseInfo(getResponseInfo(voucherSubTypeRequest.getRequestInfo())); VoucherSubType voucherSubType; VoucherSubTypeContract contract; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest.getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setLastModifiedBy(voucherSubTypeRequest.getRequestInfo().getUserInfo()); voucherSubType.setLastModifiedDate(new Date()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.update(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType voucherSubTypeObj : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(voucherSubTypeObj, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }
VoucherSubTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { voucherSubTypeRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); voucherSubTypeResponse.setResponseInfo(getResponseInfo(voucherSubTypeRequest.getRequestInfo())); VoucherSubType voucherSubType; VoucherSubTypeContract contract; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest.getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setLastModifiedBy(voucherSubTypeRequest.getRequestInfo().getUserInfo()); voucherSubType.setLastModifiedDate(new Date()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.update(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType voucherSubTypeObj : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(voucherSubTypeObj, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; } }
VoucherSubTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { voucherSubTypeRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); voucherSubTypeResponse.setResponseInfo(getResponseInfo(voucherSubTypeRequest.getRequestInfo())); VoucherSubType voucherSubType; VoucherSubTypeContract contract; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest.getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setLastModifiedBy(voucherSubTypeRequest.getRequestInfo().getUserInfo()); voucherSubType.setLastModifiedDate(new Date()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.update(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType voucherSubTypeObj : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(voucherSubTypeObj, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }  }
VoucherSubTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { voucherSubTypeRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); voucherSubTypeResponse.setResponseInfo(getResponseInfo(voucherSubTypeRequest.getRequestInfo())); VoucherSubType voucherSubType; VoucherSubTypeContract contract; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest.getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setLastModifiedBy(voucherSubTypeRequest.getRequestInfo().getUserInfo()); voucherSubType.setLastModifiedDate(new Date()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.update(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType voucherSubTypeObj : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(voucherSubTypeObj, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse create(
            @RequestBody VoucherSubTypeRequest voucherSubTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract,
            RequestInfo requestInfo,
            BindingResult errors); }
VoucherSubTypeController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors) { voucherSubTypeRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); VoucherSubTypeResponse voucherSubTypeResponse = new VoucherSubTypeResponse(); List<VoucherSubType> voucherSubTypes = new ArrayList<>(); voucherSubTypeResponse.setResponseInfo(getResponseInfo(voucherSubTypeRequest.getRequestInfo())); VoucherSubType voucherSubType; VoucherSubTypeContract contract; List<VoucherSubTypeContract> voucherSubTypeContracts = new ArrayList<>(); for (VoucherSubTypeContract voucherSubTypeContract : voucherSubTypeRequest.getVoucherSubTypes()) { voucherSubType = new VoucherSubType(); model.map(voucherSubTypeContract, voucherSubType); voucherSubType.setLastModifiedBy(voucherSubTypeRequest.getRequestInfo().getUserInfo()); voucherSubType.setLastModifiedDate(new Date()); voucherSubTypes.add(voucherSubType); } voucherSubTypes = voucherSubTypeService.update(voucherSubTypes, errors, voucherSubTypeRequest.getRequestInfo()); for (VoucherSubType voucherSubTypeObj : voucherSubTypes) { contract = new VoucherSubTypeContract(); model.map(voucherSubTypeObj, contract); voucherSubTypeContracts.add(contract); } voucherSubTypeResponse.setVoucherSubTypes(voucherSubTypeContracts); return voucherSubTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse create(
            @RequestBody VoucherSubTypeRequest voucherSubTypeRequest,
            BindingResult errors); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) VoucherSubTypeResponse update(@RequestBody VoucherSubTypeRequest voucherSubTypeRequest, BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) VoucherSubTypeResponse search(@ModelAttribute VoucherSubTypeSearchContract voucherSubTypeSearchContract,
            RequestInfo requestInfo,
            BindingResult errors);  }