@Override
    public void flush() throws IOException {
        currentTmpFile.write(buffer, 0, positionInBuffer);
        currentTmpFile.flush();
        positionInBuffer = 0;
    }
@Test
    void testFlush() throws IOException {
        RefCountedBufferingFileStream stream = getStreamToTest();

        final byte[] contentToWrite = bytesOf("hello");
        stream.write(contentToWrite);

        assertThat(stream.getPositionInBuffer()).isEqualTo(contentToWrite.length);
        assertThat(stream.getPos()).isEqualTo(contentToWrite.length);

        stream.flush();

        assertThat(stream.getPositionInBuffer()).isZero();
        assertThat(stream.getPos()).isEqualTo(contentToWrite.length);

        final byte[] contentRead = new byte[contentToWrite.length];
        new FileInputStream(stream.getInputFile()).read(contentRead, 0, contentRead.length);
        assertThat(contentRead).isEqualTo(contentToWrite);

        stream.release();
    }