### Question:
SharedWritePipe implements WritePipe<T> { @Override public void close() { if (remainingClosesRequired.decrementAndGet() == 0) { delegate.close(); } } SharedWritePipe(final WritePipe<T> delegate, final int closesRequired); @Override boolean isOpen(); @Override void put(final T value); @Override void close(); @Override void abort(); @Override boolean hasRemainingCapacity();  }### Answer:
@Test public void shouldOnlyCloseDelegatePipeWhenCloseCalledSpecifiedNumberOfTimes() { for (int i = 0; i < CLOSES_REQUIRED - 1; i++) { pipe.close(); verifyZeroInteractions(delegate); } pipe.close(); verify(delegate).close(); }