RunnerRequestCallback extends RequestCallback<T> { @Override public void onFailure(Throwable exception) { if (failureCallback != null) { failureCallback.onFailure(exception); return; } notificationManager.showError(exception.getMessage()); } RunnerRequestCallback(@NotNull NotificationManager notificationManager,
                                 @Nullable Unmarshallable<T> unmarshallable,
                                 @NotNull SuccessCallback<T> successCallback,
                                 @Nullable FailureCallback failureCallback); @Override void onSuccess(T result); @Override void onFailure(Throwable exception);  }
@Test public void failureCallBackShouldBeDoneWhenFailureIsNotNull() throws Exception { requestCallback.onFailure(throwable); verify(failureCallback).onFailure(throwable); verify(notificationManager, never()).showError(anyString()); }
@Test public void failureCallBackShouldBeDoneWhenFailureIsNull() throws Exception { when(throwable.getMessage()).thenReturn(SOME_TEXT); RunnerRequestCallback<Object> requestCallback = new RunnerRequestCallback<>(notificationManager, unmarshaller, successCallback, null); requestCallback.onFailure(throwable); verify(failureCallback, never()).onFailure(throwable); verify(notificationManager).showError(SOME_TEXT); }