|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.test.web.ModelAndViewAssert
public abstract class ModelAndViewAssert
A collection of assertions intended to simplify testing scenarios
dealing with Spring Web MVC
ModelAndView
objects.
Intended for use with JUnit 4 and TestNG.
All assert*()
methods throw AssertionError
s.
ModelAndView
Constructor Summary | |
---|---|
ModelAndViewAssert()
|
Method Summary | |
---|---|
static java.lang.Object |
assertAndReturnModelAttributeOfType(ModelAndView mav,
java.lang.Object modelName,
java.lang.Class expectedType)
Checks whether the model value under the given modelName
exists and checks it type, based on the expectedType . |
static void |
assertCompareListModelAttribute(ModelAndView mav,
java.lang.Object modelName,
java.util.List expectedList)
Compare each individual entry in a list, without first sorting the lists. |
static void |
assertModelAttributeAvailable(ModelAndView mav,
java.lang.Object modelName)
Assert whether or not a model attribute is available. |
static void |
assertModelAttributeValue(ModelAndView mav,
java.lang.Object modelName,
java.lang.Object expectedValue)
Compare a given expectedValue to the value from the model
bound under the given modelName . |
static void |
assertModelAttributeValues(ModelAndView mav,
java.util.Map expectedModel)
Inspect the expectedModel to see if all elements in the
model appear and are equal. |
static void |
assertSortAndCompareListModelAttribute(ModelAndView mav,
java.lang.Object modelName,
java.util.List expectedList,
java.util.Comparator comparator)
Compare each individual entry in a list after having sorted both lists (optionally using a comparator). |
static void |
assertViewName(ModelAndView mav,
java.lang.String expectedName)
Check to see if the view name in the ModelAndView matches the given expectedName . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ModelAndViewAssert()
Method Detail |
---|
public static java.lang.Object assertAndReturnModelAttributeOfType(ModelAndView mav, java.lang.Object modelName, java.lang.Class expectedType) throws java.lang.AssertionError
modelName
exists and checks it type, based on the expectedType
. If
the model entry exists and the type matches, the model value is returned.
mav
- ModelAndView to test against (never null
)modelName
- name of the object to add to the model (never
null
)expectedType
- expected type of the model value
java.lang.AssertionError
public static void assertCompareListModelAttribute(ModelAndView mav, java.lang.Object modelName, java.util.List expectedList) throws java.lang.AssertionError
mav
- ModelAndView to test against (never null
)modelName
- name of the object to add to the model (never
null
)expectedList
- the expected list
java.lang.AssertionError
public static void assertModelAttributeAvailable(ModelAndView mav, java.lang.Object modelName) throws java.lang.AssertionError
mav
- ModelAndView to test against (never null
)modelName
- name of the object to add to the model (never
null
)
java.lang.AssertionError
public static void assertModelAttributeValue(ModelAndView mav, java.lang.Object modelName, java.lang.Object expectedValue) throws java.lang.AssertionError
expectedValue
to the value from the model
bound under the given modelName
.
mav
- ModelAndView to test against (never null
)modelName
- name of the object to add to the model (never
null
)expectedValue
- the model value
java.lang.AssertionError
public static void assertModelAttributeValues(ModelAndView mav, java.util.Map expectedModel) throws java.lang.AssertionError
expectedModel
to see if all elements in the
model appear and are equal.
mav
- ModelAndView to test against (never null
)expectedModel
- the expected model
java.lang.AssertionError
public static void assertSortAndCompareListModelAttribute(ModelAndView mav, java.lang.Object modelName, java.util.List expectedList, java.util.Comparator comparator) throws java.lang.AssertionError
mav
- ModelAndView to test against (never null
)modelName
- name of the object to add to the model (never
null
)expectedList
- the expected listcomparator
- the comparator to use (may be null
). If
not specifying the comparator, both lists will be sorted not using
any comparator.
java.lang.AssertionError
public static void assertViewName(ModelAndView mav, java.lang.String expectedName) throws java.lang.AssertionError
expectedName
.
mav
- ModelAndView to test against (never null
)expectedName
- the name of the model value
java.lang.AssertionError
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |