@Test public void test_should_return_error_response_when_search_is_not_valid() throws Exception { final TokenSearchCriteria searchCriteria = new TokenSearchCriteria("", ""); final InvalidTokenSearchCriteriaException exception = new InvalidTokenSearchCriteriaException(searchCriteria); when(tokenService.search(searchCriteria)).thenThrow(exception); mockMvc.perform(post("/v1/_search").contentType(MediaType.APPLICATION_JSON_UTF8) .content(resources.getFileContents("invalidOtpSearchRequest.json"))) .andExpect(status().isBadRequest()) .andExpect(content().json(resources.getFileContents("invalidOtpSearchResponse.json"))); }
@PostMapping("v1/_search") public OtpResponse search(@RequestBody OtpRequest request) { final Token token = tokenService.search(request.toSearchCriteria()); return new OtpResponse(token); }
OtpController { @PostMapping("v1/_search") public OtpResponse search(@RequestBody OtpRequest request) { final Token token = tokenService.search(request.toSearchCriteria()); return new OtpResponse(token); } }
OtpController { @PostMapping("v1/_search") public OtpResponse search(@RequestBody OtpRequest request) { final Token token = tokenService.search(request.toSearchCriteria()); return new OtpResponse(token); } OtpController(TokenService tokenService); }
OtpController { @PostMapping("v1/_search") public OtpResponse search(@RequestBody OtpRequest request) { final Token token = tokenService.search(request.toSearchCriteria()); return new OtpResponse(token); } OtpController(TokenService tokenService); @PostMapping("v1/_create") @ResponseStatus(HttpStatus.CREATED) OtpResponse createOtp(@RequestBody OtpRequest otpRequest); @PostMapping("v1/_validate") OtpResponse validateOtp(@RequestBody OtpValidateRequest request); @PostMapping("v1/_search") OtpResponse search(@RequestBody OtpRequest request); }
OtpController { @PostMapping("v1/_search") public OtpResponse search(@RequestBody OtpRequest request) { final Token token = tokenService.search(request.toSearchCriteria()); return new OtpResponse(token); } OtpController(TokenService tokenService); @PostMapping("v1/_create") @ResponseStatus(HttpStatus.CREATED) OtpResponse createOtp(@RequestBody OtpRequest otpRequest); @PostMapping("v1/_validate") OtpResponse validateOtp(@RequestBody OtpValidateRequest request); @PostMapping("v1/_search") OtpResponse search(@RequestBody OtpRequest request);  }