SendablePluginBaseException extends PluginBaseException { public void sendException(@NotNull final Messager messager, @NotNull final MessageReceiver receiver) { messager.message(receiver, getBundledMessage()); final PluginBaseException cause = getCauseException(); final Throwable throwable = getCause(); if (cause != null) { sendCauseException(cause, messager, receiver); } else if (throwable != null) { sendCauseException(throwable, messager, receiver); } } SendablePluginBaseException(@NotNull final BundledMessage languageMessage);  SendablePluginBaseException(@NotNull final String message);  SendablePluginBaseException(@NotNull final BundledMessage languageMessage, @NotNull final Throwable throwable);  SendablePluginBaseException(@NotNull final String message, @NotNull final Throwable throwable);  SendablePluginBaseException(@NotNull final BundledMessage languageMessage, @NotNull final PluginBaseException cause);  SendablePluginBaseException(@NotNull final String message, @NotNull final PluginBaseException cause);  SendablePluginBaseException(@NotNull final PluginBaseException e); void sendException(@NotNull final Messager messager, @NotNull final MessageReceiver receiver); @NotNull @Override String toString();  }
@Test public void testSendException() throws Exception { SendablePluginBaseException e4 = new SendablePluginBaseException(TEST_4); Throwable e3 = new SendablePluginBaseException(TEST_3, e4); PluginBaseException e2 = new SendablePluginBaseException(TEST_2, e3); Throwable throwable = new Throwable("intermission", e2); SendablePluginBaseException e1 = new SendablePluginBaseException(TEST_1, throwable); doAnswer(new Answer<Void>() { @Override public Void answer(final InvocationOnMock invocation) throws Throwable { final BundledMessage b = (BundledMessage) invocation.getArguments()[1]; messager.message((MessageReceiver) invocation.getArguments()[0], b.getMessage(), b.getArgs()); if (b.equals(TEST_4)) { e4Sent = true; } else if (b.equals(TEST_3)) { e3Sent = true; } else if (b.equals(TEST_2)) { e2Sent = true; } else if (b.equals(TEST_1)) { e1Sent = true; } else if (b.getMessage().equals(Messages.CAUSE_EXCEPTION)) { Object o = b.getArgs()[0]; if (o.equals(TEST_4.getMessage().getDefault())) { e4Sent = true; } else if (o.equals(TEST_3.getMessage().getDefault())) { e3Sent = true; } else if (o.equals(TEST_2.getMessage().getDefault())) { e2Sent = true; } else if (o.equals(TEST_1.getMessage().getDefault())) { e1Sent = true; } } return null; } }).when(messager).message(any(MessageReceiver.class), any(BundledMessage.class)); e1.sendException(messager, receiver); assertTrue(e1Sent); assertTrue(e2Sent); assertTrue(e3Sent); assertTrue(e4Sent); }