@Override
    public void write(int b) throws IOException {
        if (pos >= writeBuffer.length) {
            flush();
        }
        writeBuffer[pos++] = (byte) b;
    }
@Test
    void testBatchFlush() throws IOException {
        final Path workingDir = new Path(TempDirUtils.newFolder(temporaryFolder).getAbsolutePath());
        final Path file = new Path(workingDir, "test-file");

        TestingFsBatchFlushOutputStream outputStream =
                new TestingFsBatchFlushOutputStream(
                        file.getFileSystem(), file, FileSystem.WriteMode.NO_OVERWRITE, BUFFER_SIZE);

        int dataSize = BUFFER_SIZE / 10;
        for (int i = 0; i < 9; ++i) {
            outputStream.write(new byte[dataSize]);
            assertThat(outputStream.flushCount).isZero();
        }
        outputStream.write(new byte[dataSize]);
        assertThat(outputStream.flushCount).isEqualTo(1);

        for (int i = 0; i < 9; ++i) {
            outputStream.write(new byte[dataSize]);
            assertThat(outputStream.flushCount).isEqualTo(1);
        }
        outputStream.write(new byte[dataSize - 1]);
        assertThat(outputStream.flushCount).isEqualTo(1);

        outputStream.write(new byte[1]);
        assertThat(outputStream.flushCount).isEqualTo(2);
    }