@Test
  void nulls() throws IOException {
    BsonDocumentWriter writer = new BsonDocumentWriter(new BsonDocument());
    BsonGenerator generator = generatorFor(writer);
    generator.writeStartObject();

    generator.writeFieldName("null");
    generator.writeNull();

    generator.writeNullField("nullField");

    generator.writeFieldName("string");
    generator.writeString((String) null);

    generator.writeFieldName("bigDecimal");
    generator.writeNumber((BigDecimal) null);

    generator.writeFieldName("bigInteger");
    generator.writeNumber((BigInteger) null);
    generator.writeEndObject();
    BsonDocument doc = writer.getDocument();
    check(doc.get("null")).is(BsonNull.VALUE);
    check(doc.get("nullField")).is(BsonNull.VALUE);
    check(doc.get("string")).is(BsonNull.VALUE);
    check(doc.get("bigDecimal")).is(BsonNull.VALUE);
    check(doc.get("bigInteger")).is(BsonNull.VALUE);
  }
Writing null values does not cause an exception
criteria/mongo/test/org/immutables/criteria/mongo/bson4jackson/BsonGeneratorTest.java