@@ -2714,6 +2714,84 @@ void testAggregateWithRedact() {
27142714 .containsOnly (json ("_id: 1" ));
27152715 }
27162716
2717+ @ Test
2718+ void dotNotationProjection () {
2719+ collection .insertOne (json ("""
2720+ _id: 1,
2721+ companyName: 'Walt Disney',
2722+ buildingNumber: 500,
2723+ streetName: 'South Buena Vista Street',
2724+ city: 'Burbank',
2725+ state: 'California',
2726+ zipCode: 91502
2727+ """ ));
2728+
2729+ assertThat (collection .aggregate (jsonList ("""
2730+ $project: {
2731+ Name: "$companyName",
2732+ "Address.City": "$city",
2733+ "Address.ZipCode": "$zipCode",
2734+ "Address.StreetName": "$streetName",
2735+ "Address.BuildingNumber": "$buildingNumber",
2736+ }
2737+ """ )))
2738+ .containsExactly (json ("""
2739+ _id: 1,
2740+ Name: 'Walt Disney',
2741+ Address: {
2742+ City: 'Burbank',
2743+ ZipCode: 91502,
2744+ StreetName: 'South Buena Vista Street',
2745+ BuildingNumber: 500
2746+ }
2747+ """ ));
2748+ }
2749+
2750+ @ Test
2751+ void dotNotationProjectionDeepNesting () {
2752+ collection .insertOne (json ("""
2753+ _id: 1,
2754+ companyName: 'Acme Corp',
2755+ country: 'USA',
2756+ state: 'California',
2757+ city: 'San Francisco',
2758+ street: 'Market Street',
2759+ buildingNumber: 123,
2760+ floor: 5,
2761+ unit: 'A'
2762+ """ ));
2763+
2764+ assertThat (collection .aggregate (jsonList ("""
2765+ $project: {
2766+ Company: "$companyName",
2767+ "Location.Country": "$country",
2768+ "Location.Address.State": "$state",
2769+ "Location.Address.City": "$city",
2770+ "Location.Address.Details.Street": "$street",
2771+ "Location.Address.Details.BuildingNumber": "$buildingNumber",
2772+ "Location.Address.Details.Floor": "$floor",
2773+ "Location.Address.Details.Unit": "$unit"
2774+ }
2775+ """ )))
2776+ .containsExactly (json ("""
2777+ _id: 1,
2778+ Company: 'Acme Corp',
2779+ Location: {
2780+ Country: 'USA',
2781+ Address: {
2782+ State: 'California',
2783+ City: 'San Francisco',
2784+ Details: {
2785+ Street: 'Market Street',
2786+ BuildingNumber: 123,
2787+ Floor: 5,
2788+ Unit: 'A'
2789+ }
2790+ }
2791+ }
2792+ """ ));
2793+ }
2794+
27172795 // https://github.com/bwaldvogel/mongo-java-server/issues/191
27182796 @ Test
27192797 void testProjectWithCondition () throws Exception {
0 commit comments