@Test public void testCreate() throws IOException, Exception { when(accountCodePurposeService.create(any(List.class), any(BindingResult.class), any(RequestInfo.class))) .thenReturn(getAccountCodePurposes()); mockMvc.perform(post("/accountcodepurposes/_create?tenantId=default") .content(resources.readRequest("accountcodepurpose/accountcodepurpose_create_request.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(201)) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content().json( resources.readResponse("accountcodepurpose/accountcodepurpose_create_response.json"))); verify(accountCodePurposeService).create(captor.capture(), any(BindingResult.class), any(RequestInfo.class)); final List<AccountCodePurpose> actualRequest = captor.getValue(); assertEquals("name", actualRequest.get(0).getName()); assertEquals("default", actualRequest.get(0).getTenantId()); }
@PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountCodePurposeResponse accountCodePurposeResponse = new AccountCodePurposeResponse(); accountCodePurposeResponse.setResponseInfo(getResponseInfo(accountCodePurposeRequest.getRequestInfo())); List<AccountCodePurpose> accountcodepurposes = new ArrayList<>(); AccountCodePurpose accountCodePurpose; List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); AccountCodePurposeContract contract; accountCodePurposeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountCodePurposeContract accountCodePurposeContract : accountCodePurposeRequest .getAccountCodePurposes()) { accountCodePurpose = new AccountCodePurpose(); model.map(accountCodePurposeContract, accountCodePurpose); accountCodePurpose.setCreatedDate(new Date()); accountCodePurpose.setCreatedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountCodePurpose.setLastModifiedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountcodepurposes.add(accountCodePurpose); } accountcodepurposes = accountCodePurposeService.create(accountcodepurposes, errors, accountCodePurposeRequest.getRequestInfo()); for (AccountCodePurpose f : accountcodepurposes) { contract = new AccountCodePurposeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountCodePurposeContracts.add(contract); } accountCodePurposeResponse.setAccountCodePurposes(accountCodePurposeContracts); return accountCodePurposeResponse; }
AccountCodePurposeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountCodePurposeResponse accountCodePurposeResponse = new AccountCodePurposeResponse(); accountCodePurposeResponse.setResponseInfo(getResponseInfo(accountCodePurposeRequest.getRequestInfo())); List<AccountCodePurpose> accountcodepurposes = new ArrayList<>(); AccountCodePurpose accountCodePurpose; List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); AccountCodePurposeContract contract; accountCodePurposeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountCodePurposeContract accountCodePurposeContract : accountCodePurposeRequest .getAccountCodePurposes()) { accountCodePurpose = new AccountCodePurpose(); model.map(accountCodePurposeContract, accountCodePurpose); accountCodePurpose.setCreatedDate(new Date()); accountCodePurpose.setCreatedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountCodePurpose.setLastModifiedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountcodepurposes.add(accountCodePurpose); } accountcodepurposes = accountCodePurposeService.create(accountcodepurposes, errors, accountCodePurposeRequest.getRequestInfo()); for (AccountCodePurpose f : accountcodepurposes) { contract = new AccountCodePurposeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountCodePurposeContracts.add(contract); } accountCodePurposeResponse.setAccountCodePurposes(accountCodePurposeContracts); return accountCodePurposeResponse; } }
AccountCodePurposeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountCodePurposeResponse accountCodePurposeResponse = new AccountCodePurposeResponse(); accountCodePurposeResponse.setResponseInfo(getResponseInfo(accountCodePurposeRequest.getRequestInfo())); List<AccountCodePurpose> accountcodepurposes = new ArrayList<>(); AccountCodePurpose accountCodePurpose; List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); AccountCodePurposeContract contract; accountCodePurposeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountCodePurposeContract accountCodePurposeContract : accountCodePurposeRequest .getAccountCodePurposes()) { accountCodePurpose = new AccountCodePurpose(); model.map(accountCodePurposeContract, accountCodePurpose); accountCodePurpose.setCreatedDate(new Date()); accountCodePurpose.setCreatedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountCodePurpose.setLastModifiedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountcodepurposes.add(accountCodePurpose); } accountcodepurposes = accountCodePurposeService.create(accountcodepurposes, errors, accountCodePurposeRequest.getRequestInfo()); for (AccountCodePurpose f : accountcodepurposes) { contract = new AccountCodePurposeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountCodePurposeContracts.add(contract); } accountCodePurposeResponse.setAccountCodePurposes(accountCodePurposeContracts); return accountCodePurposeResponse; }  }
AccountCodePurposeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountCodePurposeResponse accountCodePurposeResponse = new AccountCodePurposeResponse(); accountCodePurposeResponse.setResponseInfo(getResponseInfo(accountCodePurposeRequest.getRequestInfo())); List<AccountCodePurpose> accountcodepurposes = new ArrayList<>(); AccountCodePurpose accountCodePurpose; List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); AccountCodePurposeContract contract; accountCodePurposeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountCodePurposeContract accountCodePurposeContract : accountCodePurposeRequest .getAccountCodePurposes()) { accountCodePurpose = new AccountCodePurpose(); model.map(accountCodePurposeContract, accountCodePurpose); accountCodePurpose.setCreatedDate(new Date()); accountCodePurpose.setCreatedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountCodePurpose.setLastModifiedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountcodepurposes.add(accountCodePurpose); } accountcodepurposes = accountCodePurposeService.create(accountcodepurposes, errors, accountCodePurposeRequest.getRequestInfo()); for (AccountCodePurpose f : accountcodepurposes) { contract = new AccountCodePurposeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountCodePurposeContracts.add(contract); } accountCodePurposeResponse.setAccountCodePurposes(accountCodePurposeContracts); return accountCodePurposeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse update(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeResponse search(
			@ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId); }
