@Test public void testCreate() throws IOException, Exception { when(chartOfAccountService.add(any(List.class),any(BindingResult.class))) .thenReturn((getChartOfAccounts())); mockMvc.perform(post("/chartofaccounts/_create?tenantId=default").content(resources.readRequest("chartofaccount/chartofaccount_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("chartofaccount/chartofaccount_create_valid_response.json"))); verify(chartOfAccountService).addToQue(captor.capture()); final ChartOfAccountRequest actualRequest = captor.getValue(); assertEquals("AadharBank", actualRequest.getChartOfAccounts().get(0).getName()); assertEquals("GLCode", actualRequest.getChartOfAccounts().get(0).getGlcode()); assertEquals(true, actualRequest.getChartOfAccounts().get(0).getIsActiveForPosting()); assertEquals("default", actualRequest.getChartOfAccounts().get(0).getTenantId()); assertEquals(true, actualRequest.getChartOfAccounts().get(0).getBudgetCheckRequired()); }
@PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountResponse chartOfAccountResponse = new ChartOfAccountResponse(); chartOfAccountResponse.setResponseInfo(getResponseInfo(chartOfAccountRequest.getRequestInfo())); List<ChartOfAccount> chartofaccounts = new ArrayList<>(); ChartOfAccount chartOfAccount; List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); ChartOfAccountContract contract; chartOfAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountContract chartOfAccountContract : chartOfAccountRequest.getChartOfAccounts()) { chartOfAccount = new ChartOfAccount(); model.map(chartOfAccountContract, chartOfAccount); chartOfAccount.setCreatedDate(new Date()); chartOfAccount.setCreatedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartOfAccount.setLastModifiedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartofaccounts.add(chartOfAccount); } chartofaccounts = chartOfAccountService.add(chartofaccounts, errors); for (ChartOfAccount f : chartofaccounts) { contract = new ChartOfAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountContracts.add(contract); } chartOfAccountRequest.setChartOfAccounts(chartOfAccountContracts); chartOfAccountService.addToQue(chartOfAccountRequest); chartOfAccountResponse.setChartOfAccounts(chartOfAccountContracts); return chartOfAccountResponse; }
ChartOfAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountResponse chartOfAccountResponse = new ChartOfAccountResponse(); chartOfAccountResponse.setResponseInfo(getResponseInfo(chartOfAccountRequest.getRequestInfo())); List<ChartOfAccount> chartofaccounts = new ArrayList<>(); ChartOfAccount chartOfAccount; List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); ChartOfAccountContract contract; chartOfAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountContract chartOfAccountContract : chartOfAccountRequest.getChartOfAccounts()) { chartOfAccount = new ChartOfAccount(); model.map(chartOfAccountContract, chartOfAccount); chartOfAccount.setCreatedDate(new Date()); chartOfAccount.setCreatedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartOfAccount.setLastModifiedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartofaccounts.add(chartOfAccount); } chartofaccounts = chartOfAccountService.add(chartofaccounts, errors); for (ChartOfAccount f : chartofaccounts) { contract = new ChartOfAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountContracts.add(contract); } chartOfAccountRequest.setChartOfAccounts(chartOfAccountContracts); chartOfAccountService.addToQue(chartOfAccountRequest); chartOfAccountResponse.setChartOfAccounts(chartOfAccountContracts); return chartOfAccountResponse; } }
ChartOfAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountResponse chartOfAccountResponse = new ChartOfAccountResponse(); chartOfAccountResponse.setResponseInfo(getResponseInfo(chartOfAccountRequest.getRequestInfo())); List<ChartOfAccount> chartofaccounts = new ArrayList<>(); ChartOfAccount chartOfAccount; List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); ChartOfAccountContract contract; chartOfAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountContract chartOfAccountContract : chartOfAccountRequest.getChartOfAccounts()) { chartOfAccount = new ChartOfAccount(); model.map(chartOfAccountContract, chartOfAccount); chartOfAccount.setCreatedDate(new Date()); chartOfAccount.setCreatedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartOfAccount.setLastModifiedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartofaccounts.add(chartOfAccount); } chartofaccounts = chartOfAccountService.add(chartofaccounts, errors); for (ChartOfAccount f : chartofaccounts) { contract = new ChartOfAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountContracts.add(contract); } chartOfAccountRequest.setChartOfAccounts(chartOfAccountContracts); chartOfAccountService.addToQue(chartOfAccountRequest); chartOfAccountResponse.setChartOfAccounts(chartOfAccountContracts); return chartOfAccountResponse; }  }
ChartOfAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountResponse chartOfAccountResponse = new ChartOfAccountResponse(); chartOfAccountResponse.setResponseInfo(getResponseInfo(chartOfAccountRequest.getRequestInfo())); List<ChartOfAccount> chartofaccounts = new ArrayList<>(); ChartOfAccount chartOfAccount; List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); ChartOfAccountContract contract; chartOfAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountContract chartOfAccountContract : chartOfAccountRequest.getChartOfAccounts()) { chartOfAccount = new ChartOfAccount(); model.map(chartOfAccountContract, chartOfAccount); chartOfAccount.setCreatedDate(new Date()); chartOfAccount.setCreatedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartOfAccount.setLastModifiedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartofaccounts.add(chartOfAccount); } chartofaccounts = chartOfAccountService.add(chartofaccounts, errors); for (ChartOfAccount f : chartofaccounts) { contract = new ChartOfAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountContracts.add(contract); } chartOfAccountRequest.setChartOfAccounts(chartOfAccountContracts); chartOfAccountService.addToQue(chartOfAccountRequest); chartOfAccountResponse.setChartOfAccounts(chartOfAccountContracts); return chartOfAccountResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse update(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId); }
ChartOfAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); ChartOfAccountResponse chartOfAccountResponse = new ChartOfAccountResponse(); chartOfAccountResponse.setResponseInfo(getResponseInfo(chartOfAccountRequest.getRequestInfo())); List<ChartOfAccount> chartofaccounts = new ArrayList<>(); ChartOfAccount chartOfAccount; List<ChartOfAccountContract> chartOfAccountContracts = new ArrayList<>(); ChartOfAccountContract contract; chartOfAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (ChartOfAccountContract chartOfAccountContract : chartOfAccountRequest.getChartOfAccounts()) { chartOfAccount = new ChartOfAccount(); model.map(chartOfAccountContract, chartOfAccount); chartOfAccount.setCreatedDate(new Date()); chartOfAccount.setCreatedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartOfAccount.setLastModifiedBy(chartOfAccountRequest.getRequestInfo().getUserInfo()); chartofaccounts.add(chartOfAccount); } chartofaccounts = chartOfAccountService.add(chartofaccounts, errors); for (ChartOfAccount f : chartofaccounts) { contract = new ChartOfAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); chartOfAccountContracts.add(contract); } chartOfAccountRequest.setChartOfAccounts(chartOfAccountContracts); chartOfAccountService.addToQue(chartOfAccountRequest); chartOfAccountResponse.setChartOfAccounts(chartOfAccountContracts); return chartOfAccountResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse create(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) ChartOfAccountResponse update(@RequestBody ChartOfAccountRequest chartOfAccountRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) ChartOfAccountResponse search(@ModelAttribute ChartOfAccountSearchContract chartOfAccountSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId);  }