@Test public void testSearch() throws IOException, Exception { final ArgumentCaptor<BankBranchGetRequest> argumentCaptor = ArgumentCaptor.forClass(BankBranchGetRequest.class); final ArgumentCaptor<BankBranchContractRequest> argumentCaptor1 = ArgumentCaptor .forClass(BankBranchContractRequest.class); when(bankBranchService.getBankBranches(argumentCaptor.capture())).thenReturn(getBankBranch()); mockMvc.perform(post("/bankbranches/_search?name=bankBranchName") .content(resources.getFileContents("bankbranch/bankBranchContractSearchRequest.json")) .contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()) .andExpect(content().json(resources.getFileContents("bankbranch/bankBranchContractSearchResponse.json"))); verify(bankBranchService).validate(argumentCaptor1.capture(), any(String.class), any(BindingResult.class)); verify(bankBranchService).fetchRelatedContracts(argumentCaptor1.capture()); final BankBranchGetRequest actualRequest = argumentCaptor.getValue(); assertEquals("bankBranchName", actualRequest.getName()); final BankBranchContractRequest 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 BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { final BankBranchContractRequest bankBranchContractRequest = new BankBranchContractRequest(); bankBranchContractRequest.setBankBranchGetRequest(bankBranchGetRequest); bankBranchContractRequest.setRequestInfo(requestInfo); bankBranchService.validate(bankBranchContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchService.fetchRelatedContracts(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranches(new ArrayList<BankBranchContract>()); bankBranchContractResponse.setPage(new Pagination()); List<BankBranchContract> bankBranchContractList = null; bankBranchContractList = bankBranchService.getBankBranches(bankBranchGetRequest); bankBranchContractResponse.getBankBranches().addAll(bankBranchContractList); bankBranchContractResponse.getPage().map(new PageImpl<BankBranchContract>(bankBranchContractList)); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { final BankBranchContractRequest bankBranchContractRequest = new BankBranchContractRequest(); bankBranchContractRequest.setBankBranchGetRequest(bankBranchGetRequest); bankBranchContractRequest.setRequestInfo(requestInfo); bankBranchService.validate(bankBranchContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchService.fetchRelatedContracts(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranches(new ArrayList<BankBranchContract>()); bankBranchContractResponse.setPage(new Pagination()); List<BankBranchContract> bankBranchContractList = null; bankBranchContractList = bankBranchService.getBankBranches(bankBranchGetRequest); bankBranchContractResponse.getBankBranches().addAll(bankBranchContractList); bankBranchContractResponse.getPage().map(new PageImpl<BankBranchContract>(bankBranchContractList)); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; } }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { final BankBranchContractRequest bankBranchContractRequest = new BankBranchContractRequest(); bankBranchContractRequest.setBankBranchGetRequest(bankBranchGetRequest); bankBranchContractRequest.setRequestInfo(requestInfo); bankBranchService.validate(bankBranchContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchService.fetchRelatedContracts(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranches(new ArrayList<BankBranchContract>()); bankBranchContractResponse.setPage(new Pagination()); List<BankBranchContract> bankBranchContractList = null; bankBranchContractList = bankBranchService.getBankBranches(bankBranchGetRequest); bankBranchContractResponse.getBankBranches().addAll(bankBranchContractList); bankBranchContractResponse.getPage().map(new PageImpl<BankBranchContract>(bankBranchContractList)); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }  }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { final BankBranchContractRequest bankBranchContractRequest = new BankBranchContractRequest(); bankBranchContractRequest.setBankBranchGetRequest(bankBranchGetRequest); bankBranchContractRequest.setRequestInfo(requestInfo); bankBranchService.validate(bankBranchContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchService.fetchRelatedContracts(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranches(new ArrayList<BankBranchContract>()); bankBranchContractResponse.setPage(new Pagination()); List<BankBranchContract> bankBranchContractList = null; bankBranchContractList = bankBranchService.getBankBranches(bankBranchGetRequest); bankBranchContractResponse.getBankBranches().addAll(bankBranchContractList); bankBranchContractResponse.getPage().map(new PageImpl<BankBranchContract>(bankBranchContractList)); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse create(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse updateAll(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors); }
BankBranchController { @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) public BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest, @RequestBody RequestInfo requestInfo, BindingResult errors) { final BankBranchContractRequest bankBranchContractRequest = new BankBranchContractRequest(); bankBranchContractRequest.setBankBranchGetRequest(bankBranchGetRequest); bankBranchContractRequest.setRequestInfo(requestInfo); bankBranchService.validate(bankBranchContractRequest, "search", errors); if (errors.hasErrors()) { throw new CustomBindException(errors); } bankBranchService.fetchRelatedContracts(bankBranchContractRequest); BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse(); bankBranchContractResponse.setBankBranches(new ArrayList<BankBranchContract>()); bankBranchContractResponse.setPage(new Pagination()); List<BankBranchContract> bankBranchContractList = null; bankBranchContractList = bankBranchService.getBankBranches(bankBranchGetRequest); bankBranchContractResponse.getBankBranches().addAll(bankBranchContractList); bankBranchContractResponse.getPage().map(new PageImpl<BankBranchContract>(bankBranchContractList)); bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo())); bankBranchContractResponse.getResponseInfo().setStatus(HttpStatus.OK.toString()); return bankBranchContractResponse; }  @PostMapping("/_create") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse create(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping(value = "/{uniqueId}/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse update(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors, @PathVariable Long uniqueId); @PostMapping("/_update") @ResponseStatus(HttpStatus.OK) BankBranchContractResponse updateAll(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors); @PostMapping("/_search") @ResponseBody @ResponseStatus(HttpStatus.OK) BankBranchContractResponse search(@ModelAttribute BankBranchGetRequest bankBranchGetRequest,
			@RequestBody RequestInfo requestInfo, BindingResult errors);  }