@Test public void testUpdate() throws IOException, Exception { mockMvc.perform(post("/accountcodepurposes/1/_update") .content(resources.getFileContents("accountcodepurpose/accountCodePurposeContractUpdateRequest.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(resources.getFileContents("accountcodepurpose/accountCodePurposeContractUpdateResponse.json"))); final ArgumentCaptor<AccountCodePurposeContractRequest> argumentCaptor = ArgumentCaptor .forClass(AccountCodePurposeContractRequest.class); verify(accountCodePurposeService).validate(argumentCaptor.capture(), any(String.class), any(BindingResult.class)); verify(accountCodePurposeService).fetchRelatedContracts(argumentCaptor.capture()); verify(accountCodePurposeService).push(argumentCaptor.capture()); final AccountCodePurposeContractRequest actualRequest = argumentCaptor.getValue(); assertEquals("accountCodePurposeU", actualRequest.getAccountCodePurpose().getName()); assertEquals("default", actualRequest.getAccountCodePurpose().getTenantId()); }
@PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse update( @RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest, BindingResult errors, @PathVariable Long uniqueId) { accountCodePurposeService.validate(accountCodePurposeContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeContractRequest.getRequestInfo().setAction("update"); accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); accountCodePurposeContractRequest.getAccountCodePurpose().setId(uniqueId); accountCodePurposeService.push(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse .setAccountCodePurpose(accountCodePurposeContractRequest.getAccountCodePurpose()); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }
AccountCodePurposeController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse update( @RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest, BindingResult errors, @PathVariable Long uniqueId) { accountCodePurposeService.validate(accountCodePurposeContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeContractRequest.getRequestInfo().setAction("update"); accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); accountCodePurposeContractRequest.getAccountCodePurpose().setId(uniqueId); accountCodePurposeService.push(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse .setAccountCodePurpose(accountCodePurposeContractRequest.getAccountCodePurpose()); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; } }
AccountCodePurposeController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse update( @RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest, BindingResult errors, @PathVariable Long uniqueId) { accountCodePurposeService.validate(accountCodePurposeContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeContractRequest.getRequestInfo().setAction("update"); accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); accountCodePurposeContractRequest.getAccountCodePurpose().setId(uniqueId); accountCodePurposeService.push(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse .setAccountCodePurpose(accountCodePurposeContractRequest.getAccountCodePurpose()); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }  }
AccountCodePurposeController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse update( @RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest, BindingResult errors, @PathVariable Long uniqueId) { accountCodePurposeService.validate(accountCodePurposeContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeContractRequest.getRequestInfo().setAction("update"); accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); accountCodePurposeContractRequest.getAccountCodePurpose().setId(uniqueId); accountCodePurposeService.push(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse .setAccountCodePurpose(accountCodePurposeContractRequest.getAccountCodePurpose()); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }  @PostMapping("_create") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse create(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse update(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse updateAll(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse search(
			@ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors); }
AccountCodePurposeController { @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse update( @RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest, BindingResult errors, @PathVariable Long uniqueId) { accountCodePurposeService.validate(accountCodePurposeContractRequest, "update", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeContractRequest.getRequestInfo().setAction("update"); accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); accountCodePurposeContractRequest.getAccountCodePurpose().setId(uniqueId); accountCodePurposeService.push(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse .setAccountCodePurpose(accountCodePurposeContractRequest.getAccountCodePurpose()); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }  @PostMapping("_create") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse create(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse update(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse updateAll(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse search(
			@ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors);  }