MongoQueryBuilder implements QueryBuilder<R> { @Override public MongoQuerySortBuilder<R> sort() { if (this.sort == null) { return new MongoQuerySortBuilder<>(this); } return this.sort; } MongoQueryBuilder(Class<R> clazz, MongoCollection<Document> collection, MorphixMongoConnector connector); @Override MorphixMongoConnector getConnector(); @Override Class<R> getQueryType(); @Override MongoFieldQueryBuilder<R> where(String field); @Override MongoQuerySortBuilder<R> sort(); @Override void delete(); @Override void delete(boolean justOne); @Override QueryResult<R> result(); @Override MongoFindQuery find();  }
@Test void sortCancel() { MongoCollection<Document> collection = populate("sort_cancel_test"); MongoQueryBuilder<Object> query = new MongoQueryBuilder<>(Object.class, collection, this.connector); query.sort().desc("uuid").cancel(); assertNull(query.sort); collection.deleteMany(new BsonDocument()); assertEquals(0, collection.count()); }
@Test void sortClear() { MongoCollection<Document> collection = populate("sort_cancel_test"); MongoQueryBuilder<Object> query = new MongoQueryBuilder<>(Object.class, collection, this.connector); query.sort().desc("uuid").done(); assertEquals(1, query.sort().getElements().size()); query.sort().clear(); assertEquals(0, query.sort().getElements().size()); collection.deleteMany(new BsonDocument()); assertEquals(0, collection.count()); }