use of org.springframework.data.mongodb.core.aggregation.AggregationOptions in project spring-data-mongodb by spring-projects.
the class StringBasedAggregationUnitTests method returnSingleObject.
// DATAMONGO-2153, DATAMONGO-2449
@Test
void returnSingleObject() {
PersonAggregate expected = new PersonAggregate();
when(aggregationResults.getUniqueMappedResult()).thenReturn(Collections.singletonList(expected));
AggregationInvocation invocation = executeAggregation("returnSingleEntity");
assertThat(invocation.result).isEqualTo(expected);
AggregationOptions options = invocation.aggregation.getOptions();
assertThat(options.getComment()).isEmpty();
assertThat(options.getCursorBatchSize()).isNull();
assertThat(options.isAllowDiskUse()).isFalse();
assertThat(options.getMaxTime()).isEqualTo(Duration.ZERO);
}
use of org.springframework.data.mongodb.core.aggregation.AggregationOptions in project spring-data-mongodb by spring-projects.
the class StringBasedAggregationUnitTests method plainStringAggregationConsidersMeta.
// DATAMONGO-2153, DATAMONGO-2449
@Test
void plainStringAggregationConsidersMeta() {
AggregationInvocation invocation = executeAggregation("plainStringAggregation");
AggregationOptions options = invocation.aggregation.getOptions();
assertThat(options.getComment()).contains("expensive-aggregation");
assertThat(options.getCursorBatchSize()).isEqualTo(42);
assertThat(options.isAllowDiskUse()).isTrue();
assertThat(options.getMaxTime()).isEqualTo(Duration.ofMillis(100));
}
Aggregations