@Test public void testCreate() throws IOException, Exception { when(bankAccountService.create(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn((getBankAccounts())); mockMvc.perform(post("/bankaccounts/_create?tenantId=default") .content(resources.readRequest("bankaccount/bankAccount_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("bankaccount/bankAccount_create_valid_response.json"))); verify(bankAccountService).create(captor.capture(), any(BindingResult.class), any(RequestInfo.class)); final List<BankAccount> actualRequest = captor.getValue(); assertEquals("1", actualRequest.get(0).getBankBranch().getId()); assertEquals("1", actualRequest.get(0).getChartOfAccount().getId()); assertEquals("2", actualRequest.get(0).getFund().getId()); assertEquals("0004", actualRequest.get(0).getAccountNumber()); assertEquals(true, actualRequest.get(0).getActive()); }
@PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); BankAccountResponse bankAccountResponse = new BankAccountResponse(); bankAccountResponse.setResponseInfo(getResponseInfo(bankAccountRequest.getRequestInfo())); List<BankAccount> bankaccounts = new ArrayList<>(); BankAccount bankAccount; List<BankAccountContract> bankAccountContracts = new ArrayList<>(); BankAccountContract contract; bankAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (BankAccountContract bankAccountContract : bankAccountRequest.getBankAccounts()) { bankAccount = new BankAccount(); model.map(bankAccountContract, bankAccount); bankAccount.setCreatedDate(new Date()); bankAccount.setCreatedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankAccount.setLastModifiedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankaccounts.add(bankAccount); } bankaccounts = bankAccountService.create(bankaccounts, errors, bankAccountRequest.getRequestInfo()); for (BankAccount f : bankaccounts) { contract = new BankAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); bankAccountContracts.add(contract); } bankAccountResponse.setBankAccounts(bankAccountContracts); return bankAccountResponse; }
BankAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); BankAccountResponse bankAccountResponse = new BankAccountResponse(); bankAccountResponse.setResponseInfo(getResponseInfo(bankAccountRequest.getRequestInfo())); List<BankAccount> bankaccounts = new ArrayList<>(); BankAccount bankAccount; List<BankAccountContract> bankAccountContracts = new ArrayList<>(); BankAccountContract contract; bankAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (BankAccountContract bankAccountContract : bankAccountRequest.getBankAccounts()) { bankAccount = new BankAccount(); model.map(bankAccountContract, bankAccount); bankAccount.setCreatedDate(new Date()); bankAccount.setCreatedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankAccount.setLastModifiedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankaccounts.add(bankAccount); } bankaccounts = bankAccountService.create(bankaccounts, errors, bankAccountRequest.getRequestInfo()); for (BankAccount f : bankaccounts) { contract = new BankAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); bankAccountContracts.add(contract); } bankAccountResponse.setBankAccounts(bankAccountContracts); return bankAccountResponse; } }
BankAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); BankAccountResponse bankAccountResponse = new BankAccountResponse(); bankAccountResponse.setResponseInfo(getResponseInfo(bankAccountRequest.getRequestInfo())); List<BankAccount> bankaccounts = new ArrayList<>(); BankAccount bankAccount; List<BankAccountContract> bankAccountContracts = new ArrayList<>(); BankAccountContract contract; bankAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (BankAccountContract bankAccountContract : bankAccountRequest.getBankAccounts()) { bankAccount = new BankAccount(); model.map(bankAccountContract, bankAccount); bankAccount.setCreatedDate(new Date()); bankAccount.setCreatedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankAccount.setLastModifiedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankaccounts.add(bankAccount); } bankaccounts = bankAccountService.create(bankaccounts, errors, bankAccountRequest.getRequestInfo()); for (BankAccount f : bankaccounts) { contract = new BankAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); bankAccountContracts.add(contract); } bankAccountResponse.setBankAccounts(bankAccountContracts); return bankAccountResponse; }  }
BankAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); BankAccountResponse bankAccountResponse = new BankAccountResponse(); bankAccountResponse.setResponseInfo(getResponseInfo(bankAccountRequest.getRequestInfo())); List<BankAccount> bankaccounts = new ArrayList<>(); BankAccount bankAccount; List<BankAccountContract> bankAccountContracts = new ArrayList<>(); BankAccountContract contract; bankAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (BankAccountContract bankAccountContract : bankAccountRequest.getBankAccounts()) { bankAccount = new BankAccount(); model.map(bankAccountContract, bankAccount); bankAccount.setCreatedDate(new Date()); bankAccount.setCreatedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankAccount.setLastModifiedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankaccounts.add(bankAccount); } bankaccounts = bankAccountService.create(bankaccounts, errors, bankAccountRequest.getRequestInfo()); for (BankAccount f : bankaccounts) { contract = new BankAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); bankAccountContracts.add(contract); } bankAccountResponse.setBankAccounts(bankAccountContracts); return bankAccountResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BankAccountResponse update(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankAccountResponse search(@ModelAttribute BankAccountSearchContract bankAccountSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId); }
BankAccountController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); BankAccountResponse bankAccountResponse = new BankAccountResponse(); bankAccountResponse.setResponseInfo(getResponseInfo(bankAccountRequest.getRequestInfo())); List<BankAccount> bankaccounts = new ArrayList<>(); BankAccount bankAccount; List<BankAccountContract> bankAccountContracts = new ArrayList<>(); BankAccountContract contract; bankAccountRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (BankAccountContract bankAccountContract : bankAccountRequest.getBankAccounts()) { bankAccount = new BankAccount(); model.map(bankAccountContract, bankAccount); bankAccount.setCreatedDate(new Date()); bankAccount.setCreatedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankAccount.setLastModifiedBy(bankAccountRequest.getRequestInfo().getUserInfo()); bankaccounts.add(bankAccount); } bankaccounts = bankAccountService.create(bankaccounts, errors, bankAccountRequest.getRequestInfo()); for (BankAccount f : bankaccounts) { contract = new BankAccountContract(); contract.setCreatedDate(new Date()); model.map(f, contract); bankAccountContracts.add(contract); } bankAccountResponse.setBankAccounts(bankAccountContracts); return bankAccountResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) BankAccountResponse create(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) BankAccountResponse update(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankAccountResponse search(@ModelAttribute BankAccountSearchContract bankAccountSearchContract,
			@RequestBody RequestInfo requestInfo, BindingResult errors,@RequestParam String tenantId);  }