org.springframework.web.servlet.ModelAndView - java examples

Here are the examples of the java api org.springframework.web.servlet.ModelAndView taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : MappedInterceptor.java
Copyright Apache License 2.0
Author : langtianya
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    this.interceptor.postHandle(request, response, handler, modelAndView);
}

19 View Complete Implementation : ModelResultMatchers.java
Copyright Apache License 2.0
Author : langtianya
private BindingResult getBindingResult(ModelAndView mav, String name) {
    BindingResult result = (BindingResult) mav.getModel().get(BindingResult.MODEL_KEY_PREFIX + name);
    replacedertTrue("No BindingResult for attribute: " + name, result != null);
    return result;
}

19 View Complete Implementation : ModelAndViewAssert.java
Copyright Apache License 2.0
Author : langtianya
/**
 * Compare a given {@code expectedValue} to the value from the model
 * bound under the given {@code modelName}.
 *
 * @param mav ModelAndView to test against (never {@code null})
 * @param modelName name of the object to add to the model (never
 * {@code null})
 * @param expectedValue the model value
 */
public static void replacedertModelAttributeValue(ModelAndView mav, String modelName, Object expectedValue) {
    replacedertTrue("ModelAndView is null", mav != null);
    Object modelValue = replacedertAndReturnModelAttributeOfType(mav, modelName, Object.clreplaced);
    replacedertTrue("Model value with name '" + modelName + "' is not the same as the expected value which was '" + expectedValue + "'", modelValue.equals(expectedValue));
}

19 View Complete Implementation : StubMvcResult.java
Copyright Apache License 2.0
Author : langtianya
public void setMav(ModelAndView mav) {
    this.mav = mav;
}

19 View Complete Implementation : StubMvcResult.java
Copyright MIT License
Author : codeEngraver
public void setMav(ModelAndView mav) {
    this.mav = mav;
}

19 View Complete Implementation : HandlerInterceptorAdapter.java
Copyright MIT License
Author : codeEngraver
/**
 * This implementation is empty.
 */
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright Apache License 2.0
Author : langtianya
@Test
public void statusOnly() throws Exception {
    this.controller.setStatusCode(HttpStatus.NOT_FOUND);
    this.controller.setStatusOnly(true);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertNull(modelAndView);
    replacedertEquals(404, this.response.getStatus());
}

19 View Complete Implementation : ModelResultMatchers.java
Copyright MIT License
Author : codeEngraver
/**
 * replacedert the given model attributes do not exist.
 */
public ResultMatcher attributeDoesNotExist(final String... names) {
    return result -> {
        ModelAndView mav = getModelAndView(result);
        for (String name : names) {
            replacedertTrue("Model attribute '" + name + "' exists", mav.getModel().get(name) == null);
        }
    };
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright Apache License 2.0
Author : langtianya
@Test
public void redirectStatus() throws Exception {
    this.controller.setStatusCode(HttpStatus.PERMANENT_REDIRECT);
    this.controller.setViewName("/foo");
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("redirect:/foo", modelAndView.getViewName());
    replacedertEquals("3xx status should be left to RedirectView to set", 200, this.response.getStatus());
    replacedertEquals(HttpStatus.PERMANENT_REDIRECT, this.request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE));
}

19 View Complete Implementation : ModelAndViewAssert.java
Copyright Apache License 2.0
Author : langtianya
/**
 * Check to see if the view name in the ModelAndView matches the given
 * {@code expectedName}.
 *
 * @param mav ModelAndView to test against (never {@code null})
 * @param expectedName the name of the model value
 */
