public T findAndModify(Bson filter, Bson fields, Bson sort, boolean remove, Bson update, boolean returnNew,
                           boolean upsert) {
        if (remove) {
            throw new IllegalArgumentException("Removing objects is not supported!");
        }

        var options = new FindOneAndUpdateOptions()
                .projection(fields)
                .sort(sort)
                .returnDocument(returnNew ? ReturnDocument.AFTER : ReturnDocument.BEFORE)
                .upsert(upsert);

        try {
            return delegate.findOneAndUpdate(filter, update, options);
        } catch (MongoServerException e) {
            throw possiblyAsDuplicateKeyError(e);
        }
    }
@Test
    void findAndModifyWithBsonVariants() {
        final var collection = spy(jacksonCollection("simple", Simple.class));

        final var query = DBQuery.empty();
        final var update = new DBUpdate.Builder().set("name", "foo");

        collection.findAndModify(query, update);
        verify(collection).findAndModify(eq(query), isNull(), isNull(), eq(false), eq(update), eq(false), eq(false));
    }