public static ObjectId insertedId(@Nonnull InsertOneResult result) {
        final BsonValue insertedId = result.getInsertedId();
        if (insertedId == null) {
            // this should only happen when inserting RawBsonDocuments
            throw new IllegalArgumentException("Inserted ID is null. Make sure that you are inserting documents of " +
                    "type <? extends MongoEntity>.");
        }
        return insertedId.asObjectId().getValue();
    }
@Test
    void testNullInsertedId() {
        final var rawCollection = mongoCollections.nonEntityCollection("raw_bson_test", RawBsonDocument.class);
        final RawBsonDocument doc = RawBsonDocument.parse("{\"name\":\"a\"}");
        assertThatThrownBy(() -> insertedId(rawCollection.insertOne(doc)))
                .isInstanceOf(IllegalArgumentException.class)
                .hasMessageContaining("MongoEntity");
    }