AcmeLazyLoadingException extends RuntimeException { public AcmeLazyLoadingException(AcmeResource resource, AcmeException cause) { this(requireNonNull(resource).getClass(), requireNonNull(resource).getLocation(), cause); } AcmeLazyLoadingException(AcmeResource resource, AcmeException cause);  AcmeLazyLoadingException(Class<? extends AcmeResource> type, URL location, AcmeException cause); Class<? extends AcmeResource> getType(); URL getLocation();  }
@Test public void testAcmeLazyLoadingException() { Login login = mock(Login.class); AcmeResource resource = new TestResource(login, resourceUrl); AcmeException cause = new AcmeException("Something went wrong"); AcmeLazyLoadingException ex = new AcmeLazyLoadingException(resource, cause); assertThat(ex, is(instanceOf(RuntimeException.class))); assertThat(ex.getMessage(), containsString(resourceUrl.toString())); assertThat(ex.getMessage(), containsString(TestResource.class.getSimpleName())); assertThat(ex.getCause(), is((Throwable) cause)); assertThat(ex.getType(), is(equalTo(TestResource.class))); assertThat(ex.getLocation(), is(resourceUrl)); }