@Test public void testUpdate() throws IOException, Exception { when(accountDetailKeyService.update(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(getUpdateAccountDetailKies()); mockMvc.perform(post("/accountdetailkeys/_update?tenantId=default") .content(resources.readRequest("accountdetailkey/accountdetailkey_update_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content() .json(resources.readResponse("accountdetailkey/accountdetailkey_update_response.json"))); verify(accountDetailKeyService).update(captor.capture(), any(BindingResult.class), any(RequestInfo.class)); final List<AccountDetailKey> actualRequest = captor.getValue(); assertEquals("2", actualRequest.get(0).getKey()); assertEquals("1", actualRequest.get(0).getAccountDetailType().getId()); assertEquals("default", actualRequest.get(0).getTenantId()); }
@PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); AccountDetailKey accountDetailKey; AccountDetailKeyContract contract; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedDate(new Date()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.update(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey accountDetailKeyObj : accountdetailkeys) { contract = new AccountDetailKeyContract(); model.map(accountDetailKeyObj, contract); accountDetailKeyObj.setLastModifiedDate(new Date()); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; }
AccountDetailKeyController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); AccountDetailKey accountDetailKey; AccountDetailKeyContract contract; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedDate(new Date()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.update(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey accountDetailKeyObj : accountdetailkeys) { contract = new AccountDetailKeyContract(); model.map(accountDetailKeyObj, contract); accountDetailKeyObj.setLastModifiedDate(new Date()); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; } }
AccountDetailKeyController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); AccountDetailKey accountDetailKey; AccountDetailKeyContract contract; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedDate(new Date()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.update(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey accountDetailKeyObj : accountdetailkeys) { contract = new AccountDetailKeyContract(); model.map(accountDetailKeyObj, contract); accountDetailKeyObj.setLastModifiedDate(new Date()); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; }  }
AccountDetailKeyController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); AccountDetailKey accountDetailKey; AccountDetailKeyContract contract; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedDate(new Date()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.update(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey accountDetailKeyObj : accountdetailkeys) { contract = new AccountDetailKeyContract(); model.map(accountDetailKeyObj, contract); accountDetailKeyObj.setLastModifiedDate(new Date()); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailKeyResponse search(
			@ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId); }
AccountDetailKeyController { @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE); ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); AccountDetailKey accountDetailKey; AccountDetailKeyContract contract; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedDate(new Date()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.update(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey accountDetailKeyObj : accountdetailkeys) { contract = new AccountDetailKeyContract(); model.map(accountDetailKeyObj, contract); accountDetailKeyObj.setLastModifiedDate(new Date()); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailKeyResponse search(
			@ModelAttribute AccountDetailKeySearchContract accountDetailKeySearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId);  }