Commits

David Carr  committed 48b6a85

tests: add result sort orders to documentation example tests

  • Participants
  • Parent commits 4c901fe

Comments (0)

Files changed (5)

File src/test/java/org/bitbucket/davidm24/mongodb/aggregate/DocumentationExamplesIT.java

                         .put("totalPop").greaterThanEquals(10 * 1000 * 1000)
                         .get()
                 )
+                // Not part of the example, but important for reproducibility
+                .sort(newMap("_id", 1))
                 .run();
         verifyAggregationOutputFromResources(testName, output);
     }
                         .put("avgCityPop").avg("$pop")
                         .get()
                 )
+                // Not part of the example, but important for reproducibility
+                .sort(newMap("_id", 1))
                 .run();
         verifyAggregationOutputFromResources(testName, output);
     }
                         .put("pop").sum("$pop")
                         .get()
                 )
-                .sort(newMap("sort", 1))
+                .sort(newMap("pop", 1))
                 .group(GroupBuilder.start()
                         .put("_id").to("$_id.state")
                         .put("biggestCity").last("$_id.city")
                                 newMap("name", "$smallestCity", "pop",
                                         "$smallestPop")
                         ))
+                // Not part of the example, but important for reproducibility
+                .sort(newMap("state", 1))
                 .run();
         verifyAggregationOutputFromResources(testName, output);
     }

File src/test/resources/org/bitbucket/davidm24/mongodb/aggregate/averageCityPopulationByStateTest.expected.command.json

-{ "aggregate" : "zipcodes" , "pipeline" : [ { "$group" : { "_id" : { "state" : "$state" , "city" : "$city"} , "pop" : { "$sum" : "$pop"}}} , { "$group" : { "_id" : "$_id.state" , "avgCityPop" : { "$avg" : "$pop"}}}]}
+{ "aggregate" : "zipcodes" , "pipeline" : [ { "$group" : { "_id" : { "state" : "$state" , "city" : "$city"} , "pop" : { "$sum" : "$pop"}}} , { "$group" : { "_id" : "$_id.state" , "avgCityPop" : { "$avg" : "$pop"}}} , { "$sort" : { "_id" : 1}}]}

File src/test/resources/org/bitbucket/davidm24/mongodb/aggregate/largestAndSmallestCitiesByStateTest.expected.command.json

-{ "aggregate" : "zipcodes" , "pipeline" : [ { "$group" : { "_id" : { "state" : "$state" , "city" : "$city"} , "pop" : { "$sum" : "$pop"}}} , { "$sort" : { "sort" : 1}} , { "$group" : { "_id" : "$_id.state" , "biggestCity" : { "$last" : "$_id.city"} , "biggestPop" : { "$last" : "$pop"} , "smallestCity" : { "$first" : "$_id.city"} , "smallestPop" : { "$first" : "$pop"}}} , { "$project" : { "_id" : 0 , "state" : "$_id" , "biggestCity" : { "name" : "$biggestCity" , "pop" : "$biggestPop"} , "smallestCity" : { "name" : "$smallestCity" , "pop" : "$smallestPop"}}}]}
+{ "aggregate" : "zipcodes" , "pipeline" : [ { "$group" : { "_id" : { "state" : "$state" , "city" : "$city"} , "pop" : { "$sum" : "$pop"}}} , { "$sort" : { "pop" : 1}} , { "$group" : { "_id" : "$_id.state" , "biggestCity" : { "$last" : "$_id.city"} , "biggestPop" : { "$last" : "$pop"} , "smallestCity" : { "$first" : "$_id.city"} , "smallestPop" : { "$first" : "$pop"}}} , { "$project" : { "_id" : 0 , "state" : "$_id" , "biggestCity" : { "name" : "$biggestCity" , "pop" : "$biggestPop"} , "smallestCity" : { "name" : "$smallestCity" , "pop" : "$smallestPop"}}} , { "$sort" : { "state" : 1}}]}

File src/test/resources/org/bitbucket/davidm24/mongodb/aggregate/largestAndSmallestCitiesByStateTest.expected.results.json

