The problem is when MongoCollection#insertMany is called so that unique index is violated.
MongoBulkWriteException is thrown and there are two issues with that.
MongoBulkWriteException.getWriteErrors() is returning List of BulkWriteErrors, the problem is that BulkWriteError always has its index equal to 0 instead of a correct one.
MongoBulkWriteException.getWriteResult() always has 0 in all of its count fields despite the fact that some documents were successfully written to collection.
If I would change FongoRule to use real MongoDB, everything will work as expected.
The problem is when
MongoCollection#insertMany
is called so that unique index is violated.MongoBulkWriteException
is thrown and there are two issues with that.MongoBulkWriteException.getWriteErrors()
is returningList
ofBulkWriteError
s, the problem is thatBulkWriteError
always has itsindex
equal to0
instead of a correct one.MongoBulkWriteException.getWriteResult()
always has0
in all of its count fields despite the fact that some documents were successfully written to collection.If I would change
FongoRule
to use real MongoDB, everything will work as expected.