public static void replacedertViewName(ModelAndView mav, String expectedName) {
    replacedertTrue("ModelAndView is null", mav != null);
    replacedertTrue("View name is not equal to '" + expectedName + "' but was '" + mav.getViewName() + "'", ObjectUtils.nullSafeEquals(expectedName, mav.getViewName()));
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void statusOnly() throws Exception {
    this.controller.setStatusCode(HttpStatus.NOT_FOUND);
    this.controller.setStatusOnly(true);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertNull(modelAndView);
    replacedertEquals(404, this.response.getStatus());
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void viewName() throws Exception {
    this.controller.setViewName("view");
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("view", modelAndView.getViewName());
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void redirectStatusWithRedirectPrefix() throws Exception {
    this.controller.setStatusCode(HttpStatus.PERMANENT_REDIRECT);
    this.controller.setViewName("redirect:/foo");
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("redirect:/foo", modelAndView.getViewName());
    replacedertEquals("3xx status should be left to RedirectView to set", 200, this.response.getStatus());
    replacedertEquals(HttpStatus.PERMANENT_REDIRECT, this.request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE));
}

19 View Complete Implementation : DefaultMvcResult.java
Copyright Apache License 2.0
Author : langtianya
public void setModelAndView(ModelAndView mav) {
    this.modelAndView = mav;
}

19 View Complete Implementation : ViewResultMatchers.java
Copyright MIT License
Author : codeEngraver
/**
 * replacedert the selected view name with the given Hamcrest {@link Matcher}.
 */
public ResultMatcher name(final Matcher<? super String> matcher) {
    return result -> {
        ModelAndView mav = result.getModelAndView();
        if (mav == null) {
            fail("No ModelAndView found");
        }
        replacedertThat("View name", mav.getViewName(), matcher);
    };
}

19 View Complete Implementation : WebContentInterceptor.java
Copyright Apache License 2.0
Author : langtianya
/**
 * This implementation is empty.
 */
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}

19 View Complete Implementation : ModelAndViewAssert.java
Copyright Apache License 2.0
Author : langtianya
/**
 * Compare each individual entry in a list after having sorted both lists
 * (optionally using a comparator).
 *
 * @param mav ModelAndView to test against (never {@code null})
 * @param modelName name of the object to add to the model (never
 * {@code null})
 * @param expectedList the expected list
 * @param comparator the comparator to use (may be {@code null}). If
 * not specifying the comparator, both lists will be sorted not using any
 * comparator.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void replacedertSortAndCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList, Comparator comparator) {
    replacedertTrue("ModelAndView is null", mav != null);
    List modelList = replacedertAndReturnModelAttributeOfType(mav, modelName, List.clreplaced);
    replacedertTrue("Size of model list is '" + modelList.size() + "' while size of expected list is '" + expectedList.size() + "'", expectedList.size() == modelList.size());
    if (comparator != null) {
        Collections.sort(modelList, comparator);
        Collections.sort(expectedList, comparator);
    } else {
        Collections.sort(modelList);
        Collections.sort(expectedList);
    }
    replacedertTrue("List in model under name '" + modelName + "' is not equal to the expected list.", expectedList.equals(modelList));
}

19 View Complete Implementation : HandlerInterceptorAdapter.java
Copyright Apache License 2.0
Author : langtianya
/**
 * This implementation is empty.
 */
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
}

19 View Complete Implementation : ExceptionHandlerExceptionResolverTests.java
Copyright MIT License
Author : codeEngraver
// SPR-14651
@Test
public void resolveRedirectAttributesAtArgument() throws Exception {
    IllegalArgumentException ex = new IllegalArgumentException();
    HandlerMethod handlerMethod = new HandlerMethod(new RedirectAttributesController(), "handle");
    this.resolver.afterPropertiesSet();
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);
    replacedertNotNull(mav);
    replacedertEquals("redirect:/", mav.getViewName());
    FlashMap flashMap = (FlashMap) this.request.getAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE);
    replacedertNotNull("output FlashMap should exist", flashMap);
    replacedertEquals("IllegalArgumentException", flashMap.get("exceptionClreplacedName"));
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright Apache License 2.0
Author : langtianya
@Test
public void redirectStatusWithRedirectPrefix() throws Exception {
    this.controller.setStatusCode(HttpStatus.PERMANENT_REDIRECT);
    this.controller.setViewName("redirect:/foo");
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("redirect:/foo", modelAndView.getViewName());
    replacedertEquals("3xx status should be left to RedirectView to set", 200, this.response.getStatus());
    replacedertEquals(HttpStatus.PERMANENT_REDIRECT, this.request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE));
}

19 View Complete Implementation : WebRequestHandlerInterceptorAdapter.java
Copyright MIT License
Author : codeEngraver
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
    this.requestInterceptor.postHandle(new DispatcherServletWebRequest(request, response), (modelAndView != null && !modelAndView.wasCleared() ? modelAndView.getModelMap() : null));
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void redirectStatus() throws Exception {
    this.controller.setStatusCode(HttpStatus.PERMANENT_REDIRECT);
    this.controller.setViewName("/foo");
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("redirect:/foo", modelAndView.getViewName());
    replacedertEquals("3xx status should be left to RedirectView to set", 200, this.response.getStatus());
    replacedertEquals(HttpStatus.PERMANENT_REDIRECT, this.request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE));
}

