ObjectId's equals(...) method is implemented invalidly. equals(...) methods need to be symmetrical, which means if A.equals(B) is true, B.equals(A) needs to be true as well. This is not the case as the implementation massages String values into ObjectId instances and thus surprisingly the following code succeeds:
ObjectId left = new ObjectId(); String right = left.toString(); assertThat(left, is(right)); // succeeds
This breaks once you test for symmetry:
assertThat(right, is(left)); // fails