|
|
|
|
@ -15,20 +15,14 @@
@@ -15,20 +15,14 @@
|
|
|
|
|
*/ |
|
|
|
|
package org.springframework.data.mongodb.core.aggregation; |
|
|
|
|
|
|
|
|
|
import static org.mockito.Mockito.*; |
|
|
|
|
import static org.springframework.data.domain.Sort.Direction.*; |
|
|
|
|
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*; |
|
|
|
|
import static org.mockito.Mockito.eq; |
|
|
|
|
import static org.mockito.Mockito.mock; |
|
|
|
|
import static org.mockito.Mockito.verify; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
import org.springframework.data.annotation.Id; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.MappingMongoConverter; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver; |
|
|
|
|
import org.springframework.data.mongodb.core.convert.QueryMapper; |
|
|
|
|
import org.springframework.data.mongodb.test.util.MongoTestMappingContext; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @author Christoph Strobl |
|
|
|
|
*/ |
|
|
|
|
@ -46,33 +40,4 @@ public class AggregationOperationRendererUnitTests {
@@ -46,33 +40,4 @@ public class AggregationOperationRendererUnitTests {
|
|
|
|
|
verify(stage1).toPipelineStages(eq(rootContext)); |
|
|
|
|
verify(stage2).toPipelineStages(eq(rootContext)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
record TestRecord(@Id String field1, String field2, LayerOne layerOne) { |
|
|
|
|
record LayerOne(List<LayerTwo> layerTwo) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
record LayerTwo(LayerThree layerThree) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
record LayerThree(int fieldA, int fieldB) |
|
|
|
|
{} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void xxx() { |
|
|
|
|
|
|
|
|
|
MongoTestMappingContext ctx = new MongoTestMappingContext(cfg -> { |
|
|
|
|
cfg.initialEntitySet(TestRecord.class); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
MappingMongoConverter mongoConverter = new MappingMongoConverter(NoOpDbRefResolver.INSTANCE, ctx); |
|
|
|
|
|
|
|
|
|
Aggregation agg = Aggregation.newAggregation( |
|
|
|
|
Aggregation.unwind("layerOne.layerTwo"), |
|
|
|
|
project().and("layerOne.layerTwo.layerThree").as("layerOne.layerThree"), |
|
|
|
|
sort(DESC, "layerOne.layerThree.fieldA") |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
AggregationOperationRenderer.toDocument(agg.getPipeline().getOperations(), new RelaxedTypeBasedAggregationOperationContext(TestRecord.class, ctx, new QueryMapper(mongoConverter))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|