19 View Complete Implementation : SimpleMappingExceptionResolver.java
Copyright MIT License
Author : codeEngraver
/**
 * Return a ModelAndView for the given view name and exception.
 * <p>The default implementation adds the specified exception attribute.
 * Can be overridden in subclreplacedes.
 * @param viewName the name of the error view
 * @param ex the exception that got thrown during handler execution
 * @return the ModelAndView instance
 * @see #setExceptionAttribute
 */
protected ModelAndView getModelAndView(String viewName, Exception ex) {
    ModelAndView mv = new ModelAndView(viewName);
    if (this.exceptionAttribute != null) {
        mv.addObject(this.exceptionAttribute, ex);
    }
    return mv;
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void handleRequestHttpOptions() throws Exception {
    this.request.setMethod(HttpMethod.OPTIONS.name());
    MockHttpServletResponse response = new MockHttpServletResponse();
    ModelAndView mav = this.controller.handleRequest(this.request, response);
    replacedertNull(mav);
    replacedertEquals("GET,HEAD,OPTIONS", response.getHeader("Allow"));
}

19 View Complete Implementation : ModelResultMatchersTests.java
Copyright Apache License 2.0
Author : langtianya
@Before
public void setUp() throws Exception {
    this.matchers = new ModelResultMatchers();
    ModelAndView mav = new ModelAndView("view", "good", "good");
    BindingResult bindingResult = new BeanPropertyBindingResult("good", "good");
    mav.addObject(BindingResult.MODEL_KEY_PREFIX + "good", bindingResult);
    this.mvcResult = getMvcResult(mav);
    Date date = new Date();
    BindingResult bindingResultWithError = new BeanPropertyBindingResult(date, "date");
    bindingResultWithError.rejectValue("time", "error");
    ModelAndView mavWithError = new ModelAndView("view", "good", "good");
    mavWithError.addObject("date", date);
    mavWithError.addObject(BindingResult.MODEL_KEY_PREFIX + "date", bindingResultWithError);
    this.mvcResultWithError = getMvcResult(mavWithError);
}

19 View Complete Implementation : ModelResultMatchersTests.java
Copyright MIT License
Author : codeEngraver
private MvcResult getMvcResult(ModelAndView modelAndView) {
    return new StubMvcResult(null, null, null, null, modelAndView, null, null);
}

19 View Complete Implementation : SimpleMappingExceptionResolver.java
Copyright Apache License 2.0
Author : langtianya
/**
 * Return a ModelAndView for the given view name and exception.
 * <p>The default implementation adds the specified exception attribute.
 * Can be overridden in subclreplacedes.
 * @param viewName the name of the error view
 * @param ex the exception that got thrown during handler execution
 * @return the ModelAndView instance
 * @see #setExceptionAttribute
 */
protected ModelAndView getModelAndView(String viewName, Exception ex) {
    ModelAndView mv = new ModelAndView(viewName);
    if (this.exceptionAttribute != null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Exposing Exception as model attribute '" + this.exceptionAttribute + "'");
        }
        mv.addObject(this.exceptionAttribute, ex);
    }
    return mv;
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void defaultViewName() throws Exception {
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertNull(modelAndView.getViewName());
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright Apache License 2.0
Author : langtianya
@Test
public void viewNameAndStatus() throws Exception {
    this.controller.setViewName("view");
    this.controller.setStatusCode(HttpStatus.NOT_FOUND);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("view", modelAndView.getViewName());
    replacedertEquals(404, this.response.getStatus());
}

19 View Complete Implementation : ModelResultMatchersTests.java
Copyright MIT License
Author : codeEngraver
@Before
public void setUp() throws Exception {
    this.matchers = new ModelResultMatchers();
    ModelAndView mav = new ModelAndView("view", "good", "good");
    BindingResult bindingResult = new BeanPropertyBindingResult("good", "good");
    mav.addObject(BindingResult.MODEL_KEY_PREFIX + "good", bindingResult);
    this.mvcResult = getMvcResult(mav);
    Date date = new Date();
    BindingResult bindingResultWithError = new BeanPropertyBindingResult(date, "date");
    bindingResultWithError.rejectValue("time", "error");
    ModelAndView mavWithError = new ModelAndView("view", "good", "good");
    mavWithError.addObject("date", date);
    mavWithError.addObject(BindingResult.MODEL_KEY_PREFIX + "date", bindingResultWithError);
    this.mvcResultWithError = getMvcResult(mavWithError);
}

19 View Complete Implementation : WebRequestHandlerInterceptorAdapter.java
Copyright Apache License 2.0
Author : langtianya
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    this.requestInterceptor.postHandle(new DispatcherServletWebRequest(request, response), (modelAndView != null && !modelAndView.wasCleared() ? modelAndView.getModelMap() : null));
}

19 View Complete Implementation : MappedInterceptor.java
Copyright MIT License
Author : codeEngraver
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
    this.interceptor.postHandle(request, response, handler, modelAndView);
}

