|
17 | 17 |
|
18 | 18 | import static org.springframework.data.domain.Sort.Direction.*;
|
19 | 19 | import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
|
20 |
| -import static org.springframework.data.mongodb.core.aggregation.Fields.*; |
21 | 20 | import static org.springframework.data.mongodb.core.query.Criteria.*;
|
22 | 21 | import static org.springframework.data.mongodb.test.util.Assertions.*;
|
23 | 22 |
|
|
42 | 41 | import java.util.Scanner;
|
43 | 42 | import java.util.stream.Stream;
|
44 | 43 |
|
45 |
| -import org.apache.commons.logging.Log; |
46 |
| -import org.apache.commons.logging.LogFactory; |
47 | 44 | import org.assertj.core.data.Offset;
|
48 | 45 | import org.bson.Document;
|
49 | 46 | import org.junit.jupiter.api.AfterEach;
|
|
73 | 70 | import org.springframework.data.mongodb.core.query.NearQuery;
|
74 | 71 | import org.springframework.data.mongodb.core.query.Query;
|
75 | 72 | import org.springframework.data.mongodb.repository.Person;
|
| 73 | +import org.springframework.data.mongodb.test.util.EnableIfMongoServerVersion; |
76 | 74 | import org.springframework.data.mongodb.test.util.MongoTemplateExtension;
|
77 | 75 | import org.springframework.data.mongodb.test.util.MongoTestTemplate;
|
78 | 76 | import org.springframework.data.mongodb.test.util.MongoVersion;
|
|
100 | 98 | public class AggregationTests {
|
101 | 99 |
|
102 | 100 | private static final String INPUT_COLLECTION = "aggregation_test_collection";
|
103 |
| - private static final Log LOGGER = LogFactory.getLog(AggregationTests.class); |
104 | 101 |
|
105 | 102 | private static boolean initialized = false;
|
106 | 103 |
|
@@ -318,6 +315,7 @@ void shouldUnwindWithIndex() {
|
318 | 315 | }
|
319 | 316 |
|
320 | 317 | @Test // DATAMONGO-1391
|
| 318 | + @EnableIfMongoServerVersion(isLessThan = "6.0") // $sort does not seem to have an effect on $unwind |
321 | 319 | void shouldUnwindPreserveEmpty() {
|
322 | 320 |
|
323 | 321 | MongoCollection<Document> coll = mongoTemplate.getCollection(INPUT_COLLECTION);
|
@@ -1375,7 +1373,8 @@ void shouldRetrieveDateTimeFragementsCorrectly() throws Exception {
|
1375 | 1373 |
|
1376 | 1374 | mongoTemplate.dropCollection(ObjectWithDate.class);
|
1377 | 1375 |
|
1378 |
| - ZonedDateTime dateTime = ZonedDateTime.of(LocalDateTime.of(LocalDate.of(2014, 2, 7), LocalTime.of(3, 4, 5, 6)), ZoneId.of("UTC")); |
| 1376 | + ZonedDateTime dateTime = ZonedDateTime.of(LocalDateTime.of(LocalDate.of(2014, 2, 7), LocalTime.of(3, 4, 5, 6)), |
| 1377 | + ZoneId.of("UTC")); |
1379 | 1378 |
|
1380 | 1379 | ObjectWithDate owd = new ObjectWithDate(Date.from(dateTime.toInstant()));
|
1381 | 1380 | mongoTemplate.insert(owd);
|
@@ -1706,10 +1705,8 @@ void letShouldBeAppliedCorrectly() {
|
1706 | 1705 | .forExpression(ConditionalOperators.Cond.when("applyDiscount").then(0.9D).otherwise(1.0D));
|
1707 | 1706 |
|
1708 | 1707 | TypedAggregation<Sales2> agg = Aggregation.newAggregation(Sales2.class,
|
1709 |
| - Aggregation.project() |
1710 |
| - .and(VariableOperators.Let.define(total, discounted).andApply( |
1711 |
| - ArithmeticOperators.valueOf("total").multiplyBy("discounted"))) |
1712 |
| - .as("finalTotal")); |
| 1708 | + Aggregation.project().and(VariableOperators.Let.define(total, discounted) |
| 1709 | + .andApply(ArithmeticOperators.valueOf("total").multiplyBy("discounted"))).as("finalTotal")); |
1713 | 1710 |
|
1714 | 1711 | AggregationResults<Document> result = mongoTemplate.aggregate(agg, Document.class);
|
1715 | 1712 | assertThat(result.getMappedResults()).contains(new Document("_id", "1").append("finalTotal", 9.450000000000001D),
|
|
0 commit comments