public class HandlerResultMatchers extends Object
An instance of this class is typically accessed via
MockMvcResultMatchers.handler()
.
Note: Expectations that assert the controller method
used to process the request work only for requests processed with
RequestMappingHandlerMapping
and RequestMappingHandlerAdapter
which is used by default with the Spring MVC Java config and XML namespace.
Modifier | Constructor and Description |
---|---|
protected |
HandlerResultMatchers()
Protected constructor.
|
Modifier and Type | Method and Description |
---|---|
ResultMatcher |
handlerType(Class<?> type)
Assert the type of the handler that processed the request.
|
ResultMatcher |
method(Method method)
Assert the controller method used to process the request.
|
ResultMatcher |
methodCall(Object info)
Assert the controller method used to process the request.
|
ResultMatcher |
methodName(org.hamcrest.Matcher<? super String> matcher)
Assert the name of the controller method used to process the request
using the given Hamcrest
Matcher . |
ResultMatcher |
methodName(String name)
Assert the name of the controller method used to process the request.
|
protected HandlerResultMatchers()
MockMvcResultMatchers.handler()
.public ResultMatcher handlerType(Class<?> type)
public ResultMatcher methodCall(Object info)
MvcUriComponentsBuilder.fromMethodCall(Object)
.
For example given this controller:
@RestController static class SimpleController { @RequestMapping("/") public ResponseEntityhandle() { return ResponseEntity.ok().build(); } }
A test can be performed:
mockMvc.perform(get("/")) .andExpect(handler().methodCall(on(SimpleController.class).handle()));
public ResultMatcher methodName(org.hamcrest.Matcher<? super String> matcher)
Matcher
.public ResultMatcher methodName(String name)
public ResultMatcher method(Method method)