### Question:
BufferedBulk extends Bulk { public void completed() { for (BulkableAction bulkableAction : actions) { ((BufferedIndex)bulkableAction).release(); } actions.clear(); bulkSource.release(); } BufferedBulk(BufferedBulk.Builder builder); BufferedBulkResult deserializeResponse(InputStream responseBody); ByteBuf serializeRequest(); String getURI(); void completed(); Collection<BulkableAction> getActions(); static final char LINE_SEPARATOR; }### Answer:
@Test public void callingCompletedReleasesBulkItemSource() { BufferedBulk.Builder builder = createDefaultTestMockedBuilder(); ByteBufItemSource buffer = mock(ByteBufItemSource.class); builder.withBuffer(buffer); BufferedBulk bulk = builder.build(); bulk.completed(); verify(buffer).release(); }
@Test public void callingCompletedReleasesActions() { BufferedBulk.Builder builder = createDefaultTestMockedBuilder(); ByteBufItemSource buffer = mock(ByteBufItemSource.class); builder.withBuffer(buffer); BufferedBulk bulk = builder.build(); List<BulkableAction> actions = new ArrayList<>(); BufferedIndex bufferedIndex = spy(new BufferedIndex.Builder(mock(ByteBufItemSource.class)).build()); actions.add(bufferedIndex); builder.addAction(actions); bulk.completed(); verify(bufferedIndex).release(); }