-[ { "biggestCity" : { "name" : "WASHINGTON" , "pop" : 606879} , "smallestCity" : { "name" : "PENTAGON" , "pop" : 21} , "state" : "DC"} , { "biggestCity" : { "name" : "GREENVILLE" , "pop" : 7176} , "smallestCity" : { "name" : "LAUREL" , "pop" : 9283} , "state" : "DE"} , { "biggestCity" : { "name" : "LITCHVILLE" , "pop" : 421} , "smallestCity" : { "name" : "GRANVILLE" , "pop" : 679} , "state" : "ND"} , { "biggestCity" : { "name" : "HENDRICKS" , "pop" : 318} , "smallestCity" : { "name" : "LAHMANSVILLE" , "pop" : 32} , "state" : "WV"} , { "biggestCity" : { "name" : "LILLIWAUP" , "pop" : 635} , "smallestCity" : { "name" : "TROUT LAKE" , "pop" : 766} , "state" : "WA"} , { "biggestCity" : { "name" : "HOLMESVILLE" , "pop" : 353} , "smallestCity" : { "name" : "COZAD" , "pop" : 5221} , "state" : "NE"} , { "biggestCity" : { "name" : "MONROE" , "pop" : 44866} , "smallestCity" : { "name" : "STATESVILLE" , "pop" : 52895} , "state" : "NC"} , { "biggestCity" : { "name" : "LONDONDERRY" , "pop" : 19687} , "smallestCity" : { "name" : "HAMPTON" , "pop" : 12278} , "state" : "NH"} , { "biggestCity" : { "name" : "JOPLIN" , "pop" : 496} , "smallestCity" : { "name" : "CHOTEAU" , "pop" : 2846} , "state" : "MT"} , { "biggestCity" : { "name" : "TILLY" , "pop" : 118} , "smallestCity" : { "name" : "MOUNT VERNON" , "pop" : 534} , "state" : "AR"} , { "biggestCity" : { "name" : "STUDIO CITY" , "pop" : 24354} , "smallestCity" : { "name" : "LEMONCOVE" , "pop" : 64} , "state" : "CA"} , { "biggestCity" : { "name" : "CALDWELL" , "pop" : 32407} , "smallestCity" : { "name" : "WESTON" , "pop" : 727} , "state" : "ID"} , { "biggestCity" : { "name" : "COVENTRY" , "pop" : 722} , "smallestCity" : { "name" : "WEST PAWLET" , "pop" : 604} , "state" : "VT"} , { "biggestCity" : { "name" : "CARROLLTON" , "pop" : 37148} , "smallestCity" : { "name" : "PORT REPUBLIC" , "pop" : 2647} , "state" : "MD"} , { "biggestCity" : { "name" : "EUCHA" , "pop" : 2935} , "smallestCity" : { "name" : "ROFF" , "pop" : 1316} , "state" : "OK"} , { "biggestCity" : { "name" : "WALSHVILLE" , "pop" : 359} , "smallestCity" : { "name" : "SAINT ELMO" , "pop" : 2091} , "state" : "IL"} , { "biggestCity" : { "name" : "BAKER" , "pop" : 269} , "smallestCity" : { "name" : "FALLON" , "pop" : 17938} , "state" : "NV"} , { "biggestCity" : { "name" : "BETHPAGE" , "pop" : 4132} , "smallestCity" : { "name" : "HARTSVILLE" , "pop" : 5511} , "state" : "TN"} , { "biggestCity" : { "name" : "PEKIN" , "pop" : 5351} , "smallestCity" : { "name" : "NEW ALBANY" , "pop" : 44969} , "state" : "IN"} , { "biggestCity" : { "name" : "SAN CARLOS" , "pop" : 2307} , "smallestCity" : { "name" : "LEUPP" , "pop" : 2396} , "state" : "AZ"} , { "biggestCity" : { "name" : "FALLS" , "pop" : 2349} , "smallestCity" : { "name" : "ELLPORT" , "pop" : 19193} , "state" : "PA"} , { "biggestCity" : { "name" : "COILA" , "pop" : 1529} , "smallestCity" : { "name" : "CHURCH HILL" , "pop" : 1079} , "state" : "MS"} , { "biggestCity" : { "name" : "WEED" , "pop" : 196} , "smallestCity" : { "name" : "ALGODONES" , "pop" : 0} , "state" : "NM"} , { "biggestCity" : { "name" : "LAREDO" , "pop" : 485} , "smallestCity" : { "name" : "SUNRISE BEACH" , "pop" : 3635} , "state" : "MO"} , { "biggestCity" : { "name" : "CROOK" , "pop" : 638} , "smallestCity" : { "name" : "ECKLEY" , "pop" : 242} , "state" : "CO"} , { "biggestCity" : { "name" : "EPHRAIM" , "pop" : 3492} , "smallestCity" : { "name" : "PINTURA" , "pop" : 17392} , "state" : "UT"} , { "biggestCity" : { "name" : "ISLIP TERRACE" , "pop" : 9514} , "smallestCity" : { "name" : "BLISS" , "pop" : 1498} , "state" : "NY"} , { "biggestCity" : { "name" : "REVA" , "pop" : 332} , "smallestCity" : { "name" : "BANCROFT" , "pop" : 200} , "state" : "SD"} , { "biggestCity" : { "name" : "JAMESTOWN" , "pop" : 380} , "smallestCity" : { "name" : "MAURICE" , "pop" : 3628} , "state" : "LA"} , { "biggestCity" : { "name" : "NESS CITY" , "pop" : 2256} , "smallestCity" : { "name" : "ROSSVILLE" , "pop" : 1583} , "state" : "KS"} , { "biggestCity" : { "name" : "BELL" , "pop" : 2446} , "smallestCity" : { "name" : "OKEECHOBEE" , "pop" : 18122} , "state" : "FL"} , { "biggestCity" : { "name" : "RICHMOND HEIGHTS" , "pop" : 21114} , "smallestCity" : { "name" : "RIDGEWAY" , "pop" : 857} , "state" : "OH"} , { "biggestCity" : { "name" : "CRANSTON" , "pop" : 176404} , "smallestCity" : { "name" : "CUMBERLAND" , "pop" : 29327} , "state" : "RI"} , { "biggestCity" : { "name" : "FOSTERS" , "pop" : 2100} , "smallestCity" : { "name" : "ATHENS" , "pop" : 35441} , "state" : "AL"} , { "biggestCity" : { "name" : "OTTAWA LAKE" , "pop" : 4531} , "smallestCity" : { "name" : "HOLTON" , "pop" : 4251} , "state" : "MI"} , { "biggestCity" : { "name" : "CHERRYFIELD" , "pop" : 1341} , "smallestCity" : { "name" : "WELLS" , "pop" : 5590} , "state" : "ME"} , { "biggestCity" : { "name" : "HUBBARD" , "pop" : 6393} , "smallestCity" : { "name" : "ALOHA" , "pop" : 67233} , "state" : "OR"} , { "biggestCity" : { "name" : "SHERIDAN" , "pop" : 20025} , "smallestCity" : { "name" : "MORAN" , "pop" : 191} , "state" : "WY"} , { "biggestCity" : { "name" : "PEQUOT LAKES" , "pop" : 3437} , "smallestCity" : { "name" : "WARROAD" , "pop" : 3766} , "state" : "MN"} , { "biggestCity" : { "name" : "ARCTIC VILLAGE" , "pop" : 107} , "smallestCity" : { "name" : "AKHIOK" , "pop" : 13309} , "state" : "AK"} , { "biggestCity" : { "name" : "MONTICELLO" , "pop" : 5328} , "smallestCity" : { "name" : "JEWELL" , "pop" : 1105} , "state" : "GA"} , { "biggestCity" : { "name" : "EARLINGTON" , "pop" : 2445} , "smallestCity" : { "name" : "STRUNK" , "pop" : 481} , "state" : "KY"} , { "biggestCity" : { "name" : "OCHEYEDAN" , "pop" : 1596} , "smallestCity" : { "name" : "BARNUM" , "pop" : 481} , "state" : "IA"} , { "biggestCity" : { "name" : "LEE" , "pop" : 6916} , "smallestCity" : { "name" : "SUNDERLAND" , "pop" : 3399} , "state" : "MA"} , { "biggestCity" : { "name" : "NEW EGYPT" , "pop" : 4601} , "smallestCity" : { "name" : "MONTAGUE" , "pop" : 3228} , "state" : "NJ"} , { "biggestCity" : { "name" : "ROUND O" , "pop" : 64} , "smallestCity" : { "name" : "CHESNEE" , "pop" : 14714} , "state" : "SC"} , { "biggestCity" : { "name" : "NINOLE" , "pop" : 0} , "smallestCity" : { "name" : "HAKALAU" , "pop" : 198} , "state" : "HI"} , { "biggestCity" : { "name" : "NORTH FRANKLIN" , "pop" : 1654} , "smallestCity" : { "name" : "DANBURY" , "pop" : 65373} , "state" : "CT"} , { "biggestCity" : { "name" : "WIRTZ" , "pop" : 1675} , "smallestCity" : { "name" : "LUNENBURG" , "pop" : 156} , "state" : "VA"} , { "biggestCity" : { "name" : "EMORY" , "pop" : 3919} , "smallestCity" : { "name" : "BAYVIEW" , "pop" : 9033} , "state" : "TX"} , { "biggestCity" : { "name" : "LAKE NEBAGAMON" , "pop" : 1824} , "smallestCity" : { "name" : "HAMMOND" , "pop" : 1921} , "state" : "WI"}]
+[ { "biggestCity" : { "name" : "ANCHORAGE" , "pop" : 183987} , "smallestCity" : { "name" : "NAKNEK" , "pop" : 0} , "state" : "AK"} , { "biggestCity" : { "name" : "BIRMINGHAM" , "pop" : 242606} , "smallestCity" : { "name" : "ALLEN" , "pop" : 0} , "state" : "AL"} , { "biggestCity" : { "name" : "LITTLE ROCK" , "pop" : 192895} , "smallestCity" : { "name" : "TOMATO" , "pop" : 0} , "state" : "AR"} , { "biggestCity" : { "name" : "PHOENIX" , "pop" : 890853} , "smallestCity" : { "name" : "HUALAPAI" , "pop" : 2} , "state" : "AZ"} , { "biggestCity" : { "name" : "LOS ANGELES" , "pop" : 2102295} , "smallestCity" : { "name" : "ALLEGHANY" , "pop" : 0} , "state" : "CA"} , { "biggestCity" : { "name" : "DENVER" , "pop" : 451182} , "smallestCity" : { "name" : "CHEYENNE MTN AFB" , "pop" : 0} , "state" : "CO"} , { "biggestCity" : { "name" : "BRIDGEPORT" , "pop" : 141638} , "smallestCity" : { "name" : "EAST KILLINGLY" , "pop" : 25} , "state" : "CT"} , { "biggestCity" : { "name" : "WASHINGTON" , "pop" : 606879} , "smallestCity" : { "name" : "PENTAGON" , "pop" : 21} , "state" : "DC"} , { "biggestCity" : { "name" : "NEWARK" , "pop" : 111674} , "smallestCity" : { "name" : "BETHEL" , "pop" : 108} , "state" : "DE"} , { "biggestCity" : { "name" : "MIAMI" , "pop" : 825232} , "smallestCity" : { "name" : "CECIL FIELD NAS" , "pop" : 0} , "state" : "FL"} , { "biggestCity" : { "name" : "ATLANTA" , "pop" : 609591} , "smallestCity" : { "name" : "FORT STEWART" , "pop" : 0} , "state" : "GA"} , { "biggestCity" : { "name" : "HONOLULU" , "pop" : 396643} , "smallestCity" : { "name" : "NINOLE" , "pop" : 0} , "state" : "HI"} , { "biggestCity" : { "name" : "DES MOINES" , "pop" : 148155} , "smallestCity" : { "name" : "DOUDS" , "pop" : 15} , "state" : "IA"} , { "biggestCity" : { "name" : "BOISE" , "pop" : 165522} , "smallestCity" : { "name" : "KEUTERVILLE" , "pop" : 0} , "state" : "ID"} , { "biggestCity" : { "name" : "CHICAGO" , "pop" : 2452177} , "smallestCity" : { "name" : "ANCONA" , "pop" : 38} , "state" : "IL"} , { "biggestCity" : { "name" : "INDIANAPOLIS" , "pop" : 348868} , "smallestCity" : { "name" : "47559" , "pop" : 23} , "state" : "IN"} , { "biggestCity" : { "name" : "WICHITA" , "pop" : 295115} , "smallestCity" : { "name" : "ARNOLD" , "pop" : 0} , "state" : "KS"} , { "biggestCity" : { "name" : "LOUISVILLE" , "pop" : 288058} , "smallestCity" : { "name" : "BIG LAUREL" , "pop" : 0} , "state" : "KY"} , { "biggestCity" : { "name" : "NEW ORLEANS" , "pop" : 496937} , "smallestCity" : { "name" : "FORDOCHE" , "pop" : 0} , "state" : "LA"} , { "biggestCity" : { "name" : "WORCESTER" , "pop" : 169856} , "smallestCity" : { "name" : "BUCKLAND" , "pop" : 16} , "state" : "MA"} , { "biggestCity" : { "name" : "BALTIMORE" , "pop" : 733081} , "smallestCity" : { "name" : "ANNAPOLIS JUNCTI" , "pop" : 32} , "state" : "MD"} , { "biggestCity" : { "name" : "PORTLAND" , "pop" : 63268} , "smallestCity" : { "name" : "BUSTINS ISLAND" , "pop" : 0} , "state" : "ME"} , { "biggestCity" : { "name" : "DETROIT" , "pop" : 963243} , "smallestCity" : { "name" : "LELAND" , "pop" : 0} , "state" : "MI"} , { "biggestCity" : { "name" : "MINNEAPOLIS" , "pop" : 344719} , "smallestCity" : { "name" : "JOHNSON" , "pop" : 12} , "state" : "MN"} , { "biggestCity" : { "name" : "SAINT LOUIS" , "pop" : 397802} , "smallestCity" : { "name" : "BENDAVIS" , "pop" : 44} , "state" : "MO"} , { "biggestCity" : { "name" : "JACKSON" , "pop" : 204788} , "smallestCity" : { "name" : "CHUNKY" , "pop" : 79} , "state" : "MS"} , { "biggestCity" : { "name" : "BILLINGS" , "pop" : 78805} , "smallestCity" : { "name" : "HOMESTEAD" , "pop" : 7} , "state" : "MT"} , { "biggestCity" : { "name" : "CHARLOTTE" , "pop" : 465833} , "smallestCity" : { "name" : "GLOUCESTER" , "pop" : 0} , "state" : "NC"} , { "biggestCity" : { "name" : "GRAND FORKS" , "pop" : 59527} , "smallestCity" : { "name" : "TROTTERS" , "pop" : 12} , "state" : "ND"} , { "biggestCity" : { "name" : "OMAHA" , "pop" : 358930} , "smallestCity" : { "name" : "LAKESIDE" , "pop" : 5} , "state" : "NE"} , { "biggestCity" : { "name" : "MANCHESTER" , "pop" : 106452} , "smallestCity" : { "name" : "WEST NOTTINGHAM" , "pop" : 27} , "state" : "NH"} , { "biggestCity" : { "name" : "NEWARK" , "pop" : 275572} , "smallestCity" : { "name" : "IMLAYSTOWN" , "pop" : 17} , "state" : "NJ"} , { "biggestCity" : { "name" : "ALBUQUERQUE" , "pop" : 449584} , "smallestCity" : { "name" : "REGINA" , "pop" : 0} , "state" : "NM"} , { "biggestCity" : { "name" : "LAS VEGAS" , "pop" : 597557} , "smallestCity" : { "name" : "TUSCARORA" , "pop" : 1} , "state" : "NV"} , { "biggestCity" : { "name" : "BROOKLYN" , "pop" : 2300504} , "smallestCity" : { "name" : "EAST SPRINGFIELD" , "pop" : 0} , "state" : "NY"} , { "biggestCity" : { "name" : "CLEVELAND" , "pop" : 536759} , "smallestCity" : { "name" : "ISLE SAINT GEORG" , "pop" : 38} , "state" : "OH"} , { "biggestCity" : { "name" : "TULSA" , "pop" : 389072} , "smallestCity" : { "name" : "SOUTHARD" , "pop" : 8} , "state" : "OK"} , { "biggestCity" : { "name" : "PORTLAND" , "pop" : 518543} , "smallestCity" : { "name" : "LYONS" , "pop" : 0} , "state" : "OR"} , { "biggestCity" : { "name" : "PHILADELPHIA" , "pop" : 1610956} , "smallestCity" : { "name" : "HAMILTON" , "pop" : 0} , "state" : "PA"} , { "biggestCity" : { "name" : "CRANSTON" , "pop" : 176404} , "smallestCity" : { "name" : "CLAYVILLE" , "pop" : 45} , "state" : "RI"} , { "biggestCity" : { "name" : "COLUMBIA" , "pop" : 269521} , "smallestCity" : { "name" : "QUINBY" , "pop" : 0} , "state" : "SC"} , { "biggestCity" : { "name" : "SIOUX FALLS" , "pop" : 102046} , "smallestCity" : { "name" : "ZEONA" , "pop" : 8} , "state" : "SD"} , { "biggestCity" : { "name" : "MEMPHIS" , "pop" : 632837} , "smallestCity" : { "name" : "ALLRED" , "pop" : 2} , "state" : "TN"} , { "biggestCity" : { "name" : "HOUSTON" , "pop" : 2095918} , "smallestCity" : { "name" : "ECLETO" , "pop" : 0} , "state" : "TX"} , { "biggestCity" : { "name" : "SALT LAKE CITY" , "pop" : 186346} , "smallestCity" : { "name" : "MODENA" , "pop" : 9} , "state" : "UT"} , { "biggestCity" : { "name" : "VIRGINIA BEACH" , "pop" : 385080} , "smallestCity" : { "name" : "WALLOPS ISLAND" , "pop" : 0} , "state" : "VA"} , { "biggestCity" : { "name" : "BURLINGTON" , "pop" : 39127} , "smallestCity" : { "name" : "UNIV OF VERMONT" , "pop" : 0} , "state" : "VT"} , { "biggestCity" : { "name" : "SEATTLE" , "pop" : 520096} , "smallestCity" : { "name" : "BENGE" , "pop" : 2} , "state" : "WA"} , { "biggestCity" : { "name" : "MILWAUKEE" , "pop" : 597324} , "smallestCity" : { "name" : "CLAM LAKE" , "pop" : 2} , "state" : "WI"} , { "biggestCity" : { "name" : "HUNTINGTON" , "pop" : 75343} , "smallestCity" : { "name" : "MOUNT CARBON" , "pop" : 0} , "state" : "WV"} , { "biggestCity" : { "name" : "CHEYENNE" , "pop" : 70185} , "smallestCity" : { "name" : "LOST SPRINGS" , "pop" : 6} , "state" : "WY"}]

File src/test/resources/org/bitbucket/davidm24/mongodb/aggregate/statesWithPopulationsOverTenMillionTest.expected.command.json

-{ "aggregate" : "zipcodes" , "pipeline" : [ { "$group" : { "_id" : "$state" , "totalPop" : { "$sum" : "$pop"}}} , { "$match" : { "totalPop" : { "$gte" : 10000000}}}]}
+{ "aggregate" : "zipcodes" , "pipeline" : [ { "$group" : { "_id" : "$state" , "totalPop" : { "$sum" : "$pop"}}} , { "$match" : { "totalPop" : { "$gte" : 10000000}}} , { "$sort" : { "_id" : 1}}]}]