19 View Complete Implementation : TestDispatcherServlet.java
Copyright Apache License 2.0
Author : langtianya
@Override
protected ModelAndView processHandlerException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    ModelAndView mav = super.processHandlerException(request, response, handler, ex);
    // We got this far, exception was processed..
    DefaultMvcResult mvcResult = getMvcResult(request);
    mvcResult.setResolvedException(ex);
    mvcResult.setModelAndView(mav);
    return mav;
}

19 View Complete Implementation : ModelAndViewAssert.java
Copyright MIT License
Author : codeEngraver
/**
 * Compare each individual entry in a list after having sorted both lists
 * (optionally using a comparator).
 * @param mav the ModelAndView to test against (never {@code null})
 * @param modelName name of the object to add to the model (never {@code null})
 * @param expectedList the expected list
 * @param comparator the comparator to use (may be {@code null}). If not
 * specifying the comparator, both lists will be sorted not using any comparator.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void replacedertSortAndCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList, Comparator comparator) {
    List modelList = replacedertAndReturnModelAttributeOfType(mav, modelName, List.clreplaced);
    replacedertTrue("Size of model list is '" + modelList.size() + "' while size of expected list is '" + expectedList.size() + "'", expectedList.size() == modelList.size());
    modelList.sort(comparator);
    expectedList.sort(comparator);
    replacedertTrue("List in model under name '" + modelName + "' is not equal to the expected list.", expectedList.equals(modelList));
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright Apache License 2.0
Author : langtianya
@Test
public void viewName() throws Exception {
    this.controller.setViewName("view");
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("view", modelAndView.getViewName());
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void redirectView() throws Exception {
    RedirectView view = new RedirectView("/foo");
    this.controller.setView(view);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertSame(view, modelAndView.getView());
}

19 View Complete Implementation : ModelResultMatchersTests.java
Copyright Apache License 2.0
Author : langtianya
private MvcResult getMvcResult(ModelAndView modelAndView) {
    return new StubMvcResult(null, null, null, null, modelAndView, null, null);
}

19 View Complete Implementation : AbstractHandlerExceptionResolver.java
Copyright MIT License
Author : codeEngraver
/**
 * Check whether this resolver is supposed to apply (i.e. if the supplied handler
 * matches any of the configured {@linkplain #setMappedHandlers handlers} or
 * {@linkplain #setMappedHandlerClreplacedes handler clreplacedes}), and then delegate
 * to the {@link #doResolveException} template method.
 */
@Override
@Nullable
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
    if (shouldApplyTo(request, handler)) {
        prepareResponse(ex, response);
        ModelAndView result = doResolveException(request, response, handler, ex);
        if (result != null) {
            // Print warn message when warn logger is not enabled...
            if (logger.isDebugEnabled() && (this.warnLogger == null || !this.warnLogger.isWarnEnabled())) {
                logger.debug("Resolved [" + ex + "]" + (result.isEmpty() ? "" : " to " + result));
            }
            // warnLogger with full stack trace (requires explicit config)
            logException(ex, request);
        }
        return result;
    } else {
        return null;
    }
}

19 View Complete Implementation : TestDispatcherServlet.java
Copyright Apache License 2.0
Author : langtianya
@Override
protected void render(ModelAndView mv, HttpServletRequest request, HttpServletResponse response) throws Exception {
    DefaultMvcResult mvcResult = getMvcResult(request);
    mvcResult.setModelAndView(mv);
    super.render(mv, request, response);
}

