- @Test(expected = IllegalStateException.class)
- @SuppressWarnings({ "checkstyle:illegalThrows", "checkstyle:avoidHidingCauseException" })
- public void fromWithExceptionTest() throws Throwable {
- try {
- NotificationListenerInvoker.from(TestPrivateInterface.class);
- fail("Expected IllegalAccessException");
- } catch (UncheckedExecutionException e) {
- throw e.getCause();
- }
+ @Test
+ public void fromWithExceptionTest() {
+ final var cause = assertThrows(UncheckedExecutionException.class,
+ () -> NotificationListenerInvoker.from(TestPrivateInterface.class))
+ .getCause();
+ assertThat(cause, instanceOf(IllegalStateException.class));
+ assertThat(cause.getCause(), instanceOf(IllegalAccessException.class));