Polishing.

Add author tags, tweak Javadoc style. Simplify tests. Document operator.

See #3724
Original pull request: #3759.
This commit is contained in:
Mark Paluch
2021-08-25 11:13:02 +02:00
parent 92cc2a582a
commit 7c6e951c7c
4 changed files with 11 additions and 7 deletions

View File

@@ -40,6 +40,7 @@ import org.springframework.util.StringUtils;
*
* @author Christoph Strobl
* @author Mark Paluch
* @author Mushtaq Ahmed
* @since 1.10
*/
public class ArithmeticOperators {
@@ -65,7 +66,8 @@ public class ArithmeticOperators {
}
/**
* Creates new {@link AggregationExpression} that returns a random float between 0 and 1 each time it is called.
* Creates new {@link AggregationExpression} that returns a random float between {@code 0} and {@code 1} each time it
* is called.
*
* @return new instance of {@link Rand}.
* @since 3.3

View File

@@ -29,6 +29,7 @@ import org.junit.jupiter.api.Test;
*
* @author Christoph Strobl
* @author Mark Paluch
* @author Mushtaq Ahmed
*/
class ArithmeticOperatorsUnitTests {
@@ -166,9 +167,8 @@ class ArithmeticOperatorsUnitTests {
.isEqualTo("{ $tanh : { $degreesToRadians : \"$angle\" } }");
}
@Test // GH-3724
void rendersRank() {
void rendersRand() {
assertThat(rand().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo(new Document("$rand", new Document()));
}
}

View File

@@ -1036,17 +1036,19 @@ public class SpelExpressionTransformerUnitTests {
@Test // GH-3713
void shouldRenderDateAdd() {
assertThat(transform("dateAdd(purchaseDate, 'day', 3)")).isEqualTo(Document.parse("{ $dateAdd: { startDate: \"$purchaseDate\", unit: \"day\", amount: 3 } }"));
assertThat(transform("dateAdd(purchaseDate, 'day', 3)"))
.isEqualTo("{ $dateAdd: { startDate: \"$purchaseDate\", unit: \"day\", amount: 3 } }");
}
@Test // GH-3713
void shouldRenderDateDiff() {
assertThat(transform("dateDiff(purchaseDate, delivered, 'day')")).isEqualTo(Document.parse("{ $dateDiff: { startDate: \"$purchaseDate\", endDate: \"$delivered\", unit: \"day\" } }"));
assertThat(transform("dateDiff(purchaseDate, delivered, 'day')"))
.isEqualTo("{ $dateDiff: { startDate: \"$purchaseDate\", endDate: \"$delivered\", unit: \"day\" } }");
}
@Test // GH-3724
void shouldRenderRand() {
assertThat(transform("rand()")).isEqualTo(Document.parse("{ $rand : {} }"));
assertThat(transform("rand()")).isEqualTo("{ $rand : {} }");
}
private Document transform(String expression, Object... params) {

View File

@@ -76,7 +76,7 @@ At the time of this writing, we provide support for the following Aggregation Op
[cols="2*"]
|===
| Pipeline Aggregation Operators
| `bucket`, `bucketAuto`, `count`, `facet`, `geoNear`, `graphLookup`, `group`, `limit`, `lookup`, `match`, `project`, `replaceRoot`, `skip`, `sort`, `unwind`
| `bucket`, `bucketAuto`, `count`, `facet`, `geoNear`, `graphLookup`, `group`, `limit`, `lookup`, `match`, `project`, `rand`, `replaceRoot`, `skip`, `sort`, `unwind`
| Set Aggregation Operators
| `setEquals`, `setIntersection`, `setUnion`, `setDifference`, `setIsSubset`, `anyElementTrue`, `allElementsTrue`