@Test public void testCallbackOnError() { final Throwable throwable = mock(Throwable.class); final RequestCallback callback = presenter.makeCallback(onSuccess, onError); callback.onError(request, throwable); verify(onError).execute(); verify(onSuccess, never()).execute(); }
RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; }
FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } }
FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } @Inject  FooterPresenter(final View view); }
FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } @Inject  FooterPresenter(final View view); View getView(); void setup(final String url,
                      final String version); }
FooterPresenter { RequestCallback makeCallback(final Command onSuccess, final Command onError) { return new RequestCallback() { public void onResponseReceived(final Request request, final Response response) { if (isKieServerAccessible(response)) { onSuccess.execute(); } else { onError.execute(); } } public void onError(final Request request, final Throwable exception) { onError.execute(); } }; } @Inject  FooterPresenter(final View view); View getView(); void setup(final String url,
                      final String version);  }