类 ModelAndViewAssert
java.lang.Object
cn.taketoday.test.web.ModelAndViewAssert
A collection of assertions intended to simplify testing scenarios dealing
with Infra Web MVC
ModelAndView objects.
Intended for use with JUnit 4 and TestNG. All assert*() methods
throw AssertionErrors.
- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen, Alef Arendsen, Bram Smeets
- 另请参阅:
-
ModelAndView
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private static voidappendNonMatchingSetsErrorMessage(Set<String> assertionSet, Set<String> incorrectSet, StringBuilder sb) static <T> TassertAndReturnModelAttributeOfType(cn.taketoday.web.view.ModelAndView mav, String modelName, Class<T> expectedType) Checks whether the model value under the givenmodelNameexists and checks it type, based on theexpectedType.static voidassertCompareListModelAttribute(cn.taketoday.web.view.ModelAndView mav, String modelName, List expectedList) Compare each individual entry in a list, without first sorting the lists.static voidassertModelAttributeAvailable(cn.taketoday.web.view.ModelAndView mav, String modelName) Assert whether or not a model attribute is available.static voidassertModelAttributeValue(cn.taketoday.web.view.ModelAndView mav, String modelName, Object expectedValue) Compare a givenexpectedValueto the value from the model bound under the givenmodelName.static voidassertModelAttributeValues(cn.taketoday.web.view.ModelAndView mav, Map<String, Object> expectedModel) Inspect theexpectedModelto see if all elements in the model appear and are equal.static voidassertSortAndCompareListModelAttribute(cn.taketoday.web.view.ModelAndView mav, String modelName, List expectedList, Comparator comparator) Compare each individual entry in a list after having sorted both lists (optionally using a comparator).static voidassertViewName(cn.taketoday.web.view.ModelAndView mav, String expectedName) Check to see if the view name in the ModelAndView matches the givenexpectedName.
-
构造器详细资料
-
ModelAndViewAssert
public ModelAndViewAssert()
-
-
方法详细资料
-
assertAndReturnModelAttributeOfType
public static <T> T assertAndReturnModelAttributeOfType(cn.taketoday.web.view.ModelAndView mav, String modelName, Class<T> expectedType) Checks whether the model value under the givenmodelNameexists and checks it type, based on theexpectedType. If the model entry exists and the type matches, the model value is returned.- 参数:
mav- the ModelAndView to test against (nevernull)modelName- name of the object to add to the model (nevernull)expectedType- expected type of the model value- 返回:
- the model value
-
assertCompareListModelAttribute
public static void assertCompareListModelAttribute(cn.taketoday.web.view.ModelAndView mav, String modelName, List expectedList) Compare each individual entry in a list, without first sorting the lists.- 参数:
mav- the ModelAndView to test against (nevernull)modelName- name of the object to add to the model (nevernull)expectedList- the expected list
-
assertModelAttributeAvailable
public static void assertModelAttributeAvailable(cn.taketoday.web.view.ModelAndView mav, String modelName) Assert whether or not a model attribute is available.- 参数:
mav- the ModelAndView to test against (nevernull)modelName- name of the object to add to the model (nevernull)
-
assertModelAttributeValue
public static void assertModelAttributeValue(cn.taketoday.web.view.ModelAndView mav, String modelName, Object expectedValue) Compare a givenexpectedValueto the value from the model bound under the givenmodelName.- 参数:
mav- the ModelAndView to test against (nevernull)modelName- name of the object to add to the model (nevernull)expectedValue- the model value
-
assertModelAttributeValues
public static void assertModelAttributeValues(cn.taketoday.web.view.ModelAndView mav, Map<String, Object> expectedModel) Inspect theexpectedModelto see if all elements in the model appear and are equal.- 参数:
mav- the ModelAndView to test against (nevernull)expectedModel- the expected model
-
assertSortAndCompareListModelAttribute
public static void assertSortAndCompareListModelAttribute(cn.taketoday.web.view.ModelAndView mav, String modelName, List expectedList, Comparator comparator) Compare each individual entry in a list after having sorted both lists (optionally using a comparator).- 参数:
mav- the ModelAndView to test against (nevernull)modelName- name of the object to add to the model (nevernull)expectedList- the expected listcomparator- the comparator to use (may benull). If not specifying the comparator, both lists will be sorted not using any comparator.
-
assertViewName
Check to see if the view name in the ModelAndView matches the givenexpectedName.- 参数:
mav- the ModelAndView to test against (nevernull)expectedName- the name of the model value
-
appendNonMatchingSetsErrorMessage
private static void appendNonMatchingSetsErrorMessage(Set<String> assertionSet, Set<String> incorrectSet, StringBuilder sb)
-