### Question:
BufferedHttpFailedItemOps implements FailedItemOps<AbstractDocumentTargetedAction<DocumentResult>> { @Override public FailedItemSource createItem(AbstractDocumentTargetedAction<DocumentResult> failed) { BufferedIndex failedRequest = (BufferedIndex) failed; if (failedRequest.getSource() instanceof FailedItemSource) { LOG.trace("Reusing {}", FailedItemSource.class.getSimpleName()); return (FailedItemSource) failedRequest.getSource(); } return new FailedItemSource<>(failedRequest.getSource(), createInfo(failed)); }  @Override FailedItemSource createItem(AbstractDocumentTargetedAction<DocumentResult> failed); @Override FailedItemInfo createInfo(
            AbstractDocumentTargetedAction<DocumentResult> failed
    );  }### Answer:
@Test public void createsFailedItemSourceFromGivenRequest() { BufferedHttpFailedItemOps failedItemOps = new BufferedHttpFailedItemOps(); ItemSource<ByteBuf> itemSource = mock(ItemSource.class); ByteBuf expectedSource = mock(ByteBuf.class); when(itemSource.getSource()).thenReturn(expectedSource); String expectedIndex = UUID.randomUUID().toString(); AbstractDocumentTargetedAction request = createDefaultTestIndexRequest(itemSource, expectedIndex); FailedItemSource result = failedItemOps.createItem(request); assertEquals(expectedSource, result.getSource()); assertEquals(expectedIndex, result.getInfo().getTargetName()); }
@Test public void canReuseFailedItemSourceFromGivenRequest() { BufferedHttpFailedItemOps failedItemOps = new BufferedHttpFailedItemOps(); FailedItemSource<ByteBuf> itemSource = mock(FailedItemSource.class); AbstractDocumentTargetedAction request = createDefaultTestIndexRequest( itemSource, UUID.randomUUID().toString() ); FailedItemSource result = failedItemOps.createItem(request); assertSame(itemSource, result); }