NotificationListenerInvoker { @SuppressWarnings("checkstyle:illegalCatch") public void invokeNotification(final @NonNull NotificationListener impl, final @NonNull QName rpcName, final @Nullable DataContainer input) { requireNonNull(impl, "implemetation must be supplied"); final MethodHandle invoker = methodInvokers.get(rpcName); checkArgument(invoker != null, "Supplied notification is not valid for implementation %s", impl); try { invoker.invokeExact(impl, input); } catch (final Throwable e) { Throwables.throwIfUnchecked(e); throw new IllegalStateException(e); } } NotificationListenerInvoker(final ImmutableMap<QName, MethodHandle> map); static NotificationListenerInvoker from(final Class<? extends NotificationListener> type); @SuppressWarnings("checkstyle:illegalCatch") void invokeNotification(final @NonNull NotificationListener impl, final @NonNull QName rpcName,
            final @Nullable DataContainer input);  }
@Test(expected = WrongMethodTypeException.class) public void invokeNotification() throws Exception { final NotificationListener notificationListener = mock(NotificationListener.class); final MethodHandle methodHandle = mock(MethodHandle.class); final NotificationListenerInvoker notificationListenerInvoker = new NotificationListenerInvoker(ImmutableMap.of(QName.create("test", "test"), methodHandle)); notificationListenerInvoker.invokeNotification(notificationListener, QName.create("test", "test"), null); fail("Expected WrongMethodTypeException, no method to invoke is supplied"); }