@Test public void testCreate() throws IOException, Exception { when(chartOfAccountDetailService.add(any(List.class),any(BindingResult.class))) .thenReturn((getChartOfAccountDetails())); mockMvc.perform(post("/chartofaccountdetails/_create?tenantId=default").content(resources.readRequest("chartofaccountdetail/chartofaccountdetail_create_valid_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(content().json(resources.readResponse("chartofaccountdetail/chartofaccountdetail_create_valid_response.json"))); verify(chartOfAccountDetailService).addToQue(captor.capture()); final ChartOfAccountDetailRequest actualRequest = captor.getValue(); assertEquals("830bf3dc60504244babfe228bdf80bac", actualRequest.getChartOfAccountDetails().get(0).getChartOfAccount().getId()); assertEquals("e647d2406902400cbf3cee71a4befb35", actualRequest.getChartOfAccountDetails().get(0).getAccountDetailType().getId()); }
@PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountDetailResponse create(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountDetailResponse chartOfAccountDetailResponse = new ChartOfAccountDetailResponse(); chartOfAccountDetailResponse.setResponseInfo(getResponseInfo(chartOfAccountDetailRequest.getRequestInfo())); List<ChartOfAccountDetail> chartofaccountdetails = new ArrayList<>(); ChartOfAccountDetail chartOfAccountDetail; List<ChartOfAccountDetailContract> chartOfAccountDetailContracts = new ArrayList<>(); ChartOfAccountDetailContract contract; chartOfAccountDetailRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountDetailContract chartOfAccountDetailContract : chartOfAccountDetailRequest .getChartOfAccountDetails()) { chartOfAccountDetail = new ChartOfAccountDetail(); model.map(chartOfAccountDetailContract, chartOfAccountDetail); chartOfAccountDetail.setCreatedDate(new Date()); chartOfAccountDetail.setCreatedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartOfAccountDetail.setLastModifiedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartofaccountdetails.add(chartOfAccountDetail); } chartofaccountdetails = chartOfAccountDetailService.add(chartofaccountdetails, errors); for (ChartOfAccountDetail f : chartofaccountdetails) { contract = new ChartOfAccountDetailContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountDetailContracts.add(contract); } chartOfAccountDetailRequest.setChartOfAccountDetails(chartOfAccountDetailContracts); chartOfAccountDetailService.addToQue(chartOfAccountDetailRequest); chartOfAccountDetailResponse.setChartOfAccountDetails(chartOfAccountDetailContracts); return chartOfAccountDetailResponse; }
ChartOfAccountDetailController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountDetailResponse create(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountDetailResponse chartOfAccountDetailResponse = new ChartOfAccountDetailResponse(); chartOfAccountDetailResponse.setResponseInfo(getResponseInfo(chartOfAccountDetailRequest.getRequestInfo())); List<ChartOfAccountDetail> chartofaccountdetails = new ArrayList<>(); ChartOfAccountDetail chartOfAccountDetail; List<ChartOfAccountDetailContract> chartOfAccountDetailContracts = new ArrayList<>(); ChartOfAccountDetailContract contract; chartOfAccountDetailRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountDetailContract chartOfAccountDetailContract : chartOfAccountDetailRequest .getChartOfAccountDetails()) { chartOfAccountDetail = new ChartOfAccountDetail(); model.map(chartOfAccountDetailContract, chartOfAccountDetail); chartOfAccountDetail.setCreatedDate(new Date()); chartOfAccountDetail.setCreatedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartOfAccountDetail.setLastModifiedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartofaccountdetails.add(chartOfAccountDetail); } chartofaccountdetails = chartOfAccountDetailService.add(chartofaccountdetails, errors); for (ChartOfAccountDetail f : chartofaccountdetails) { contract = new ChartOfAccountDetailContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountDetailContracts.add(contract); } chartOfAccountDetailRequest.setChartOfAccountDetails(chartOfAccountDetailContracts); chartOfAccountDetailService.addToQue(chartOfAccountDetailRequest); chartOfAccountDetailResponse.setChartOfAccountDetails(chartOfAccountDetailContracts); return chartOfAccountDetailResponse; } }
ChartOfAccountDetailController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountDetailResponse create(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountDetailResponse chartOfAccountDetailResponse = new ChartOfAccountDetailResponse(); chartOfAccountDetailResponse.setResponseInfo(getResponseInfo(chartOfAccountDetailRequest.getRequestInfo())); List<ChartOfAccountDetail> chartofaccountdetails = new ArrayList<>(); ChartOfAccountDetail chartOfAccountDetail; List<ChartOfAccountDetailContract> chartOfAccountDetailContracts = new ArrayList<>(); ChartOfAccountDetailContract contract; chartOfAccountDetailRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountDetailContract chartOfAccountDetailContract : chartOfAccountDetailRequest .getChartOfAccountDetails()) { chartOfAccountDetail = new ChartOfAccountDetail(); model.map(chartOfAccountDetailContract, chartOfAccountDetail); chartOfAccountDetail.setCreatedDate(new Date()); chartOfAccountDetail.setCreatedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartOfAccountDetail.setLastModifiedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartofaccountdetails.add(chartOfAccountDetail); } chartofaccountdetails = chartOfAccountDetailService.add(chartofaccountdetails, errors); for (ChartOfAccountDetail f : chartofaccountdetails) { contract = new ChartOfAccountDetailContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountDetailContracts.add(contract); } chartOfAccountDetailRequest.setChartOfAccountDetails(chartOfAccountDetailContracts); chartOfAccountDetailService.addToQue(chartOfAccountDetailRequest); chartOfAccountDetailResponse.setChartOfAccountDetails(chartOfAccountDetailContracts); return chartOfAccountDetailResponse; }  }
ChartOfAccountDetailController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountDetailResponse create(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountDetailResponse chartOfAccountDetailResponse = new ChartOfAccountDetailResponse(); chartOfAccountDetailResponse.setResponseInfo(getResponseInfo(chartOfAccountDetailRequest.getRequestInfo())); List<ChartOfAccountDetail> chartofaccountdetails = new ArrayList<>(); ChartOfAccountDetail chartOfAccountDetail; List<ChartOfAccountDetailContract> chartOfAccountDetailContracts = new ArrayList<>(); ChartOfAccountDetailContract contract; chartOfAccountDetailRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountDetailContract chartOfAccountDetailContract : chartOfAccountDetailRequest .getChartOfAccountDetails()) { chartOfAccountDetail = new ChartOfAccountDetail(); model.map(chartOfAccountDetailContract, chartOfAccountDetail); chartOfAccountDetail.setCreatedDate(new Date()); chartOfAccountDetail.setCreatedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartOfAccountDetail.setLastModifiedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartofaccountdetails.add(chartOfAccountDetail); } chartofaccountdetails = chartOfAccountDetailService.add(chartofaccountdetails, errors); for (ChartOfAccountDetail f : chartofaccountdetails) { contract = new ChartOfAccountDetailContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountDetailContracts.add(contract); } chartOfAccountDetailRequest.setChartOfAccountDetails(chartOfAccountDetailContracts); chartOfAccountDetailService.addToQue(chartOfAccountDetailRequest); chartOfAccountDetailResponse.setChartOfAccountDetails(chartOfAccountDetailContracts); return chartOfAccountDetailResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountDetailResponse create(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountDetailResponse update(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) ChartOfAccountDetailResponse search(
			@ModelAttribute ChartOfAccountDetailSearchContract chartOfAccountDetailSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId); }
