Skip to content

Commit 7c6e951

Browse files
committed
Polishing.
Add author tags, tweak Javadoc style. Simplify tests. Document operator. See #3724 Original pull request: #3759.
1 parent 92cc2a5 commit 7c6e951

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
*
4141
* @author Christoph Strobl
4242
* @author Mark Paluch
43+
* @author Mushtaq Ahmed
4344
* @since 1.10
4445
*/
4546
public class ArithmeticOperators {
@@ -65,7 +66,8 @@ public static ArithmeticOperatorFactory valueOf(AggregationExpression expression
6566
}
6667

6768
/**
68-
* Creates new {@link AggregationExpression} that returns a random float between 0 and 1 each time it is called.
69+
* Creates new {@link AggregationExpression} that returns a random float between {@code 0} and {@code 1} each time it
70+
* is called.
6971
*
7072
* @return new instance of {@link Rand}.
7173
* @since 3.3

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
* @author Christoph Strobl
3131
* @author Mark Paluch
32+
* @author Mushtaq Ahmed
3233
*/
3334
class ArithmeticOperatorsUnitTests {
3435

@@ -166,9 +167,8 @@ void rendersTanhWithValueInDegrees() {
166167
.isEqualTo("{ $tanh : { $degreesToRadians : \"$angle\" } }");
167168
}
168169

169-
170170
@Test // GH-3724
171-
void rendersRank() {
171+
void rendersRand() {
172172
assertThat(rand().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo(new Document("$rand", new Document()));
173173
}
174174
}

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1036,17 +1036,19 @@ void shouldRenderTanh() {
10361036

10371037
@Test // GH-3713
10381038
void shouldRenderDateAdd() {
1039-
assertThat(transform("dateAdd(purchaseDate, 'day', 3)")).isEqualTo(Document.parse("{ $dateAdd: { startDate: \"$purchaseDate\", unit: \"day\", amount: 3 } }"));
1039+
assertThat(transform("dateAdd(purchaseDate, 'day', 3)"))
1040+
.isEqualTo("{ $dateAdd: { startDate: \"$purchaseDate\", unit: \"day\", amount: 3 } }");
10401041
}
10411042

10421043
@Test // GH-3713
10431044
void shouldRenderDateDiff() {
1044-
assertThat(transform("dateDiff(purchaseDate, delivered, 'day')")).isEqualTo(Document.parse("{ $dateDiff: { startDate: \"$purchaseDate\", endDate: \"$delivered\", unit: \"day\" } }"));
1045+
assertThat(transform("dateDiff(purchaseDate, delivered, 'day')"))
1046+
.isEqualTo("{ $dateDiff: { startDate: \"$purchaseDate\", endDate: \"$delivered\", unit: \"day\" } }");
10451047
}
10461048

10471049
@Test // GH-3724
10481050
void shouldRenderRand() {
1049-
assertThat(transform("rand()")).isEqualTo(Document.parse("{ $rand : {} }"));
1051+
assertThat(transform("rand()")).isEqualTo("{ $rand : {} }");
10501052
}
10511053

10521054
private Document transform(String expression, Object... params) {

src/main/asciidoc/reference/aggregation-framework.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ At the time of this writing, we provide support for the following Aggregation Op
7676
[cols="2*"]
7777
|===
7878
| Pipeline Aggregation Operators
79-
| `bucket`, `bucketAuto`, `count`, `facet`, `geoNear`, `graphLookup`, `group`, `limit`, `lookup`, `match`, `project`, `replaceRoot`, `skip`, `sort`, `unwind`
79+
| `bucket`, `bucketAuto`, `count`, `facet`, `geoNear`, `graphLookup`, `group`, `limit`, `lookup`, `match`, `project`, `rand`, `replaceRoot`, `skip`, `sort`, `unwind`
8080

8181
| Set Aggregation Operators
8282
| `setEquals`, `setIntersection`, `setUnion`, `setDifference`, `setIsSubset`, `anyElementTrue`, `allElementsTrue`

0 commit comments

Comments
 (0)