@Test public void testToResponseWithUnhandledRepositoryException() { when(mockProviders.getExceptionMapper(Exception.class)).thenReturn(null); final Exception cause = new Exception("xyz"); final RepositoryRuntimeException ex = new RepositoryRuntimeException(cause); final Response response = testObj.toResponse(ex); assertEquals(500, response.getStatus()); }
@Test public void testToResponseWithHandledRepositoryException() { when(mockProviders.getExceptionMapper(RepositoryException.class)).thenReturn(mockProvider); final RepositoryException cause = new RepositoryException("xyz"); final RepositoryRuntimeException ex = new RepositoryRuntimeException(cause); testObj.toResponse(ex); verify(mockProvider).toResponse(cause); }