@Override
    protected void write(final PostgreSQLPacketPayload payload) {
        for (Entry<Character, String> entry : fields.entrySet()) {
            payload.writeInt1(entry.getKey());
            payload.writeStringNul(entry.getValue());
        }
        payload.writeInt1(0);
    }
@Test
    void assertWrite() {
        PostgreSQLErrorResponsePacket responsePacket = createErrorResponsePacket();
        responsePacket.write(payload);
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_SEVERITY);
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_SEVERITY_NON_LOCALIZED);
        verify(payload, times(2)).writeStringNul("FATAL");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_CODE);
        verify(payload).writeStringNul("3D000");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_MESSAGE);
        verify(payload).writeStringNul("database \"test\" does not exist");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_DETAIL);
        verify(payload).writeStringNul("detail");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_HINT);
        verify(payload).writeStringNul("hint");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_POSITION);
        verify(payload).writeStringNul("1");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_INTERNAL_POSITION);
        verify(payload).writeStringNul("2");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_INTERNAL_QUERY);
        verify(payload).writeStringNul("internal query");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_WHERE);
        verify(payload).writeStringNul("where");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_SCHEMA_NAME);
        verify(payload).writeStringNul("test");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_TABLE_NAME);
        verify(payload).writeStringNul("table");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_COLUMN_NAME);
        verify(payload).writeStringNul("column");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_DATA_TYPE_NAME);
        verify(payload).writeStringNul("data type");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_CONSTRAINT_NAME);
        verify(payload).writeStringNul("constraint");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_FILE);
        verify(payload).writeStringNul("file");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_LINE);
        verify(payload).writeStringNul("3");
        verify(payload).writeInt1(PostgreSQLErrorResponsePacket.FIELD_TYPE_ROUTINE);
        verify(payload).writeStringNul("routine");
        verify(payload).writeInt1(0);
    }