use of com.mongodb.internal.operation.AggregateOperation in project mongo-java-driver by mongodb.
the class AggregatePublisherImplTest method shouldBuildTheExpectedOperationForHintPlusHintString.
@DisplayName("Should build the expected AggregateOperation when both hint and hintString are set")
@Test
void shouldBuildTheExpectedOperationForHintPlusHintString() {
List<BsonDocument> pipeline = singletonList(BsonDocument.parse("{'$match': 1}"));
TestOperationExecutor executor = createOperationExecutor(asList(getBatchCursor(), getBatchCursor()));
AggregatePublisher<Document> publisher = new AggregatePublisherImpl<>(null, createMongoOperationPublisher(executor), pipeline, AggregationLevel.COLLECTION);
AggregateOperation<Document> expectedOperation = new AggregateOperation<>(NAMESPACE, pipeline, getDefaultCodecRegistry().get(Document.class)).batchSize(Integer.MAX_VALUE).retryReads(true);
publisher.hint(new Document("x", 1)).hintString("x_1");
expectedOperation.hint(new BsonDocument("x", new BsonInt32(1)));
Flux.from(publisher).blockFirst();
assertOperationIsTheSameAs(expectedOperation, executor.getReadOperation());
}
use of com.mongodb.internal.operation.AggregateOperation in project mongo-java-driver by mongodb.
the class AggregatePublisherImplTest method shouldBuildTheExpectedOperationForHintString.
@DisplayName("Should build the expected AggregateOperation for hint string")
@Test
void shouldBuildTheExpectedOperationForHintString() {
List<BsonDocument> pipeline = singletonList(BsonDocument.parse("{'$match': 1}"));
TestOperationExecutor executor = createOperationExecutor(asList(getBatchCursor(), getBatchCursor()));
AggregatePublisher<Document> publisher = new AggregatePublisherImpl<>(null, createMongoOperationPublisher(executor), pipeline, AggregationLevel.COLLECTION);
AggregateOperation<Document> expectedOperation = new AggregateOperation<>(NAMESPACE, pipeline, getDefaultCodecRegistry().get(Document.class)).batchSize(Integer.MAX_VALUE).retryReads(true);
publisher.hintString("x_1");
expectedOperation.hint(new BsonString("x_1"));
Flux.from(publisher).blockFirst();
assertOperationIsTheSameAs(expectedOperation, executor.getReadOperation());
}
Aggregations