下面列出了怎么用com.mongodb.MongoQueryException的API类实例代码及写法,或者点击链接到github查看源代码。
@Test(expected = MongoQueryException.class)
public void testNearNoIndex() {
final Place place1 = new Place("place1", new double[]{1, 1});
getDs().save(place1);
Place found = getDs().find(Place.class)
.filter(near("loc", new Point(new Position(0, 0)))).iterator(new FindOptions().limit(1))
.tryNext();
Assert.assertNull(found);
}
@Test public void setsError() {
assertThatThrownBy(() -> executeFind(INVALID_COLLECTION_NAME))
.isInstanceOf(MongoQueryException.class);
// the error the interceptor receives is a MongoCommandException!
testSpanHandler.takeRemoteSpanWithErrorMessage(CLIENT, ".*InvalidNamespace.*");
}