void addFinishedBuffer(Buffer buffer) {
        NettyPayload toAddBuffer =
                NettyPayload.newBuffer(buffer, finishedBufferIndex, subpartitionId);
        addFinishedBuffer(toAddBuffer);
    }
@Test
    void testAddFinishedBuffer() {
        MemoryTierSubpartitionProducerAgent subpartitionProducerAgent =
                createSubpartitionProducerAgent();

        AtomicReference<NettyPayload> received = new AtomicReference<>();
        TestingNettyConnectionWriter connectionWriter =
                new TestingNettyConnectionWriter.Builder()
                        .setWriteBufferFunction(
                                buffer -> {
                                    received.set(buffer);
                                    return null;
                                })
                        .build();
        subpartitionProducerAgent.connectionEstablished(connectionWriter);

        Buffer sentBuffer = BufferBuilderTestUtils.buildSomeBuffer();
        subpartitionProducerAgent.addFinishedBuffer(sentBuffer);
        Optional<Buffer> receivedBuffer = received.get().getBuffer();

        assertThat(receivedBuffer).isPresent();
        assertThat(receivedBuffer.get()).isEqualTo(sentBuffer);
    }