19 View Complete Implementation : HandlerExceptionResolverComposite.java
Copyright Apache License 2.0
Author : langtianya
/**
 * Resolve the exception by iterating over the list of configured exception resolvers.
 * The first one to return a ModelAndView instance wins. Otherwise {@code null} is returned.
 */
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
    if (resolvers != null) {
        for (HandlerExceptionResolver handlerExceptionResolver : resolvers) {
            ModelAndView mav = handlerExceptionResolver.resolveException(request, response, handler, ex);
            if (mav != null) {
                return mav;
            }
        }
    }
    return null;
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright Apache License 2.0
Author : langtianya
@Test
public void viewNameAndStatus204() throws Exception {
    this.controller.setStatusCode(HttpStatus.NO_CONTENT);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertNull(modelAndView);
    replacedertEquals(204, this.response.getStatus());
}

19 View Complete Implementation : ViewResultMatchers.java
Copyright MIT License
Author : codeEngraver
/**
 * replacedert the selected view name.
 */
public ResultMatcher name(final String expectedViewName) {
    return result -> {
        ModelAndView mav = result.getModelAndView();
        if (mav == null) {
            fail("No ModelAndView found");
        }
        replacedertEquals("View name", expectedViewName, mav.getViewName());
    };
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright Apache License 2.0
Author : langtianya
@Test
public void redirectView() throws Exception {
    RedirectView view = new RedirectView("/foo");
    this.controller.setView(view);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertSame(view, modelAndView.getView());
}

19 View Complete Implementation : ModelAndViewAssert.java
Copyright MIT License
Author : codeEngraver
/**
 * Check to see if the view name in the ModelAndView matches the given
 * {@code expectedName}.
 * @param mav the ModelAndView to test against (never {@code null})
 * @param expectedName the name of the model value
 */
public static void replacedertViewName(ModelAndView mav, String expectedName) {
    replacedertTrue("View name is not equal to '" + expectedName + "' but was '" + mav.getViewName() + "'", ObjectUtils.nullSafeEquals(expectedName, mav.getViewName()));
}

19 View Complete Implementation : DefaultMvcResult.java
Copyright MIT License
Author : codeEngraver
public void setModelAndView(@Nullable ModelAndView mav) {
    this.modelAndView = mav;
}

19 View Complete Implementation : ModelResultMatchers.java
Copyright MIT License
Author : codeEngraver
/**
 * replacedert the given model attributes exist.
 */
public ResultMatcher attributeExists(final String... names) {
    return result -> {
        ModelAndView mav = getModelAndView(result);
        for (String name : names) {
            replacedertTrue("Model attribute '" + name + "' does not exist", mav.getModel().get(name) != null);
        }
    };
}

19 View Complete Implementation : HandlerExceptionResolverComposite.java
Copyright MIT License
Author : codeEngraver
/**
 * Resolve the exception by iterating over the list of configured exception resolvers.
 * <p>The first one to return a {@link ModelAndView} wins. Otherwise {@code null}
 * is returned.
 */
@Override
@Nullable
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
    if (this.resolvers != null) {
        for (HandlerExceptionResolver handlerExceptionResolver : this.resolvers) {
            ModelAndView mav = handlerExceptionResolver.resolveException(request, response, handler, ex);
            if (mav != null) {
                return mav;
            }
        }
    }
    return null;
}

19 View Complete Implementation : ModelAndViewAssert.java
Copyright MIT License
Author : codeEngraver
/**
 * Compare a given {@code expectedValue} to the value from the model
 * bound under the given {@code modelName}.
 * @param mav the ModelAndView to test against (never {@code null})
 * @param modelName name of the object to add to the model (never {@code null})
 * @param expectedValue the model value
 */
public static void replacedertModelAttributeValue(ModelAndView mav, String modelName, Object expectedValue) {
    Object modelValue = replacedertAndReturnModelAttributeOfType(mav, modelName, Object.clreplaced);
    replacedertTrue("Model value with name '" + modelName + "' is not the same as the expected value which was '" + expectedValue + "'", modelValue.equals(expectedValue));
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void viewNameAndStatus204() throws Exception {
    this.controller.setStatusCode(HttpStatus.NO_CONTENT);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertNull(modelAndView);
    replacedertEquals(204, this.response.getStatus());
}

19 View Complete Implementation : ParameterizableViewControllerTests.java
Copyright MIT License
Author : codeEngraver
@Test
public void viewNameAndStatus() throws Exception {
    this.controller.setViewName("view");
    this.controller.setStatusCode(HttpStatus.NOT_FOUND);
    ModelAndView modelAndView = this.controller.handleRequest(this.request, this.response);
    replacedertEquals("view", modelAndView.getViewName());
    replacedertEquals(404, this.response.getStatus());
}