|
15 | 15 | */
|
16 | 16 | package org.springframework.data.mongodb.core.aggregation;
|
17 | 17 |
|
18 |
| -import static org.assertj.core.api.Assertions.*; |
19 | 18 | import static org.springframework.data.mongodb.core.aggregation.DocumentOperators.*;
|
| 19 | +import static org.springframework.data.mongodb.test.util.Assertions.*; |
20 | 20 |
|
21 |
| -import org.bson.Document; |
22 | 21 | import org.junit.jupiter.api.Test;
|
23 | 22 |
|
24 | 23 | /**
|
| 24 | + * Unit tests for {@link DocumentOperators}. |
| 25 | + * |
25 | 26 | * @author Christoph Strobl
|
26 | 27 | */
|
27 | 28 | class DocumentOperatorsUnitTests {
|
28 | 29 |
|
29 | 30 | @Test // GH-3715
|
30 | 31 | void rendersRank() {
|
31 |
| - assertThat(rank().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo(new Document("$rank", new Document())); |
| 32 | + assertThat(rank().toDocument(Aggregation.DEFAULT_CONTEXT)).isEqualTo("{ $rank: { } }"); |
32 | 33 | }
|
33 | 34 |
|
34 | 35 | @Test // GH-3715
|
35 | 36 | void rendersDenseRank() {
|
36 | 37 | assertThat(denseRank().toDocument(Aggregation.DEFAULT_CONTEXT))
|
37 |
| - .isEqualTo(new Document("$denseRank", new Document())); |
| 38 | + .isEqualTo("{ $denseRank: { } }"); |
38 | 39 | }
|
39 | 40 |
|
40 | 41 | @Test // GH-3717
|
41 | 42 | void rendersDocumentNumber() {
|
42 | 43 | assertThat(documentNumber().toDocument(Aggregation.DEFAULT_CONTEXT))
|
43 |
| - .isEqualTo(new Document("$documentNumber", new Document())); |
| 44 | + .isEqualTo("{ $documentNumber: { } }"); |
44 | 45 | }
|
45 | 46 |
|
46 | 47 | @Test // GH-3727
|
47 | 48 | void rendersShift() {
|
48 | 49 |
|
49 | 50 | assertThat(valueOf("quantity").shift(1).toDocument(Aggregation.DEFAULT_CONTEXT))
|
50 |
| - .isEqualTo(Document.parse("{ $shift: { output: \"$quantity\", by: 1 } }")); |
| 51 | + .isEqualTo("{ $shift: { output: \"$quantity\", by: 1 } }"); |
51 | 52 | }
|
52 | 53 |
|
53 | 54 | @Test // GH-3727
|
54 | 55 | void rendersShiftWithDefault() {
|
55 | 56 |
|
56 | 57 | assertThat(valueOf("quantity").shift(1).defaultTo("Not available").toDocument(Aggregation.DEFAULT_CONTEXT))
|
57 |
| - .isEqualTo(Document.parse("{ $shift: { output: \"$quantity\", by: 1, default: \"Not available\" } }")); |
| 58 | + .isEqualTo("{ $shift: { output: \"$quantity\", by: 1, default: \"Not available\" } }"); |
58 | 59 | }
|
59 | 60 | }
|
0 commit comments