@Test public void testSearch() throws IOException, Exception { final ArgumentCaptor<AccountCodePurposeGetRequest> argumentCaptor = ArgumentCaptor .forClass(AccountCodePurposeGetRequest.class); final ArgumentCaptor<AccountCodePurposeContractRequest> argumentCaptor1 = ArgumentCaptor .forClass(AccountCodePurposeContractRequest.class); when(accountCodePurposeService.getAccountCodePurposes(argumentCaptor.capture())) .thenReturn(getAccountCodePurpose()); mockMvc.perform(post("/accountcodepurposes/_search?name=test") .content(resources.getFileContents("accountcodepurpose/accountCodePurposeContractSearchRequest.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()) .andExpect(content().json(resources.getFileContents("accountcodepurpose/accountCodePurposeContractSearchResponse.json"))); verify(accountCodePurposeService).validate(argumentCaptor1.capture(), any(String.class), any(BindingResult.class)); verify(accountCodePurposeService).fetchRelatedContracts(argumentCaptor1.capture()); final AccountCodePurposeGetRequest actualRequest = argumentCaptor.getValue(); assertEquals("test", actualRequest.getName()); final AccountCodePurposeContractRequest actualRequest1 = argumentCaptor1.getValue(); assertEquals("action", actualRequest1.getRequestInfo().getAction()); assertEquals("did", actualRequest1.getRequestInfo().getDid()); assertEquals("msgId", actualRequest1.getRequestInfo().getMsgId()); assertEquals("requesterId", actualRequest1.getRequestInfo().getRequesterId()); }
@PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse search( @ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { AccountCodePurposeContractRequest accountCodePurposeContractRequest = new AccountCodePurposeContractRequest(); accountCodePurposeContractRequest.setAccountCodePurposeGetRequest(accountCodePurposeGetRequest); accountCodePurposeContractRequest.setRequestInfo(requestInfo); accountCodePurposeService.validate(accountCodePurposeContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse.setAccountCodePurposes(new ArrayList<AccountCodePurposeContract>()); accountCodePurposeContractResponse.setPage(new Pagination()); List<AccountCodePurpose> accountCodePurposesList = null; accountCodePurposesList = accountCodePurposeService.getAccountCodePurposes(accountCodePurposeGetRequest); for (AccountCodePurpose b : accountCodePurposesList) { accountCodePurposeContractResponse.getAccountCodePurposes().add(new AccountCodePurposeContract(b)); } accountCodePurposeContractResponse.getPage().map(new PageImpl<AccountCodePurpose>(accountCodePurposesList)); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }
AccountCodePurposeController { @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse search( @ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { AccountCodePurposeContractRequest accountCodePurposeContractRequest = new AccountCodePurposeContractRequest(); accountCodePurposeContractRequest.setAccountCodePurposeGetRequest(accountCodePurposeGetRequest); accountCodePurposeContractRequest.setRequestInfo(requestInfo); accountCodePurposeService.validate(accountCodePurposeContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse.setAccountCodePurposes(new ArrayList<AccountCodePurposeContract>()); accountCodePurposeContractResponse.setPage(new Pagination()); List<AccountCodePurpose> accountCodePurposesList = null; accountCodePurposesList = accountCodePurposeService.getAccountCodePurposes(accountCodePurposeGetRequest); for (AccountCodePurpose b : accountCodePurposesList) { accountCodePurposeContractResponse.getAccountCodePurposes().add(new AccountCodePurposeContract(b)); } accountCodePurposeContractResponse.getPage().map(new PageImpl<AccountCodePurpose>(accountCodePurposesList)); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; } }
AccountCodePurposeController { @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse search( @ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { AccountCodePurposeContractRequest accountCodePurposeContractRequest = new AccountCodePurposeContractRequest(); accountCodePurposeContractRequest.setAccountCodePurposeGetRequest(accountCodePurposeGetRequest); accountCodePurposeContractRequest.setRequestInfo(requestInfo); accountCodePurposeService.validate(accountCodePurposeContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse.setAccountCodePurposes(new ArrayList<AccountCodePurposeContract>()); accountCodePurposeContractResponse.setPage(new Pagination()); List<AccountCodePurpose> accountCodePurposesList = null; accountCodePurposesList = accountCodePurposeService.getAccountCodePurposes(accountCodePurposeGetRequest); for (AccountCodePurpose b : accountCodePurposesList) { accountCodePurposeContractResponse.getAccountCodePurposes().add(new AccountCodePurposeContract(b)); } accountCodePurposeContractResponse.getPage().map(new PageImpl<AccountCodePurpose>(accountCodePurposesList)); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }  }
AccountCodePurposeController { @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse search( @ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { AccountCodePurposeContractRequest accountCodePurposeContractRequest = new AccountCodePurposeContractRequest(); accountCodePurposeContractRequest.setAccountCodePurposeGetRequest(accountCodePurposeGetRequest); accountCodePurposeContractRequest.setRequestInfo(requestInfo); accountCodePurposeService.validate(accountCodePurposeContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse.setAccountCodePurposes(new ArrayList<AccountCodePurposeContract>()); accountCodePurposeContractResponse.setPage(new Pagination()); List<AccountCodePurpose> accountCodePurposesList = null; accountCodePurposesList = accountCodePurposeService.getAccountCodePurposes(accountCodePurposeGetRequest); for (AccountCodePurpose b : accountCodePurposesList) { accountCodePurposeContractResponse.getAccountCodePurposes().add(new AccountCodePurposeContract(b)); } accountCodePurposeContractResponse.getPage().map(new PageImpl<AccountCodePurpose>(accountCodePurposesList)); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }  @PostMapping("_create") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse create(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse update(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse updateAll(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse search(
			@ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors); }
AccountCodePurposeController { @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public AccountCodePurposeContractResponse search( @ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { AccountCodePurposeContractRequest accountCodePurposeContractRequest = new AccountCodePurposeContractRequest(); accountCodePurposeContractRequest.setAccountCodePurposeGetRequest(accountCodePurposeGetRequest); accountCodePurposeContractRequest.setRequestInfo(requestInfo); accountCodePurposeService.validate(accountCodePurposeContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } accountCodePurposeService.fetchRelatedContracts(accountCodePurposeContractRequest); AccountCodePurposeContractResponse accountCodePurposeContractResponse = new AccountCodePurposeContractResponse(); accountCodePurposeContractResponse.setAccountCodePurposes(new ArrayList<AccountCodePurposeContract>()); accountCodePurposeContractResponse.setPage(new Pagination()); List<AccountCodePurpose> accountCodePurposesList = null; accountCodePurposesList = accountCodePurposeService.getAccountCodePurposes(accountCodePurposeGetRequest); for (AccountCodePurpose b : accountCodePurposesList) { accountCodePurposeContractResponse.getAccountCodePurposes().add(new AccountCodePurposeContract(b)); } accountCodePurposeContractResponse.getPage().map(new PageImpl<AccountCodePurpose>(accountCodePurposesList)); accountCodePurposeContractResponse .setResponseInfo(getResponseInfo(accountCodePurposeContractRequest.getRequestInfo())); accountCodePurposeContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return accountCodePurposeContractResponse; }  @PostMapping("_create") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse create(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse update(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("_update") @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse updateAll(
			@RequestBody @Valid AccountCodePurposeContractRequest accountCodePurposeContractRequest,
			BindingResult errors); @PostMapping("_search") @ResponseBody @ResponseStatus(HttpStatus.OK) AccountCodePurposeContractResponse search(
			@ModelAttribute AccountCodePurposeGetRequest accountCodePurposeGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors);  }