### Question:
BatchRequest implements Request { public void completed() { for (IndexRequest indexRequest : indexRequests) { indexRequest.release(); } indexRequests.clear(); buffer.release(); buffer = null; } protected  BatchRequest(Builder builder); ItemSource serialize(); void completed(); Collection<IndexRequest> getIndexRequests(); @Override String getURI(); @Override String getHttpMethodName(); static final String HTTP_METHOD_NAME; static final char LINE_SEPARATOR; }### Answer:
@Test public void callingCompletedReleasesItemSource() { BatchRequest.Builder builder = createDefaultTestObjectBuilder(); ByteBufItemSource buffer = mock(ByteBufItemSource.class); builder.withBuffer(buffer); BatchRequest request = builder.build(); request.completed(); verify(buffer).release(); }
@Test public void callingCompletedReleasesActions() { BatchRequest.Builder builder = createDefaultTestObjectBuilder(); ByteBufItemSource buffer = mock(ByteBufItemSource.class); builder.withBuffer(buffer); BatchRequest request = builder.build(); Collection<IndexRequest> actions = new ArrayList<>(); IndexRequest indexRequest = spy(createIndexRequestBuilder(mock(ByteBufItemSource.class)) .build()); actions.add(indexRequest); builder.add(actions); request.completed(); verify(indexRequest).release(); }