@Test public void testCreate_Error() throws IOException, Exception { when(accountDetailTypeService.create(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(getAccountDetailTypes()); mockMvc.perform(post("/accountdetailtypes/_create") .content(resources.readRequest("accountdetailtype/accountdetailtype_create_invalid_fieldvalue.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is5xxServerError()); }
@PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailTypeResponse accountDetailTypeResponse = new AccountDetailTypeResponse(); accountDetailTypeResponse.setResponseInfo(getResponseInfo(accountDetailTypeRequest.getRequestInfo())); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); AccountDetailType accountDetailType; List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); AccountDetailTypeContract contract; accountDetailTypeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailTypeContract accountDetailTypeContract : accountDetailTypeRequest.getAccountDetailTypes()) { accountDetailType = new AccountDetailType(); model.map(accountDetailTypeContract, accountDetailType); accountDetailType.setCreatedDate(new Date()); accountDetailType.setCreatedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountDetailType.setLastModifiedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountdetailtypes.add(accountDetailType); } accountdetailtypes = accountDetailTypeService.create(accountdetailtypes, errors, accountDetailTypeRequest.getRequestInfo()); for (AccountDetailType f : accountdetailtypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailTypeContracts.add(contract); } accountDetailTypeResponse.setAccountDetailTypes(accountDetailTypeContracts); return accountDetailTypeResponse; }
AccountDetailTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailTypeResponse accountDetailTypeResponse = new AccountDetailTypeResponse(); accountDetailTypeResponse.setResponseInfo(getResponseInfo(accountDetailTypeRequest.getRequestInfo())); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); AccountDetailType accountDetailType; List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); AccountDetailTypeContract contract; accountDetailTypeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailTypeContract accountDetailTypeContract : accountDetailTypeRequest.getAccountDetailTypes()) { accountDetailType = new AccountDetailType(); model.map(accountDetailTypeContract, accountDetailType); accountDetailType.setCreatedDate(new Date()); accountDetailType.setCreatedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountDetailType.setLastModifiedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountdetailtypes.add(accountDetailType); } accountdetailtypes = accountDetailTypeService.create(accountdetailtypes, errors, accountDetailTypeRequest.getRequestInfo()); for (AccountDetailType f : accountdetailtypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailTypeContracts.add(contract); } accountDetailTypeResponse.setAccountDetailTypes(accountDetailTypeContracts); return accountDetailTypeResponse; } }
AccountDetailTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailTypeResponse accountDetailTypeResponse = new AccountDetailTypeResponse(); accountDetailTypeResponse.setResponseInfo(getResponseInfo(accountDetailTypeRequest.getRequestInfo())); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); AccountDetailType accountDetailType; List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); AccountDetailTypeContract contract; accountDetailTypeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailTypeContract accountDetailTypeContract : accountDetailTypeRequest.getAccountDetailTypes()) { accountDetailType = new AccountDetailType(); model.map(accountDetailTypeContract, accountDetailType); accountDetailType.setCreatedDate(new Date()); accountDetailType.setCreatedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountDetailType.setLastModifiedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountdetailtypes.add(accountDetailType); } accountdetailtypes = accountDetailTypeService.create(accountdetailtypes, errors, accountDetailTypeRequest.getRequestInfo()); for (AccountDetailType f : accountdetailtypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailTypeContracts.add(contract); } accountDetailTypeResponse.setAccountDetailTypes(accountDetailTypeContracts); return accountDetailTypeResponse; }  }
AccountDetailTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailTypeResponse accountDetailTypeResponse = new AccountDetailTypeResponse(); accountDetailTypeResponse.setResponseInfo(getResponseInfo(accountDetailTypeRequest.getRequestInfo())); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); AccountDetailType accountDetailType; List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); AccountDetailTypeContract contract; accountDetailTypeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailTypeContract accountDetailTypeContract : accountDetailTypeRequest.getAccountDetailTypes()) { accountDetailType = new AccountDetailType(); model.map(accountDetailTypeContract, accountDetailType); accountDetailType.setCreatedDate(new Date()); accountDetailType.setCreatedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountDetailType.setLastModifiedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountdetailtypes.add(accountDetailType); } accountdetailtypes = accountDetailTypeService.create(accountdetailtypes, errors, accountDetailTypeRequest.getRequestInfo()); for (AccountDetailType f : accountdetailtypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailTypeContracts.add(contract); } accountDetailTypeResponse.setAccountDetailTypes(accountDetailTypeContracts); return accountDetailTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse update(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailTypeResponse search(
			@ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId); }
AccountDetailTypeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountDetailTypeResponse accountDetailTypeResponse = new AccountDetailTypeResponse(); accountDetailTypeResponse.setResponseInfo(getResponseInfo(accountDetailTypeRequest.getRequestInfo())); List<AccountDetailType> accountdetailtypes = new ArrayList<>(); AccountDetailType accountDetailType; List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>(); AccountDetailTypeContract contract; accountDetailTypeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountDetailTypeContract accountDetailTypeContract : accountDetailTypeRequest.getAccountDetailTypes()) { accountDetailType = new AccountDetailType(); model.map(accountDetailTypeContract, accountDetailType); accountDetailType.setCreatedDate(new Date()); accountDetailType.setCreatedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountDetailType.setLastModifiedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo()); accountdetailtypes.add(accountDetailType); } accountdetailtypes = accountDetailTypeService.create(accountdetailtypes, errors, accountDetailTypeRequest.getRequestInfo()); for (AccountDetailType f : accountdetailtypes) { contract = new AccountDetailTypeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountDetailTypeContracts.add(contract); } accountDetailTypeResponse.setAccountDetailTypes(accountDetailTypeContracts); return accountDetailTypeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse create(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountDetailTypeResponse update(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountDetailTypeResponse search(
			@ModelAttribute AccountDetailTypeSearchContract accountDetailTypeSearchContract,@RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId);  }