@Test public void runWithIoExceptionDispatchRetry() { Action action = mockAction(URI_KEY_1, URI_1); BitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, stats, action, null, new IOException()); hunter.run(); verify(dispatcher).dispatchRetry(hunter); }
@Test public void runWithNoResultDispatchFailed() { Action action = mockAction(URI_KEY_1, URI_1); BitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, stats, action); hunter.run(); verify(dispatcher).dispatchFailed(hunter); }
@Test public void runWithResultDispatchComplete() { Action action = mockAction(URI_KEY_1, URI_1); BitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, stats, action, bitmap); hunter.run(); verify(dispatcher).dispatchComplete(hunter); }
@Test public void nullDecodeResponseIsError() { Action action = mockAction(URI_KEY_1, URI_1); BitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, stats, action, null); hunter.run(); verify(dispatcher).dispatchFailed(hunter); }
@Test public void outOfMemoryDispatchFailed() { Action action = mockAction(URI_KEY_1, URI_1); BitmapHunter hunter = new OOMBitmapHunter(picasso, dispatcher, cache, stats, action); hunter.run(); Exception exception = hunter.getException(); verify(dispatcher).dispatchFailed(hunter); assertThat(hunter.getResult()).isNull(); assertThat(exception).hasMessageThat().contains("BEGIN PICASSO STATS"); assertThat(exception.getCause()).isInstanceOf(OutOfMemoryError.class); }
@Test public void responseExceptionDispatchFailed() { Action action = mockAction(URI_KEY_1, URI_1); BitmapHunter hunter = new TestableBitmapHunter(picasso, dispatcher, cache, stats, action, null, new NetworkRequestHandler.ResponseException(504, 0)); hunter.run(); verify(dispatcher).dispatchFailed(hunter); }