ChartOfAccountDetailController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountDetailResponse create(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountDetailResponse chartOfAccountDetailResponse = new ChartOfAccountDetailResponse(); chartOfAccountDetailResponse.setResponseInfo(getResponseInfo(chartOfAccountDetailRequest.getRequestInfo())); List<ChartOfAccountDetail> chartofaccountdetails = new ArrayList<>(); ChartOfAccountDetail chartOfAccountDetail; List<ChartOfAccountDetailContract> chartOfAccountDetailContracts = new ArrayList<>(); ChartOfAccountDetailContract contract; chartOfAccountDetailRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountDetailContract chartOfAccountDetailContract : chartOfAccountDetailRequest .getChartOfAccountDetails()) { chartOfAccountDetail = new ChartOfAccountDetail(); model.map(chartOfAccountDetailContract, chartOfAccountDetail); chartOfAccountDetail.setCreatedDate(new Date()); chartOfAccountDetail.setCreatedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartOfAccountDetail.setLastModifiedBy(chartOfAccountDetailRequest.getRequestInfo().getUserInfo()); chartofaccountdetails.add(chartOfAccountDetail); } chartofaccountdetails = chartOfAccountDetailService.add(chartofaccountdetails, errors); for (ChartOfAccountDetail f : chartofaccountdetails) { contract = new ChartOfAccountDetailContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountDetailContracts.add(contract); } chartOfAccountDetailRequest.setChartOfAccountDetails(chartOfAccountDetailContracts); chartOfAccountDetailService.addToQue(chartOfAccountDetailRequest); chartOfAccountDetailResponse.setChartOfAccountDetails(chartOfAccountDetailContracts); return chartOfAccountDetailResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountDetailResponse create(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountDetailResponse update(@RequestBody ChartOfAccountDetailRequest chartOfAccountDetailRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) ChartOfAccountDetailResponse search(
			@ModelAttribute ChartOfAccountDetailSearchContract chartOfAccountDetailSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId);  }