@Test public void shouldThreatViewURIAsAjax() { final HttpServletRequest request = mockery.mock(HttpServletRequest.class); mockery.checking( new Expectations() { { allowing(request).getRequestURI(); will(returnValue("somethig.ajax.logic")); } }); DefaultComponentInfoProvider info = new DefaultComponentInfoProvider(request); assertThat(info.isAjax(), is(equalTo(true))); mockery.assertIsSatisfied(); }
@Test public void shouldNormalURIAsNotAjax() { final HttpServletRequest request = mockery.mock(HttpServletRequest.class); mockery.checking( new Expectations() { { allowing(request).getRequestURI(); will(returnValue("somethig.non-ajax.logic")); allowing(request).getParameter("view"); will(returnValue("xml")); } }); DefaultComponentInfoProvider info = new DefaultComponentInfoProvider(request); assertThat(info.isAjax(), is(equalTo(false))); mockery.assertIsSatisfied(); }