@Test public void methodArgumentNotValid() { Exception ex = Mockito.mock(MethodArgumentNotValidException.class); testException(ex); }
@Test public void bindException() { Exception ex = new BindException(new Object(), "name"); testException(ex); }
@Test public void conversionNotSupported() { Exception ex = new ConversionNotSupportedException(new Object(), Object.class, null); testException(ex); }
@Test public void httpMessageNotWritable() { Exception ex = new HttpMessageNotWritableException(""); testException(ex); }
@Test public void missingServletRequestPart() { Exception ex = new MissingServletRequestPartException("partName"); testException(ex); }
@Test public void typeMismatch() { Exception ex = new TypeMismatchException("foo", String.class); testException(ex); }
@Test public void missingServletRequestParameter() { Exception ex = new MissingServletRequestParameterException("param", "type"); testException(ex); }
@Test public void servletRequestBindingException() { Exception ex = new ServletRequestBindingException("message"); testException(ex); }
@Test public void httpMessageNotReadable() { Exception ex = new HttpMessageNotReadableException("message"); testException(ex); }
@Test public void httpMediaTypeNotAcceptable() { Exception ex = new HttpMediaTypeNotAcceptableException(""); testException(ex); }
@Test public void missingPathVariable() throws NoSuchMethodException { Method method = getClass().getDeclaredMethod("handle", String.class); MethodParameter parameter = new MethodParameter(method, 0); Exception ex = new MissingPathVariableException("param", parameter); testException(ex); }
@Test public void asyncRequestTimeoutException() { testException(new AsyncRequestTimeoutException()); }
@Test public void httpRequestMethodNotSupported() { List<String> supported = Arrays.asList("POST", "DELETE"); Exception ex = new HttpRequestMethodNotSupportedException("GET", supported); ResponseEntity<Object> responseEntity = testException(ex); assertEquals(EnumSet.of(HttpMethod.POST, HttpMethod.DELETE), responseEntity.getHeaders().getAllow()); }
@Test public void handleHttpMediaTypeNotSupported() { List<MediaType> acceptable = Arrays.asList(MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_XML); Exception ex = new HttpMediaTypeNotSupportedException(MediaType.APPLICATION_JSON, acceptable); ResponseEntity<Object> responseEntity = testException(ex); assertEquals(acceptable, responseEntity.getHeaders().getAccept()); }
@Test public void noHandlerFoundException() { ServletServerHttpRequest req = new ServletServerHttpRequest( new MockHttpServletRequest("GET","/resource")); Exception ex = new NoHandlerFoundException(req.getMethod().toString(), req.getServletRequest().getRequestURI(),req.getHeaders()); testException(ex); }