Class HandlerResultAssert
java.lang.Object
org.assertj.core.api.AbstractAssert<HandlerResultAssert, Object>
org.assertj.core.api.AbstractObjectAssert<HandlerResultAssert, Object>
org.springframework.test.web.servlet.assertj.HandlerResultAssert
- All Implemented Interfaces:
org.assertj.core.api.Assert<HandlerResultAssert, Object>, org.assertj.core.api.Descriptable<HandlerResultAssert>, org.assertj.core.api.ExtensionPoints<HandlerResultAssert, Object>
public class HandlerResultAssert
extends org.assertj.core.api.AbstractObjectAssert<HandlerResultAssert, Object>
AssertJ assertions that can be applied
to a handler or handler method.
- Since:
- 6.2
- Author:
- Stephane Nicoll
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionVerify that the handler is of the giventype.isInvokedOn(Class<T> controllerType, Function<T, Object> handlerMethod) Verify that the handler is managed by the givenhandlerMethod.Verify that the handler is managed by a method invocation, typically on a controller.method()Methods inherited from class org.assertj.core.api.AbstractObjectAssert
as, as, doesNotReturn, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, getComparatorsByType, hasAllNullFieldsOrProperties, hasAllNullFieldsOrPropertiesExcept, hasFieldOrProperty, hasFieldOrPropertyWithValue, hasNoNullFieldsOrProperties, hasNoNullFieldsOrPropertiesExcept, hasOnlyFields, isEqualToComparingFieldByField, isEqualToComparingFieldByFieldRecursively, isEqualToComparingOnlyGivenFields, isEqualToIgnoringGivenFields, isEqualToIgnoringNullFields, newObjectAssert, returns, usingComparatorForFields, usingComparatorForType, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparisonMethods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingEquals, usingEquals, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, describedAs, describedAs
-
Constructor Details
-
HandlerResultAssert
-
-
Method Details
-
method
Return a new assertion object that uses theMethodthat handles the request as the object to test.Verifies first that the handler is a method handler.
Example:
// Check that a GET to "/greet" is invoked on a "handleGreet" method name assertThat(mvc.perform(get("/greet")).handler().method().hasName("handleGreet"); -
isMethodHandler
Verify that the handler is managed by a method invocation, typically on a controller. -
isInvokedOn
public <T> HandlerResultAssert isInvokedOn(Class<T> controllerType, Function<T, Object> handlerMethod) Verify that the handler is managed by the givenhandlerMethod.This creates a "mock" for the given
controllerTypeand records the method invocation in thehandlerMethod. The arguments used by the target method invocation can benullas the purpose of the mock is to identify the method that was invoked.Example:
// If the method has a return type, you can return the result of the invocation assertThat(mvc.perform(get("/greet")).handler().isInvokedOn( GreetController.class, controller -> controller.sayGreet()); // If the method has a void return type, the controller should be returned assertThat(mvc.perform(post("/persons/")).handler().isInvokedOn( PersonController.class, controller -> controller.createPerson(null, null));- Parameters:
controllerType- the controller to mockhandlerMethod- the method
-
hasType
Verify that the handler is of the giventype. For a controller method, this is the type of the controller.Example:
// Check that a GET to "/greet" is managed by GreetController assertThat(mvc.perform(get("/greet")).handler().hasType(GreetController.class);- Parameters:
type- the expected type of the handler
-