public void shouldNotExecuteIfModelAndViewIsNull() throws Exception { // given // when interceptor.postHandle(mockRequest, mockResponse, mockHandlerMethod, null); // then verifyZeroInteractions(mockMetaFormatter, mockCombinatorStrategy); }
public void shouldNotExecuteInHeaderMode() throws Exception { // given ModelAndView modelAndView = new ModelAndView("test-view"); interceptor.setMode(RepInterceptor.RepMode.HEADER); // when interceptor.postHandle(mockRequest, mockResponse, mockHandlerMethod, modelAndView); // then assertTrue("Model should be empty", modelAndView.getModel().isEmpty()); verifyZeroInteractions(mockMetaFormatter, mockCombinatorStrategy); }
public void shouldAddModelDataInMetaMode() throws Exception { // given ModelAndView modelAndView = new ModelAndView("test-view"); mockRequest.setAttribute( RepInterceptor.ROBOTS_REQUEST_ATTRIBUTE, Lists.newArrayList(new RobotInfo("ua"))); // when interceptor.postHandle(mockRequest, mockResponse, mockHandlerMethod, modelAndView); // then List<MetaTag> metaTags = ModelAndViewAssert.assertAndReturnModelAttributeOfType( modelAndView, RepInterceptor.ROBOTS_META_TAGS_ATTRIBUTE_NAME, List.class); assertEquals(1, metaTags.size()); assertEquals("meta-name", metaTags.get(0).getName()); assertEquals("meta-content", metaTags.get(0).getContent()); }