Browse Source

Polishing.

Update javadoc to reflect recent changes and split tests.

Original Pull Request: #4666
pull/4668/head
Christoph Strobl 2 years ago
parent
commit
d294d50407
No known key found for this signature in database
GPG Key ID: E6054036D0C37A4B
  1. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOptions.java
  2. 17
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationOptionsTests.java

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationOptions.java

@ -33,6 +33,10 @@ import com.mongodb.ReadPreference; @@ -33,6 +33,10 @@ import com.mongodb.ReadPreference;
* Holds a set of configurable aggregation options that can be used within an aggregation pipeline. A list of support
* aggregation options can be found in the
* <a href="https://docs.mongodb.org/manual/reference/command/aggregate/#aggregate">MongoDB reference documentation</a>.
* <p>
* As off 4.3 {@link #allowDiskUse} can be {@literal null}, indicating use of server default, and may only be applied if
* {@link #isAllowDiskUseSet() explicitly set}. For compatibility reasons {@link #isAllowDiskUse()} will remain
* returning {@literal false} if the no value has been set.
*
* @author Thomas Darimont
* @author Oliver Gierke

17
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationOptionsTests.java

@ -86,6 +86,12 @@ class AggregationOptionsTests { @@ -86,6 +86,12 @@ class AggregationOptionsTests {
assertThat(aggregationOptions.isAllowDiskUseSet()).isFalse();
assertThat(aggregationOptions.toDocument()).doesNotContainKey("allowDiskUse");
}
@Test // GH-4664
void applyOptionsDoesNotChangeAllowDiskUseDefault() {
aggregationOptions = AggregationOptions.fromDocument(new Document());
Document empty = new Document();
aggregationOptions.applyAndReturnPotentiallyChangedCommand(empty);
@ -93,6 +99,17 @@ class AggregationOptionsTests { @@ -93,6 +99,17 @@ class AggregationOptionsTests {
assertThat(empty).doesNotContainKey("allowDiskUse");
}
@Test // GH-4664
void applyOptionsDoesNotChangeExistingAllowDiskUse() {
aggregationOptions = AggregationOptions.fromDocument(new Document());
Document existing = new Document("allowDiskUse", true);
aggregationOptions.applyAndReturnPotentiallyChangedCommand(existing);
assertThat(existing).containsEntry("allowDiskUse", true);
}
@Test // DATAMONGO-960, DATAMONGO-2153, DATAMONGO-1836
void aggregationOptionsToString() {

Loading…
Cancel
Save