/** Test when the exception is found. */ @Test public void withRootException() { final Exception e = new IllegalStateException(); when(mapper.findByException(e)).thenReturn(mockRecorder); doThrow(new InterceptionException(e)).when(stack).next(method, instance); interceptor.intercept(stack, method, instance); verify(mockRecorder).replay(result); }
/** Test when the exception is not found, so vraptor needs only rethrows the exception. */ @Test public void whenNotFoundException() { final Exception e = new IllegalArgumentException(); when(mapper.findByException(e)).thenReturn(null); doThrow(new InterceptionException(e)).when(stack).next(method, instance); try { interceptor.intercept(stack, method, instance); fail("Should throw InterceptionException"); } catch (InterceptionException e2) { assertEquals(e2.getCause(), e); } }
@Test public void shouldAlwaysAccept() { assertTrue(interceptor.accepts(null)); }