AccountCodePurposeController { @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) public AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest, BindingResult errors,@RequestParam String tenantId) { if (errors.hasErrors()) { throw new CustomBindException(errors); } ModelMapper model = new ModelMapper(); AccountCodePurposeResponse accountCodePurposeResponse = new AccountCodePurposeResponse(); accountCodePurposeResponse.setResponseInfo(getResponseInfo(accountCodePurposeRequest.getRequestInfo())); List<AccountCodePurpose> accountcodepurposes = new ArrayList<>(); AccountCodePurpose accountCodePurpose; List<AccountCodePurposeContract> accountCodePurposeContracts = new ArrayList<>(); AccountCodePurposeContract contract; accountCodePurposeRequest.getRequestInfo().setAction(Constants.ACTION_CREATE); for (AccountCodePurposeContract accountCodePurposeContract : accountCodePurposeRequest .getAccountCodePurposes()) { accountCodePurpose = new AccountCodePurpose(); model.map(accountCodePurposeContract, accountCodePurpose); accountCodePurpose.setCreatedDate(new Date()); accountCodePurpose.setCreatedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountCodePurpose.setLastModifiedBy(accountCodePurposeRequest.getRequestInfo().getUserInfo()); accountcodepurposes.add(accountCodePurpose); } accountcodepurposes = accountCodePurposeService.create(accountcodepurposes, errors, accountCodePurposeRequest.getRequestInfo()); for (AccountCodePurpose f : accountcodepurposes) { contract = new AccountCodePurposeContract(); contract.setCreatedDate(new Date()); model.map(f, contract); accountCodePurposeContracts.add(contract); } accountCodePurposeResponse.setAccountCodePurposes(accountCodePurposeContracts); return accountCodePurposeResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse create(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_update") @ResponseStatus(HttpStatus.CREATED) AccountCodePurposeResponse update(@RequestBody AccountCodePurposeRequest accountCodePurposeRequest,
			BindingResult errors,@RequestParam String tenantId); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeResponse search(
			@ModelAttribute AccountCodePurposeSearchContract accountCodePurposeSearchContract, @RequestBody RequestInfo requestInfo,
			BindingResult errors,@RequestParam String tenantId);  }