### Question:
FailedWorkRecycler implements FailureConsumer<W> { @Override public void accept(W work, Throwable error) { if (isRecyclable(work, error)) { R recycled = recycle(work, error); hookOnRecycle(work, recycled, error); recycleConsumer.accept(recycled); } else { hookOnDrop(work, error); } } FailedWorkRecycler(WorkRecycleConfig config, Consumer<? super R> recycleConsumer); @Override void accept(W work, Throwable error);  }### Answer:
@Test public void failedWorkIsNotRecycledIfExpired() { TestWork work = TestWork.create(WorkType.INTENT, "SOME/URL", Instant.now().minus(RECYCLE_CONFIG.getRecycleExpiration()).minusMillis(1).toEpochMilli()); recycler.accept(work, new RuntimeException()); assertNull(recycleHolder.get()); }
@Test public void failedWorkIsRecycledUntilMaxCountIsReached() { TestWork work = TestWork.create(WorkType.INTENT, "SOME/URL", Instant.now().toEpochMilli()); for (long recycleCount = 0; recycleCount <= RECYCLE_CONFIG.getMaxRecycleCount(); recycleCount++) { recycler.accept(work, new RuntimeException()); assertNotNull(recycleHolder.get()); work = recycleHolder.get(); } recycleHolder.set(null); recycler.accept(work, new RuntimeException()); assertNull(recycleHolder.get()); }
@Test public void failedWorkIsNotRecycledForUnrecyclableException() { TestWork work = TestWork.create(WorkType.INTENT, "SOME/URL", Instant.now().toEpochMilli()); recycler.accept(work, new IllegalStateException()); assertNull(recycleHolder.get()); recycler.accept(work, new RuntimeException()); assertNotNull(recycleHolder.get()); }