@SuppressWarnings("unchecked") public void testSubmitRunsFallbackCreateOnGet() throws Exception { IllegalStateException exception = new IllegalStateException(); expect(http.submit(new HttpCommand(getRequest))).andReturn( Futures.<HttpResponse> immediateFailedFuture(exception)); expect(fallback.create(exception)).andReturn(Futures.<HttpResponse> immediateFuture(fallbackResponse)); // not using the field, as you can see above we are making an immediate // failed future instead. future = createMock(ListenableFuture.class); replay(http, timeLimiter, fallback, config, future); assertEquals(ListenableFuture.class.cast(invokeHttpMethod.apply(asyncGet)).get(), fallbackResponse); } }