BsonObjectIdKeyGenerator implements KeyGenerator<ObjectId> { @Override public ObjectId generate() { return ObjectId.get(); }  @Override ObjectId generate();  }
@Test public void testNotNullValue() { assertThat(generator.generate(), is(notNullValue())); }
@Test public void testUniqueness() { final Set<ObjectId> set = new HashSet<>(); for (int i = 0; i < 1000; i++) { final ObjectId id = generator.generate(); assertThat(set, not(contains(id))); } }