@Test public void testCreate_Error() throws IOException, Exception { when(accountDetailKeyService.create(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(getAccountDetailKies()); mockMvc.perform(post("/accountdetailkeys/_create") .content(resources.readRequest("accountdetailkey/accountdetailkey_create_invalid_fieldvalue.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is5xxServerError()); }
@PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); AccountDetailKey accountDetailKey; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); AccountDetailKeyContract contract; accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setCreatedDate(new Date()); accountDetailKey.setCreatedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.create(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey f : accountdetailkeys) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; }
AccountDetailKeyController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); AccountDetailKey accountDetailKey; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); AccountDetailKeyContract contract; accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setCreatedDate(new Date()); accountDetailKey.setCreatedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.create(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey f : accountdetailkeys) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; } }
AccountDetailKeyController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); AccountDetailKey accountDetailKey; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); AccountDetailKeyContract contract; accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setCreatedDate(new Date()); accountDetailKey.setCreatedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.create(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey f : accountdetailkeys) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailKeyContracts.add(contract); } accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts); return accountDetailKeyResponse; }  }
AccountDetailKeyController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); AccountDetailKey accountDetailKey; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); AccountDetailKeyContract contract; accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setCreatedDate(new Date()); accountDetailKey.setCreatedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.create(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey f : accountdetailkeys) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); model.map(f, contract); 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("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailKeyResponse create(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse(); accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo())); List<AccountDetailKey> accountdetailkeys = new ArrayList<>(); AccountDetailKey accountDetailKey; List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>(); AccountDetailKeyContract contract; accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) { accountDetailKey = new AccountDetailKey(); model.map(accountDetailKeyContract, accountDetailKey); accountDetailKey.setCreatedDate(new Date()); accountDetailKey.setCreatedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo()); accountdetailkeys.add(accountDetailKey); } accountdetailkeys = accountDetailKeyService.create(accountdetailkeys, errors, accountDetailKeyRequest.getRequestInfo()); for (AccountDetailKey f : accountdetailkeys) { contract = new AccountDetailKeyContract(); contract.setCreatedDate(new Date()); model.map(f, contract); 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);  }