@Override
    protected void write(final PostgreSQLPacketPayload payload) {
        ByteBuf byteBuf = payload.getByteBuf();
        for (DatabasePacket each : packets) {
            if (!(each instanceof PostgreSQLIdentifierPacket)) {
                each.write(payload);
                continue;
            }
            PostgreSQLIdentifierPacket eachPacket = (PostgreSQLIdentifierPacket) each;
            byteBuf.writeByte(eachPacket.getIdentifier().getValue());
            int from = byteBuf.writerIndex();
            byteBuf.writeInt(0);
            eachPacket.write(payload);
            int length = byteBuf.writerIndex() - from;
            byteBuf.setInt(from, length);
        }
    }
@Test
    void assertWrite() {
        PostgreSQLIdentifierPacket identifierPacket = mock(PostgreSQLIdentifierPacket.class);
        when(identifierPacket.getIdentifier()).thenReturn(PostgreSQLMessagePacketType.READY_FOR_QUERY);
        PostgreSQLPacket nonIdentifierPacket = mock(PostgreSQLPacket.class);
        PostgreSQLAggregatedResponsesPacket packet = new PostgreSQLAggregatedResponsesPacket(Arrays.asList(nonIdentifierPacket, identifierPacket));
        PostgreSQLPacketPayload payload = mock(PostgreSQLPacketPayload.class);
        ByteBuf byteBuf = mock(ByteBuf.class);
        when(byteBuf.writerIndex()).thenReturn(1, 10);
        when(payload.getByteBuf()).thenReturn(byteBuf);
        packet.write(payload);
        verify(nonIdentifierPacket).write(payload);
        verify(byteBuf).writeByte(PostgreSQLMessagePacketType.READY_FOR_QUERY.getValue());
        verify(byteBuf).writeInt(0);
        verify(identifierPacket).write(payload);
        verify(byteBuf).setInt(1, 10 - 1);
    }