@Test public void testUpdate() throws IOException, Exception { when(bankBranchService.update(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn((getUpdatedBankBranches())); mockMvc.perform(post("/bankbranches/_update?tenantId=default") .content(resources.readRequest("bankbranch/bankbranch_update_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(resources.readResponse("bankbranch/bankbranch_update_response.json"))); verify(bankBranchService).update(captor.capture(), any(BindingResult.class), any(RequestInfo.class)); final List<BankBranch> actualRequest = captor.getValue(); assertEquals("1", actualRequest.get(0).getBank().getId()); assertEquals("default", actualRequest.get(0).getTenantId()); assertEquals(true, actualRequest.get(0).getActive()); }
@PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); BankBranchResponse bankBranchResponse = new BankBranchResponse(); List<BankBranch> bankbranches = new ArrayList<>(); bankBranchResponse.setResponseInfo(getResponseInfo(bankBranchRequest.getRequestInfo())); BankBranch bankBranch; BankBranchContract contract; List<BankBranchContract> bankBranchContracts = new ArrayList<>(); for (BankBranchContract bankBranchContract : bankBranchRequest.getBankBranches()) { bankBranch = new BankBranch(); model.map(bankBranchContract, bankBranch); bankBranch.setLastModifiedBy(bankBranchRequest.getRequestInfo().getUserInfo()); bankBranch.setLastModifiedDate(new Date()); bankbranches.add(bankBranch); } bankbranches = bankBranchService.update(bankbranches, errors, bankBranchRequest.getRequestInfo()); for (BankBranch bankBranchObj : bankbranches) { contract = new BankBranchContract(); model.map(bankBranchObj, contract); bankBranchObj.setLastModifiedDate(new Date()); bankBranchContracts.add(contract); } bankBranchResponse.setBankBranches(bankBranchContracts); return bankBranchResponse; }
BankBranchController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); BankBranchResponse bankBranchResponse = new BankBranchResponse(); List<BankBranch> bankbranches = new ArrayList<>(); bankBranchResponse.setResponseInfo(getResponseInfo(bankBranchRequest.getRequestInfo())); BankBranch bankBranch; BankBranchContract contract; List<BankBranchContract> bankBranchContracts = new ArrayList<>(); for (BankBranchContract bankBranchContract : bankBranchRequest.getBankBranches()) { bankBranch = new BankBranch(); model.map(bankBranchContract, bankBranch); bankBranch.setLastModifiedBy(bankBranchRequest.getRequestInfo().getUserInfo()); bankBranch.setLastModifiedDate(new Date()); bankbranches.add(bankBranch); } bankbranches = bankBranchService.update(bankbranches, errors, bankBranchRequest.getRequestInfo()); for (BankBranch bankBranchObj : bankbranches) { contract = new BankBranchContract(); model.map(bankBranchObj, contract); bankBranchObj.setLastModifiedDate(new Date()); bankBranchContracts.add(contract); } bankBranchResponse.setBankBranches(bankBranchContracts); return bankBranchResponse; } }
BankBranchController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); BankBranchResponse bankBranchResponse = new BankBranchResponse(); List<BankBranch> bankbranches = new ArrayList<>(); bankBranchResponse.setResponseInfo(getResponseInfo(bankBranchRequest.getRequestInfo())); BankBranch bankBranch; BankBranchContract contract; List<BankBranchContract> bankBranchContracts = new ArrayList<>(); for (BankBranchContract bankBranchContract : bankBranchRequest.getBankBranches()) { bankBranch = new BankBranch(); model.map(bankBranchContract, bankBranch); bankBranch.setLastModifiedBy(bankBranchRequest.getRequestInfo().getUserInfo()); bankBranch.setLastModifiedDate(new Date()); bankbranches.add(bankBranch); } bankbranches = bankBranchService.update(bankbranches, errors, bankBranchRequest.getRequestInfo()); for (BankBranch bankBranchObj : bankbranches) { contract = new BankBranchContract(); model.map(bankBranchObj, contract); bankBranchObj.setLastModifiedDate(new Date()); bankBranchContracts.add(contract); } bankBranchResponse.setBankBranches(bankBranchContracts); return bankBranchResponse; }  }
BankBranchController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); BankBranchResponse bankBranchResponse = new BankBranchResponse(); List<BankBranch> bankbranches = new ArrayList<>(); bankBranchResponse.setResponseInfo(getResponseInfo(bankBranchRequest.getRequestInfo())); BankBranch bankBranch; BankBranchContract contract; List<BankBranchContract> bankBranchContracts = new ArrayList<>(); for (BankBranchContract bankBranchContract : bankBranchRequest.getBankBranches()) { bankBranch = new BankBranch(); model.map(bankBranchContract, bankBranch); bankBranch.setLastModifiedBy(bankBranchRequest.getRequestInfo().getUserInfo()); bankBranch.setLastModifiedDate(new Date()); bankbranches.add(bankBranch); } bankbranches = bankBranchService.update(bankbranches, errors, bankBranchRequest.getRequestInfo()); for (BankBranch bankBranchObj : bankbranches) { contract = new BankBranchContract(); model.map(bankBranchObj, contract); bankBranchObj.setLastModifiedDate(new Date()); bankBranchContracts.add(contract); } bankBranchResponse.setBankBranches(bankBranchContracts); return bankBranchResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse create(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId); }
BankBranchController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); BankBranchResponse bankBranchResponse = new BankBranchResponse(); List<BankBranch> bankbranches = new ArrayList<>(); bankBranchResponse.setResponseInfo(getResponseInfo(bankBranchRequest.getRequestInfo())); BankBranch bankBranch; BankBranchContract contract; List<BankBranchContract> bankBranchContracts = new ArrayList<>(); for (BankBranchContract bankBranchContract : bankBranchRequest.getBankBranches()) { bankBranch = new BankBranch(); model.map(bankBranchContract, bankBranch); bankBranch.setLastModifiedBy(bankBranchRequest.getRequestInfo().getUserInfo()); bankBranch.setLastModifiedDate(new Date()); bankbranches.add(bankBranch); } bankbranches = bankBranchService.update(bankbranches, errors, bankBranchRequest.getRequestInfo()); for (BankBranch bankBranchObj : bankbranches) { contract = new BankBranchContract(); model.map(bankBranchObj, contract); bankBranchObj.setLastModifiedDate(new Date()); bankBranchContracts.add(contract); } bankBranchResponse.setBankBranches(bankBranchContracts); return bankBranchResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse create(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchResponse search(@ModelAttribute BankBranchSearchContract bankBranchSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId);  }