@Test public void testUpdate() throws IOException, Exception { mockMvc.perform(post("/bankbranches/1/_update") .content(resources.getFileContents("bankbranch/bankBranchContractUpdateRequest.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(resources.getFileContents("bankbranch/bankBranchContractUpdateResponse.json"))); final ArgumentCaptor<BankBranchContractRequest> argumentCaptor = ArgumentCaptor .forClass(BankBranchContractRequest.class); verify(bankBranchService).validate(argumentCaptor.capture(), any(String.class), any(BindingResult.class)); verify(bankBranchService).fetchRelatedContracts(argumentCaptor.capture()); verify(bankBranchService).push(argumentCaptor.capture()); final BankBranchContractRequest actualRequest = argumentCaptor.getValue(); assertEquals("nameU", actualRequest.getBankBranch().getName()); assertEquals("codeU", actualRequest.getBankBranch().getCode()); assertEquals(Long.valueOf(1), actualRequest.getBankBranch().getBank().getId()); assertEquals("default", actualRequest.getBankBranch().getTenantId()); }
@PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest, BindingResult errors, @PathVariable Long uniqueId) { bankBranchService.validate(bankBranchContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchContractRequest.getRequestInfo().setAction("update"); bankBranchService.fetchRelatedContracts(bankBranchContractRequest); bankBranchContractRequest.getBankBranch().setId(uniqueId); bankBranchService.push(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranch(new BankBranchContract()); bankBranchContractResponse.setBankBranch(bankBranchContractRequest.getBankBranch()); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }
BankBranchController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest, BindingResult errors, @PathVariable Long uniqueId) { bankBranchService.validate(bankBranchContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchContractRequest.getRequestInfo().setAction("update"); bankBranchService.fetchRelatedContracts(bankBranchContractRequest); bankBranchContractRequest.getBankBranch().setId(uniqueId); bankBranchService.push(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranch(new BankBranchContract()); bankBranchContractResponse.setBankBranch(bankBranchContractRequest.getBankBranch()); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; } }
BankBranchController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest, BindingResult errors, @PathVariable Long uniqueId) { bankBranchService.validate(bankBranchContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchContractRequest.getRequestInfo().setAction("update"); bankBranchService.fetchRelatedContracts(bankBranchContractRequest); bankBranchContractRequest.getBankBranch().setId(uniqueId); bankBranchService.push(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranch(new BankBranchContract()); bankBranchContractResponse.setBankBranch(bankBranchContractRequest.getBankBranch()); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }  }
BankBranchController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest, BindingResult errors, @PathVariable Long uniqueId) { bankBranchService.validate(bankBranchContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchContractRequest.getRequestInfo().setAction("update"); bankBranchService.fetchRelatedContracts(bankBranchContractRequest); bankBranchContractRequest.getBankBranch().setId(uniqueId); bankBranchService.push(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranch(new BankBranchContract()); bankBranchContractResponse.setBankBranch(bankBranchContractRequest.getBankBranch()); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse create(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse updateAll(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors); }
BankBranchController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest, BindingResult errors, @PathVariable Long uniqueId) { bankBranchService.validate(bankBranchContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchContractRequest.getRequestInfo().setAction("update"); bankBranchService.fetchRelatedContracts(bankBranchContractRequest); bankBranchContractRequest.getBankBranch().setId(uniqueId); bankBranchService.push(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranch(new BankBranchContract()); bankBranchContractResponse.setBankBranch(bankBranchContractRequest.getBankBranch()); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse create(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse updateAll(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors);  }