diff --git a/audits/catalog/documented-examples.json b/audits/catalog/documented-examples.json index 3c5885aaa4a..fa7199b9054 100644 --- a/audits/catalog/documented-examples.json +++ b/audits/catalog/documented-examples.json @@ -541,23 +541,11 @@ "stem" : null, "title" : "Bitwise ``AND`` with Two Integers " }, { - "blocks" : [ { - "role" : "ACTION", - "sha256" : "1aadffa313a8052ccf34cccc5fc442e15db9580eb0fd3fdb90a60d883f7432fe", - "text" : "db.switches.aggregate( [\n { \n $project: { \n result: { \n $bitAnd: [ \"$a\", Long(\"63\") ]\n }\n }\n }\n])" - }, { - "role" : "DATA", - "sha256" : "b2a88d93c5c6a57747258e1afb0a59e50d7153194b9683d1440687a755ae7900", - "text" : "db.switches.insertMany( [\n { _id: 0, a: Int32(0), b: Int32(127) },\n { _id: 1, a: Int32(2), b: Int32(3) },\n { _id: 2, a: Int32(3), b: Int32(5) }\n] )" - }, { - "role" : "EXPECTED", - "sha256" : "dd4f6c27a92b2caf6a7525bb9626602b11d80f5681ee5178b65be76ffe8a1d70", - "text" : "[\n { _id: 0, result: Long(\"0\") }\n { _id: 1, result: Long(\"2\") }\n { _id: 2, result: Long(\"3\") }\n]" - } ], - "detail" : null, - "owner" : null, - "status" : "UNOWNED", - "stem" : "bitwiseAndWithALongAndInteger", + "blocks" : [ ], + "detail" : "matched by name", + "owner" : "aggregation/expressions/bitAnd/bitwiseAndWithALongAndInteger", + "status" : "OWNED", + "stem" : null, "title" : "Bitwise ``AND`` with a Long and Integer " } ], "includes" : [ { @@ -611,23 +599,11 @@ "stem" : null, "title" : "Bitwise ``OR`` with Two Integers " }, { - "blocks" : [ { - "role" : "ACTION", - "sha256" : "3562bc55bfdf8a9d74f6a100315321a7eead79236e79543ef138d8a2915fab16", - "text" : "db.switches.aggregate( [\n { \n $project: { \n result: { \n $bitOr: [ \"$a\", Long(\"63\") ]\n }\n }\n }\n])" - }, { - "role" : "DATA", - "sha256" : "b2a88d93c5c6a57747258e1afb0a59e50d7153194b9683d1440687a755ae7900", - "text" : "db.switches.insertMany( [\n { _id: 0, a: Int32(0), b: Int32(127) },\n { _id: 1, a: Int32(2), b: Int32(3) },\n { _id: 2, a: Int32(3), b: Int32(5) }\n] )" - }, { - "role" : "EXPECTED", - "sha256" : "7f781c5dcb9db120b52f2671a70c7570d3a97f2b99b67d3b72116fc9d44f5703", - "text" : "[\n { _id: 0, result: Long(\"0\") },\n { _id: 1, result: Long(\"2\") },\n { _id: 2, result: Long(\"3\") }\n]" - } ], - "detail" : null, - "owner" : null, - "status" : "UNOWNED", - "stem" : "bitwiseOrWithALongAndInteger", + "blocks" : [ ], + "detail" : "matched by name", + "owner" : "aggregation/expressions/bitOr/bitwiseOrWithALongAndInteger", + "status" : "OWNED", + "stem" : null, "title" : "Bitwise ``OR`` with a Long and Integer " } ], "includes" : [ { @@ -6551,19 +6527,11 @@ "stem" : null, "title" : "Adding Fields to an Embedded Document" }, { - "blocks" : [ { - "role" : "ACTION", - "sha256" : "20083a5b7334419a85db9485000aef46fbcb3bec0e50fcb93c7693f1e9bb867e", - "text" : "db.movies.aggregate( [\n { $match: { runtime: { $gt: 1000 } } },\n {\n $addFields: { runtime: { $add: [ \"$runtime\", 15 ] } }\n }\n] )" - }, { - "role" : "EXPECTED", - "sha256" : "08430c1f571f50d496021e8d16151661684de58f4a9a89e0e9ae2b21354a6f3a", - "text" : "[\n { _id: ..., title: 'Baseball', runtime: 1155 },\n { _id: ..., title: 'Centennial', runtime: 1271 }\n]\n..." - } ], - "detail" : null, - "owner" : null, - "status" : "UNOWNED", - "stem" : "overwritingAnExistingField", + "blocks" : [ ], + "detail" : "matched by name", + "owner" : "aggregation/stages/addFields/overwritingAnExistingField", + "status" : "OWNED", + "stem" : null, "title" : "Overwriting an Existing Field" }, { "blocks" : [ ], @@ -8270,19 +8238,11 @@ "stem" : null, "title" : "Include Specific Fields in Output Documents" }, { - "blocks" : [ { - "role" : "ACTION", - "sha256" : "47227f0bf20295cd3cd125bd7d4cd6f3f0438e742f2c18bf2db95bb6cf52c337", - "text" : "db.movies.aggregate( [\n { $match: { title: \"The Great Train Robbery\" } },\n { $project : { _id: 0, title : 1, rated : 1 } },\n { $limit: 1 }\n] )" - }, { - "role" : "EXPECTED", - "sha256" : "628c71d12c7b97c6ea537334bec0def92e30aa9a96c9ca4e294eac10b8178f8c", - "text" : "[ { title: 'The Great Train Robbery', rated: 'TV-G' } ]" - } ], - "detail" : null, - "owner" : null, - "status" : "UNOWNED", - "stem" : "suppressIdFieldInTheOutputDocuments", + "blocks" : [ ], + "detail" : "matched by name", + "owner" : "aggregation/stages/project/suppressIdFieldInTheOutputDocuments", + "status" : "OWNED", + "stem" : null, "title" : "Suppress _id Field in the Output Documents" }, { "blocks" : [ ], @@ -8941,19 +8901,11 @@ "stem" : null, "title" : "Adding Fields to an Embedded Document" }, { - "blocks" : [ { - "role" : "ACTION", - "sha256" : "3b807cf2d4c9b9770f5340a630371b891ac255770c1a963ce3ca51ba36867cd2", - "text" : "db.movies.aggregate( [\n { $match: { title: \"Baseball\" } },\n { $set: { rated: \"UNRATED\" } }\n] )" - }, { - "role" : "EXPECTED", - "sha256" : "38ac7d3b077d70fc4407b44cea604a7ad530877aadf8aadb269858501d853f8a", - "text" : "[\n { _id: ..., title: 'Baseball', rated: 'UNRATED' }\n]\n..." - } ], - "detail" : null, - "owner" : null, - "status" : "UNOWNED", - "stem" : "overwritingAnExistingField", + "blocks" : [ ], + "detail" : "matched by name", + "owner" : "aggregation/stages/set/overwritingAnExistingField", + "status" : "OWNED", + "stem" : null, "title" : "Overwriting an Existing Field" }, { "blocks" : [ ], @@ -9545,19 +9497,11 @@ "stem" : null, "title" : "Missing or Non-array Values" }, { - "blocks" : [ { - "role" : "ACTION", - "sha256" : "c921bbbb4ec17afad0e42edf95716db567e167f3231b1e4651f3d64301adf106", - "text" : "db.movies.aggregate( [\n {\n $match: {\n title: {\n $in: [\n \"Inception\",\n \"Brave\",\n \"La porta del cielo\",\n \"Neecha Nagar\"\n ]\n }\n }\n },\n { $project: { _id: 0, title: 1, genres: 1 } },\n {\n $unwind: {\n path: \"$genres\",\n preserveNullAndEmptyArrays: true\n }\n }\n] )" - }, { - "role" : "EXPECTED", - "sha256" : "d0053fa65e56cd16ee5a9469c86fbf4cd0e3d116a23565c4545a520ad0c0977d", - "text" : "[\n {\n title: 'La porta del cielo'\n },\n {\n title: 'Neecha Nagar'\n },\n {\n genres: 'Animation',\n title: 'Brave'\n },\n {\n genres: 'Adventure',\n title: 'Brave'\n },\n {\n genres: 'Comedy',\n title: 'Brave'\n },\n {\n genres: 'Action',\n title: 'Inception'\n },\n {\n genres: 'Mystery',\n title: 'Inception'\n },\n {\n genres: 'Sci-Fi',\n title: 'Inception'\n }\n]" - } ], - "detail" : null, - "owner" : null, - "status" : "UNOWNED", - "stem" : "preserveNullAndEmptyArraysAndIncludeArrayIndex", + "blocks" : [ ], + "detail" : "matched by name", + "owner" : "aggregation/stages/unwind/preserveNullAndEmptyArraysAndIncludeArrayIndex", + "status" : "OWNED", + "stem" : null, "title" : "preserveNullAndEmptyArrays and includeArrayIndex" }, { "blocks" : [ ], @@ -10134,19 +10078,11 @@ }, { "context" : "query/filters", "examples" : [ { - "blocks" : [ { - "role" : "ACTION", - "sha256" : "6f38e367f7b7fb2449061ac27968800152d980828cf8792dfe638db14b883d05", - "text" : "db.movies.find(\n { $expr: { $gt: [ \"$tomatoes.viewer.rating\", \"$tomatoes.critic.rating\" ] } },\n { _id: 0, title: 1, \"tomatoes.viewer.rating\": 1, \"tomatoes.critic.rating\": 1 }\n).sort( { \"tomatoes.viewer.rating\": -1 } ).limit( 3 )" - }, { - "role" : "EXPECTED", - "sha256" : "4e9959f8cd9aac85c128f28a5b112d8f23a30bcb9ea3ca0ad6506aad5c112973", - "text" : "[\n { title: 'I Am Maria', tomatoes: { viewer: { rating: 5 } } },\n { title: 'Kadin Hamlet', tomatoes: { viewer: { rating: 5 } } },\n { title: 'The Seine Meets Paris', tomatoes: { viewer: { rating: 5 } } }\n]" - } ], - "detail" : null, - "owner" : null, - "status" : "UNOWNED", - "stem" : "compareTwoFieldsFromASingleDocument", + "blocks" : [ ], + "detail" : "matched by name", + "owner" : "query/filters/expr/compareTwoFieldsFromASingleDocument", + "status" : "OWNED", + "stem" : null, "title" : "Compare Two Fields from a Single Document" }, { "blocks" : [ ], @@ -12718,9 +12654,9 @@ "sourceRepository" : "mongodb/docs", "summary" : { "examples.ambiguous" : 0, - "examples.owned" : 437, + "examples.owned" : 444, "examples.unnamed" : 0, - "examples.unowned" : 145, + "examples.unowned" : 138, "pages" : 297, "pages.skipped" : 3, "reviews.stale" : 0 diff --git a/audits/catalog/dsl-bindings.json b/audits/catalog/dsl-bindings.json index 0ca035c64dc..90e71035a44 100644 --- a/audits/catalog/dsl-bindings.json +++ b/audits/catalog/dsl-bindings.json @@ -16,6 +16,35 @@ "options": {}, "fields": {} }, + { + "operator": "$addToSet", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "addToSet", + "parameters": [ + "java.lang.Object" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, + { + "operator": "$avg", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "avg", + "parameters": [ + "java.lang.Object", + "java.lang.Object[]" + ], + "varargs": true, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$bitAnd", "position": "EXPRESSION", @@ -190,6 +219,20 @@ "varargs": false, "fields": {} }, + { + "operator": "$first", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "first", + "parameters": [ + "java.lang.Object" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$firstN", "position": "EXPRESSION", @@ -208,6 +251,20 @@ "options": {}, "fields": {} }, + { + "operator": "$last", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "last", + "parameters": [ + "java.lang.Object" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$lastN", "position": "EXPRESSION", @@ -251,6 +308,21 @@ }, "fields": {} }, + { + "operator": "$max", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "max", + "parameters": [ + "java.lang.Object", + "java.lang.Object[]" + ], + "varargs": true, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$maxN", "position": "EXPRESSION", @@ -269,6 +341,21 @@ "options": {}, "fields": {} }, + { + "operator": "$min", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "min", + "parameters": [ + "java.lang.Object", + "java.lang.Object[]" + ], + "varargs": true, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$minN", "position": "EXPRESSION", @@ -302,6 +389,35 @@ "options": {}, "fields": {} }, + { + "operator": "$multiply", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.MathExpressions", + "method": "multiply", + "parameters": [ + "java.lang.Object", + "java.lang.Object[]" + ], + "varargs": true, + "arguments": [], + "options": {}, + "fields": {} + }, + { + "operator": "$push", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "push", + "parameters": [ + "java.lang.Object" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$reduce", "position": "EXPRESSION", @@ -362,6 +478,21 @@ "varargs": false, "fields": {} }, + { + "operator": "$sum", + "position": "EXPRESSION", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.expressions.AccumulatorExpressions", + "method": "sum", + "parameters": [ + "java.lang.Object", + "java.lang.Object[]" + ], + "varargs": true, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$toString", "position": "EXPRESSION", @@ -567,6 +698,20 @@ "arguments": [], "options": {} }, + { + "operator": "$count", + "position": "STAGE", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.stages.Count", + "method": "count", + "parameters": [ + "java.lang.String" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$group", "position": "STAGE", @@ -595,6 +740,20 @@ } } }, + { + "operator": "$limit", + "position": "STAGE", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.stages.Limit", + "method": "limit", + "parameters": [ + "long" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$match", "position": "STAGE", @@ -665,6 +824,20 @@ "arguments": [], "options": {} }, + { + "operator": "$skip", + "position": "STAGE", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.stages.Skip", + "method": "skip", + "parameters": [ + "long" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$sort", "position": "STAGE", @@ -692,6 +865,20 @@ } } }, + { + "operator": "$sortByCount", + "position": "STAGE", + "form": "POSITIONAL", + "owner": "dev.morphia.aggregation.stages.SortByCount", + "method": "sortByCount", + "parameters": [ + "java.lang.Object" + ], + "varargs": false, + "arguments": [], + "options": {}, + "fields": {} + }, { "operator": "$unwind", "position": "STAGE", diff --git a/audits/catalog/generation-review.json b/audits/catalog/generation-review.json index 2ac82a9fb86..30822b46e3e 100644 --- a/audits/catalog/generation-review.json +++ b/audits/catalog/generation-review.json @@ -2,14 +2,11 @@ "schemaVersion": 1, "families": [ "aggregation/expressions", + "aggregation/stages", "query/filters", "query/updates" ], "excluded": [ - { - "name": "aggregation/expressions/bitOr/bitwiseOrWithALongAndInteger", - "reason": "The page prints $bitAnd's results: it shows Long(\"0\"), Long(\"2\") and Long(\"3\"), but a | 63 is 63 for each document, which is what the server returns. Serialization and behavior pass; the page is wrong." - }, { "name": "aggregation/expressions/dateDiff/yearBoundaryCrossing", "reason": "$dateDiff returns a long, which mongosh prints as Long('1'); the page prints 1, which only an Int32 or a Double prints as. Serialization and behavior pass." diff --git a/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt b/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt index 79bd31b1759..d2e255a04da 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/generate/CaseGenerator.kt @@ -630,6 +630,12 @@ object CaseGenerator { STRING -> if (value.isString) literal(value.asString().value) else throw Unbound("$path: ${value.bsonType} where $type is required") + "long" -> + when { + value.isInt32 -> "${value.asInt32().value}" + value.isInt64 -> "${value.asInt64().value}L" + else -> throw Unbound("$path: ${value.bsonType} where $type is required") + } NUMBER -> when { value.isInt32 -> "${value.asInt32().value}" diff --git a/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt b/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt index f314fec6bdc..7a47b5f62bc 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/generate/DocumentedExamples.kt @@ -32,8 +32,8 @@ enum class ExampleStatus { /** * One example on a current page. [owner] is the owning fixture, by title or, when the title changed - * since the fixture was written, by its action text. An unowned example keeps its source [blocks], - * so generation never needs the page. + * since the fixture was written, by its action text or its descriptive name. An unowned example + * keeps its source [blocks], so generation never needs the page. */ data class DocumentedExample( val title: String, @@ -229,8 +229,13 @@ object DocumentedExamples { val byAction = if (byTitle.isNotEmpty() || action == null) emptyList() else owners.filter { it.action != null && it.action in action } - val matched = byTitle.ifEmpty { byAction } val stem = stems[index] + // The descriptive-name backport named each fixture for its example, so a fixture with + // the example's name owns it even when the title or action text has changed since. + val byName = + if (byTitle.isNotEmpty() || byAction.isNotEmpty() || stem == null) emptyList() + else owners.filter { it.fixture.substringAfterLast('/') == stem } + val matched = byTitle.ifEmpty { byAction }.ifEmpty { byName } when { review?.owner != null -> if (matched.any { it.fixture == review.owner }) @@ -265,7 +270,12 @@ object DocumentedExamples { title, ExampleStatus.OWNED, owner = matched.single().fixture, - detail = if (byTitle.isEmpty()) "matched by action text" else null, + detail = + when { + byTitle.isNotEmpty() -> null + byAction.isNotEmpty() -> "matched by action text" + else -> "matched by name" + }, name = name, ) stem == null -> diff --git a/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt b/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt index 6a6b3420b2b..e1fc8ce4f7b 100644 --- a/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt +++ b/audits/src/test/kotlin/dev/morphia/audits/offline/GeneratorTest.kt @@ -287,6 +287,35 @@ class GeneratorTest { ) } + /** + * A fixture named for an example owns it even when its title and action text have changed since + * the fixture was written. + */ + @Test + fun aFixtureWithTheExamplesNameOwnsIt() { + write( + directory.resolve( + "repository/core/src/test/resources/dev/morphia/test/aggregation/expressions/bitOr/" + + "bitwiseOrWithALongAndInteger/name" + ), + "Bitwise OR with a Long\n", + ) + val example = + inventory() + .pages + .single { it.operator == "bitOr" } + .examples + .single { it.title == "Bitwise ``OR`` with a Long and Integer" } + assertEquals( + Triple( + ExampleStatus.OWNED, + "aggregation/expressions/bitOr/bitwiseOrWithALongAndInteger", + "matched by name", + ), + Triple(example.status, example.owner, example.detail), + ) + } + /** A reviewed name stands in for a generic title; a stale review is counted, not applied. */ @Test fun reviewedNamesResolveGenericTitles() { @@ -680,7 +709,12 @@ class GeneratorTest { val review = AuditJson.generationReview(Files.readString(root.resolve(CaseGenerator.REVIEW))) assertEquals( - listOf("aggregation/expressions", "query/filters", "query/updates"), + listOf( + "aggregation/expressions", + "aggregation/stages", + "query/filters", + "query/updates", + ), review.families, ) // The inventory's recorded source text is what generation reads; its digests must hold. diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestAddToSet.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestAddToSet.java new file mode 100644 index 00000000000..7d98c3c7a03 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestAddToSet.java @@ -0,0 +1,35 @@ +// spotless:off +package dev.morphia.test.generated.expressions; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.expressions.AccumulatorExpressions.addToSet; +import static dev.morphia.aggregation.stages.Group.group; +import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Limit.limit; +import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.aggregation.stages.Unwind.unwind; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestAddToSet extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Collect the Genres of Each Director") + public void collectTheGenresOfEachDirector() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/addToSet/collectTheGenresOfEachDirector/scenario.json"), + (aggregation) -> aggregation.pipeline( + unwind("$directors"), + unwind("$genres"), + group(id("$directors")).field("genres", addToSet("$genres")), + sort().ascending("_id"), + limit(5))); + } +} +// spotless:on diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestBottomN.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestBottomN.java index af1677a2ba2..f0d934e753b 100644 --- a/core/src/test/java/dev/morphia/test/generated/expressions/TestBottomN.java +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestBottomN.java @@ -12,7 +12,10 @@ import static dev.morphia.aggregation.expressions.ArrayExpressions.array; import static dev.morphia.aggregation.stages.Group.group; import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Limit.limit; import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.aggregation.stages.Unwind.unwind; import static dev.morphia.query.Sort.ascending; import static dev.morphia.query.Sort.descending; import static dev.morphia.query.filters.Filters.eq; @@ -22,6 +25,19 @@ public class TestBottomN extends TestBase { private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + @Test + @DisplayName("Find the Lowest Rated Movies for Each Genre") + public void findTheLowestRatedMoviesForEachGenre() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheLowestRatedMoviesForEachGenre/scenario.json"), + (aggregation) -> aggregation.pipeline( + unwind("$genres"), + match(exists("imdb.rating")), + group(id("$genres")).field("lowestRatedMovie", bottomN(3, array("$title", "$imdb.rating"), descending("imdb.rating"), ascending("title"))), + sort().ascending("_id"), + limit(5))); + } + @Test @DisplayName("Find the Three Lowest Rated Movies in a Single Genre") public void findTheThreeLowestRatedMoviesInASingleGenre() { diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestFirst.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestFirst.java new file mode 100644 index 00000000000..b56b3326e11 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestFirst.java @@ -0,0 +1,35 @@ +// spotless:off +package dev.morphia.test.generated.expressions; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.expressions.AccumulatorExpressions.first; +import static dev.morphia.aggregation.stages.Group.group; +import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Limit.limit; +import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.aggregation.stages.Unwind.unwind; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestFirst extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Find the First Movie in Each Genre") + public void findTheFirstMovieInEachGenre() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/first/findTheFirstMovieInEachGenre/scenario.json"), + (aggregation) -> aggregation.pipeline( + sort().ascending("year").ascending("title"), + unwind("$genres"), + group(id("$genres")).field("firstMovieTitle", first("$title")).field("firstMovieYear", first("$year")), + sort().ascending("_id"), + limit(5))); + } +} +// spotless:on diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestFirstN.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestFirstN.java index f6b1fc7c2f5..5c8e0df8c7d 100644 --- a/core/src/test/java/dev/morphia/test/generated/expressions/TestFirstN.java +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestFirstN.java @@ -12,14 +12,29 @@ import static dev.morphia.aggregation.expressions.ArrayExpressions.array; import static dev.morphia.aggregation.stages.Group.group; import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Limit.limit; import static dev.morphia.aggregation.stages.Match.match; import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.aggregation.stages.Unwind.unwind; import static dev.morphia.query.filters.Filters.eq; /** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ public class TestFirstN extends TestBase { private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + @Test + @DisplayName("Find the First Three Movies Across Multiple Genres") + public void findTheFirstThreeMoviesAcrossMultipleGenres() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres/scenario.json"), + (aggregation) -> aggregation.pipeline( + unwind("$genres"), + sort().ascending("year"), + group(id("$genres")).field("movies", firstN(3, array("$title", "$year"))), + sort().ascending("_id"), + limit(5))); + } + @Test @DisplayName("Find the First Three Movies for a Single Genre") public void findTheFirstThreeMoviesForASingleGenre() { diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestMinN.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestMinN.java index 3ab8d457eb4..ea7a36bec1f 100644 --- a/core/src/test/java/dev/morphia/test/generated/expressions/TestMinN.java +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestMinN.java @@ -11,13 +11,28 @@ import static dev.morphia.aggregation.expressions.AccumulatorExpressions.minN; import static dev.morphia.aggregation.stages.Group.group; import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Limit.limit; import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.aggregation.stages.Unwind.unwind; import static dev.morphia.query.filters.Filters.eq; /** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ public class TestMinN extends TestBase { private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + @Test + @DisplayName("Find the Minimum Three Ratings Across Multiple Genres") + public void findTheMinimumThreeRatingsAcrossMultipleGenres() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres/scenario.json"), + (aggregation) -> aggregation.pipeline( + unwind("$genres"), + group(id("$genres")).field("minThreeRatings", minN(3, "$imdb.rating")), + sort().ascending("_id"), + limit(5))); + } + @Test @DisplayName("Find the Minimum Three Ratings for a Single Genre") public void findTheMinimumThreeRatingsForASingleGenre() { diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestPush.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestPush.java new file mode 100644 index 00000000000..828424058b7 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestPush.java @@ -0,0 +1,43 @@ +// spotless:off +package dev.morphia.test.generated.expressions; + +import java.util.List; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.expressions.AccumulatorExpressions.first; +import static dev.morphia.aggregation.expressions.AccumulatorExpressions.push; +import static dev.morphia.aggregation.stages.Group.group; +import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Limit.limit; +import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.aggregation.stages.Unwind.unwind; +import static dev.morphia.query.filters.Filters.exists; +import static dev.morphia.query.filters.Filters.gte; +import static dev.morphia.query.filters.Filters.lte; +import static dev.morphia.query.filters.Filters.ne; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestPush extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Collect the First Genre of Each Director's Movies") + public void collectTheFirstGenreOfEachDirectorSMovies() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/push/collectTheFirstGenreOfEachDirectorSMovies/scenario.json"), + (aggregation) -> aggregation.pipeline( + match(gte("year", 2010), lte("year", 2015), exists("genres"), ne("genres", List.of()), exists("directors"), ne("directors", List.of())), + unwind("$directors"), + group(id("$directors")).field("genres", push(first("$genres"))), + sort().ascending("_id"), + limit(5))); + } +} +// spotless:on diff --git a/core/src/test/java/dev/morphia/test/generated/expressions/TestTopN.java b/core/src/test/java/dev/morphia/test/generated/expressions/TestTopN.java index 6cccdd2c7c3..ba380b09a82 100644 --- a/core/src/test/java/dev/morphia/test/generated/expressions/TestTopN.java +++ b/core/src/test/java/dev/morphia/test/generated/expressions/TestTopN.java @@ -12,7 +12,10 @@ import static dev.morphia.aggregation.expressions.ArrayExpressions.array; import static dev.morphia.aggregation.stages.Group.group; import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Limit.limit; import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.aggregation.stages.Sort.sort; +import static dev.morphia.aggregation.stages.Unwind.unwind; import static dev.morphia.query.Sort.ascending; import static dev.morphia.query.Sort.descending; import static dev.morphia.query.filters.Filters.eq; @@ -22,6 +25,19 @@ public class TestTopN extends TestBase { private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + @Test + @DisplayName("Find the Highest-Rated Movies for Each Genre") + public void findTheHighestRatedMoviesForEachGenre() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/expressions/topN/findTheHighestRatedMoviesForEachGenre/scenario.json"), + (aggregation) -> aggregation.pipeline( + unwind("$genres"), + match(gt("imdb.rating", 0)), + group(id("$genres")).field("topRatedMovies", topN(3, array("$title", "$imdb.rating"), descending("imdb.rating"), ascending("title"))), + sort().ascending("_id"), + limit(5))); + } + @Test @DisplayName("Find the Three Highest-Rated Movies in a Single Genre") public void findTheThreeHighestRatedMoviesInASingleGenre() { diff --git a/core/src/test/java/dev/morphia/test/generated/stages/TestGroup.java b/core/src/test/java/dev/morphia/test/generated/stages/TestGroup.java new file mode 100644 index 00000000000..2b99525cfb3 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/stages/TestGroup.java @@ -0,0 +1,31 @@ +// spotless:off +package dev.morphia.test.generated.stages; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.expressions.AccumulatorExpressions.sum; +import static dev.morphia.aggregation.stages.Group.group; +import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.query.filters.Filters.gte; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestGroup extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Group by Rating") + public void groupByRating() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/stages/group/groupByRating/scenario.json"), + (aggregation) -> aggregation.pipeline( + group(id("$rated")).field("totalRuntime", sum("$runtime")), + match(gte("totalRuntime", 100000)))); + } +} +// spotless:on diff --git a/core/src/test/java/dev/morphia/test/generated/stages/TestProject.java b/core/src/test/java/dev/morphia/test/generated/stages/TestProject.java new file mode 100644 index 00000000000..6e1579eab07 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/stages/TestProject.java @@ -0,0 +1,43 @@ +// spotless:off +package dev.morphia.test.generated.stages; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.expressions.ArrayExpressions.array; +import static dev.morphia.aggregation.stages.Limit.limit; +import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.aggregation.stages.Projection.project; +import static dev.morphia.query.filters.Filters.eq; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestProject extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Exclude Fields from Embedded Documents") + public void excludeFieldsFromEmbeddedDocuments() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/stages/project/excludeFieldsFromEmbeddedDocuments/scenario.json"), + (aggregation) -> aggregation.pipeline( + match(eq("title", "The Great Train Robbery")), + project().exclude("imdb.id").exclude("type"), + limit(1))); + } + + @Test + @DisplayName("Project New Array Fields") + public void projectNewArrayFields() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/stages/project/projectNewArrayFields/scenario.json"), + (aggregation) -> aggregation.pipeline( + match(eq("title", "The Great Train Robbery")), + project().include("myArray", array("$year", "$runtime")), + limit(1))); + } +} +// spotless:on diff --git a/core/src/test/java/dev/morphia/test/generated/stages/TestSort.java b/core/src/test/java/dev/morphia/test/generated/stages/TestSort.java new file mode 100644 index 00000000000..20bd42c64bb --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/stages/TestSort.java @@ -0,0 +1,28 @@ +// spotless:off +package dev.morphia.test.generated.stages; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.stages.Limit.limit; +import static dev.morphia.aggregation.stages.Sort.sort; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestSort extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Ascending and Descending Sort") + public void ascendingAndDescendingSort() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/stages/sort/ascendingAndDescendingSort/scenario.json"), + (aggregation) -> aggregation.pipeline( + sort().descending("year").ascending("title"), + limit(5))); + } +} +// spotless:on diff --git a/core/src/test/java/dev/morphia/test/generated/stages/TestUnwind.java b/core/src/test/java/dev/morphia/test/generated/stages/TestUnwind.java new file mode 100644 index 00000000000..047e3918778 --- /dev/null +++ b/core/src/test/java/dev/morphia/test/generated/stages/TestUnwind.java @@ -0,0 +1,38 @@ +// spotless:off +package dev.morphia.test.generated.stages; + +import java.util.List; + +import dev.morphia.test.OperatorCase; +import dev.morphia.test.OperatorCaseRunner; +import dev.morphia.test.TestBase; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static dev.morphia.aggregation.expressions.AccumulatorExpressions.sum; +import static dev.morphia.aggregation.stages.Group.group; +import static dev.morphia.aggregation.stages.Group.id; +import static dev.morphia.aggregation.stages.Match.match; +import static dev.morphia.aggregation.stages.Projection.project; +import static dev.morphia.aggregation.stages.Unwind.unwind; +import static dev.morphia.query.filters.Filters.in; + +/** Generated by GenerateMainKt from audits/catalog/documented-examples.json; do not edit. */ +public class TestUnwind extends TestBase { + private final OperatorCaseRunner runner = new OperatorCaseRunner(this); + + @Test + @DisplayName("Unwind Multiple Array Fields") + public void unwindMultipleArrayFields() { + runner.aggregate( + OperatorCase.of("/dev/morphia/test/generated/fixtures/stages/unwind/unwindMultipleArrayFields/scenario.json"), + (aggregation) -> aggregation.pipeline( + match(in("title", List.of("Inception", "The Dark Knight", "Interstellar"))), + project().suppressId().include("title").include("genres").include("cast"), + unwind("$genres"), + unwind("$cast"), + group(id("$genres")).field("castAppearances", sum(1)))); + } +} +// spotless:on diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/addToSet/collectTheGenresOfEachDirector/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/addToSet/collectTheGenresOfEachDirector/scenario.json new file mode 100644 index 00000000000..66f6b253c06 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/addToSet/collectTheGenresOfEachDirector/scenario.json @@ -0,0 +1,190 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/addToSet/collectTheGenresOfEachDirector", + "title": "Collect the Genres of Each Director", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/addToSet.txt", + "blob": "0ce8087c09957d3d8a7ded7498b8162ce0ab553a" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$unwind": "$directors" + }, + { + "$unwind": "$genres" + }, + { + "$group": { + "_id": "$directors", + "genres": { + "$addToSet": "$genres" + } + } + }, + { + "$sort": { + "_id": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "A. Dean Bell" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Crime" + }, + { + "text": "Drama" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "A. Karunakaran" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Romance" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "A. Vanichkin" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Animation" + }, + { + "text": "Fantasy" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "A.J. Edwards" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Biography" + }, + { + "text": "Drama" + }, + { + "text": "History" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "A.R. Murugadoss" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Drama" + }, + { + "text": "Sci-Fi" + }, + { + "text": "Thriller" + }, + { + "text": "Action" + }, + { + "text": "Mystery" + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheLowestRatedMoviesForEachGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheLowestRatedMoviesForEachGenre/scenario.json new file mode 100644 index 00000000000..44897f2edc2 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheLowestRatedMoviesForEachGenre/scenario.json @@ -0,0 +1,353 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/bottomN/findTheLowestRatedMoviesForEachGenre", + "title": "Find the Lowest Rated Movies for Each Genre", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/bottomN.txt", + "blob": "e889d2a459bf25885175611a49408f65c55394f4" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$unwind": "$genres" + }, + { + "$match": { + "imdb.rating": { + "$exists": true + } + } + }, + { + "$group": { + "_id": "$genres", + "lowestRatedMovie": { + "$bottomN": { + "output": [ + "$title", + "$imdb.rating" + ], + "sortBy": { + "imdb.rating": { + "$numberInt": "-1" + }, + "title": { + "$numberInt": "1" + } + }, + "n": { + "$numberInt": "3" + } + } + } + } + }, + { + "$sort": { + "_id": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "Action" + } + }, + { + "name": "lowestRatedMovie", + "value": { + "array": [ + { + "array": [ + { + "text": "Starship: Rising" + }, + { + "exact": { + "$numberDouble": "2.1" + } + } + ] + }, + { + "array": [ + { + "text": "House of the Dead" + }, + { + "whole": { + "$numberInt": "2" + } + } + ] + }, + { + "array": [ + { + "text": "Krampus: The Christmas Devil" + }, + { + "whole": { + "$numberInt": "2" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Adventure" + } + }, + { + "name": "lowestRatedMovie", + "value": { + "array": [ + { + "array": [ + { + "text": "Battlefield Earth" + }, + { + "exact": { + "$numberDouble": "2.4" + } + } + ] + }, + { + "array": [ + { + "text": "Epic Movie" + }, + { + "exact": { + "$numberDouble": "2.3" + } + } + ] + }, + { + "array": [ + { + "text": "Son of the Mask" + }, + { + "exact": { + "$numberDouble": "2.1" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Animation" + } + }, + { + "name": "lowestRatedMovie", + "value": { + "array": [ + { + "array": [ + { + "text": "The Adventures of Rocky & Bullwinkle" + }, + { + "exact": { + "$numberDouble": "4.1" + } + } + ] + }, + { + "array": [ + { + "text": "The King and I" + }, + { + "whole": { + "$numberInt": "4" + } + } + ] + }, + { + "array": [ + { + "text": "Space Chimps 2: Zartog Strikes Back" + }, + { + "exact": { + "$numberDouble": "2.7" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Biography" + } + }, + { + "name": "lowestRatedMovie", + "value": { + "array": [ + { + "array": [ + { + "text": "Man in the Mirror: The Michael Jackson Story" + }, + { + "exact": { + "$numberDouble": "3.5" + } + } + ] + }, + { + "array": [ + { + "text": "The Gaul" + }, + { + "exact": { + "$numberDouble": "2.7" + } + } + ] + }, + { + "array": [ + { + "text": "The Undefeated" + }, + { + "exact": { + "$numberDouble": "2.3" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Comedy" + } + }, + { + "name": "lowestRatedMovie", + "value": { + "array": [ + { + "array": [ + { + "text": "Superbabies: Baby Geniuses 2" + }, + { + "exact": { + "$numberDouble": "1.9" + } + } + ] + }, + { + "array": [ + { + "text": "The Hottie & the Nottie" + }, + { + "exact": { + "$numberDouble": "1.9" + } + } + ] + }, + { + "array": [ + { + "text": "Saving Christmas" + }, + { + "exact": { + "$numberDouble": "1.6" + } + } + ] + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "NAMED_ARGUMENTS" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/first/findTheFirstMovieInEachGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/first/findTheFirstMovieInEachGenre/scenario.json new file mode 100644 index 00000000000..f0c607084ed --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/first/findTheFirstMovieInEachGenre/scenario.json @@ -0,0 +1,196 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/first/findTheFirstMovieInEachGenre", + "title": "Find the First Movie in Each Genre", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/first.txt", + "blob": "83ec8d6a7173ec8b9e2613dae6d82f74cb64a7e4" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$sort": { + "year": { + "$numberInt": "1" + }, + "title": { + "$numberInt": "1" + } + } + }, + { + "$unwind": "$genres" + }, + { + "$group": { + "_id": "$genres", + "firstMovieTitle": { + "$first": "$title" + }, + "firstMovieYear": { + "$first": "$year" + } + } + }, + { + "$sort": { + "_id": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "Action" + } + }, + { + "name": "firstMovieTitle", + "value": { + "text": "The Perils of Pauline" + } + }, + { + "name": "firstMovieYear", + "value": { + "whole": { + "$numberInt": "1914" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Adventure" + } + }, + { + "name": "firstMovieTitle", + "value": { + "text": "Robin Hood" + } + }, + { + "name": "firstMovieYear", + "value": { + "whole": { + "$numberInt": "1922" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Animation" + } + }, + { + "name": "firstMovieTitle", + "value": { + "text": "Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics" + } + }, + { + "name": "firstMovieYear", + "value": { + "whole": { + "$numberInt": "1911" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Biography" + } + }, + { + "name": "firstMovieTitle", + "value": { + "text": "Regeneration" + } + }, + { + "name": "firstMovieYear", + "value": { + "whole": { + "$numberInt": "1915" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Comedy" + } + }, + { + "name": "firstMovieTitle", + "value": { + "text": "Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics" + } + }, + { + "name": "firstMovieYear", + "value": { + "whole": { + "$numberInt": "1911" + } + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres/scenario.json new file mode 100644 index 00000000000..3232691b0f5 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres/scenario.json @@ -0,0 +1,345 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres", + "title": "Find the First Three Movies Across Multiple Genres", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/firstN.txt", + "blob": "0bc605aac52ba143b2d5c2f4be44cb68254dcafe" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$unwind": "$genres" + }, + { + "$sort": { + "year": { + "$numberInt": "1" + } + } + }, + { + "$group": { + "_id": "$genres", + "movies": { + "$firstN": { + "input": [ + "$title", + "$year" + ], + "n": { + "$numberInt": "3" + } + } + } + } + }, + { + "$sort": { + "_id": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "Action" + } + }, + { + "name": "movies", + "value": { + "array": [ + { + "array": [ + { + "text": "The Perils of Pauline" + }, + { + "whole": { + "$numberInt": "1914" + } + } + ] + }, + { + "array": [ + { + "text": "From Hand to Mouth" + }, + { + "whole": { + "$numberInt": "1919" + } + } + ] + }, + { + "array": [ + { + "text": "For Heaven's Sake" + }, + { + "whole": { + "$numberInt": "1926" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Adventure" + } + }, + { + "name": "movies", + "value": { + "array": [ + { + "array": [ + { + "text": "Robin Hood" + }, + { + "whole": { + "$numberInt": "1922" + } + } + ] + }, + { + "array": [ + { + "text": "Peter Pan" + }, + { + "whole": { + "$numberInt": "1924" + } + } + ] + }, + { + "array": [ + { + "text": "The Thief of Bagdad" + }, + { + "whole": { + "$numberInt": "1924" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Animation" + } + }, + { + "name": "movies", + "value": { + "array": [ + { + "array": [ + { + "text": "Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics" + }, + { + "whole": { + "$numberInt": "1911" + } + } + ] + }, + { + "array": [ + { + "text": "Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics" + }, + { + "whole": { + "$numberInt": "1911" + } + } + ] + }, + { + "array": [ + { + "text": "Gertie the Dinosaur" + }, + { + "whole": { + "$numberInt": "1914" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Biography" + } + }, + { + "name": "movies", + "value": { + "array": [ + { + "array": [ + { + "text": "Regeneration" + }, + { + "whole": { + "$numberInt": "1915" + } + } + ] + }, + { + "array": [ + { + "text": "Salomè" + }, + { + "whole": { + "$numberInt": "1922" + } + } + ] + }, + { + "array": [ + { + "text": "Napoleon" + }, + { + "whole": { + "$numberInt": "1927" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Comedy" + } + }, + { + "name": "movies", + "value": { + "array": [ + { + "array": [ + { + "text": "Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics" + }, + { + "whole": { + "$numberInt": "1911" + } + } + ] + }, + { + "array": [ + { + "text": "Winsor McCay, the Famous Cartoonist of the N.Y. Herald and His Moving Comics" + }, + { + "whole": { + "$numberInt": "1911" + } + } + ] + }, + { + "array": [ + { + "text": "Gertie the Dinosaur" + }, + { + "whole": { + "$numberInt": "1914" + } + } + ] + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "NAMED_ARGUMENTS" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres/scenario.json new file mode 100644 index 00000000000..62d9e1815cb --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres/scenario.json @@ -0,0 +1,230 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres", + "title": "Find the Minimum Three Ratings Across Multiple Genres", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/minN.txt", + "blob": "8a1f595f514f95f04f57ea98c2fbca7cd639200d" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$unwind": "$genres" + }, + { + "$group": { + "_id": "$genres", + "minThreeRatings": { + "$minN": { + "input": "$imdb.rating", + "n": { + "$numberInt": "3" + } + } + } + } + }, + { + "$sort": { + "_id": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "Action" + } + }, + { + "name": "minThreeRatings", + "value": { + "array": [ + { + "whole": { + "$numberInt": "2" + } + }, + { + "whole": { + "$numberInt": "2" + } + }, + { + "exact": { + "$numberDouble": "2.1" + } + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Adventure" + } + }, + { + "name": "minThreeRatings", + "value": { + "array": [ + { + "exact": { + "$numberDouble": "2.1" + } + }, + { + "exact": { + "$numberDouble": "2.3" + } + }, + { + "exact": { + "$numberDouble": "2.4" + } + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Animation" + } + }, + { + "name": "minThreeRatings", + "value": { + "array": [ + { + "exact": { + "$numberDouble": "2.7" + } + }, + { + "whole": { + "$numberInt": "4" + } + }, + { + "exact": { + "$numberDouble": "4.1" + } + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Biography" + } + }, + { + "name": "minThreeRatings", + "value": { + "array": [ + { + "exact": { + "$numberDouble": "2.3" + } + }, + { + "exact": { + "$numberDouble": "2.7" + } + }, + { + "exact": { + "$numberDouble": "3.5" + } + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Comedy" + } + }, + { + "name": "minThreeRatings", + "value": { + "array": [ + { + "exact": { + "$numberDouble": "1.6" + } + }, + { + "exact": { + "$numberDouble": "1.9" + } + }, + { + "exact": { + "$numberDouble": "1.9" + } + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "NAMED_ARGUMENTS" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/push/collectTheFirstGenreOfEachDirectorSMovies/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/push/collectTheFirstGenreOfEachDirectorSMovies/scenario.json new file mode 100644 index 00000000000..d9375c53c7c --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/push/collectTheFirstGenreOfEachDirectorSMovies/scenario.json @@ -0,0 +1,190 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/push/collectTheFirstGenreOfEachDirectorSMovies", + "title": "Collect the First Genre of Each Director's Movies", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/push.txt", + "blob": "250570a12dee3006848d643520a9bafe84fbd8b3" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$match": { + "year": { + "$gte": { + "$numberInt": "2010" + }, + "$lte": { + "$numberInt": "2015" + } + }, + "genres": { + "$exists": true, + "$ne": [] + }, + "directors": { + "$exists": true, + "$ne": [] + } + } + }, + { + "$unwind": "$directors" + }, + { + "$group": { + "_id": "$directors", + "genres": { + "$push": { + "$first": "$genres" + } + } + } + }, + { + "$sort": { + "_id": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "A. Karunakaran" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Romance" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "A.J. Edwards" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Biography" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "A.R. Murugadoss" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Action" + }, + { + "text": "Action" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "AJ Schnack" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Documentary" + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Aanand Rai" + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Comedy" + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "FIELD_OPERATORS_AND" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheHighestRatedMoviesForEachGenre/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheHighestRatedMoviesForEachGenre/scenario.json new file mode 100644 index 00000000000..a4e30169dd0 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheHighestRatedMoviesForEachGenre/scenario.json @@ -0,0 +1,355 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/expressions/topN/findTheHighestRatedMoviesForEachGenre", + "title": "Find the Highest-Rated Movies for Each Genre", + "context": "EXPRESSION", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/topN.txt", + "blob": "68fd3a1a63bbfa2718f454f01671d272aa12d972" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$unwind": "$genres" + }, + { + "$match": { + "imdb.rating": { + "$gt": { + "$numberInt": "0" + } + } + } + }, + { + "$group": { + "_id": "$genres", + "topRatedMovies": { + "$topN": { + "output": [ + "$title", + "$imdb.rating" + ], + "sortBy": { + "imdb.rating": { + "$numberInt": "-1" + }, + "title": { + "$numberInt": "1" + } + }, + "n": { + "$numberInt": "3" + } + } + } + } + }, + { + "$sort": { + "_id": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "Action" + } + }, + { + "name": "topRatedMovies", + "value": { + "array": [ + { + "array": [ + { + "text": "Band of Brothers" + }, + { + "exact": { + "$numberDouble": "9.6" + } + } + ] + }, + { + "array": [ + { + "text": "The Real Miyagi" + }, + { + "exact": { + "$numberDouble": "9.3" + } + } + ] + }, + { + "array": [ + { + "text": "The Dark Knight" + }, + { + "whole": { + "$numberInt": "9" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Adventure" + } + }, + { + "name": "topRatedMovies", + "value": { + "array": [ + { + "array": [ + { + "text": "Over the Garden Wall" + }, + { + "exact": { + "$numberDouble": "9.2" + } + } + ] + }, + { + "array": [ + { + "text": "Love is God" + }, + { + "exact": { + "$numberDouble": "8.9" + } + } + ] + }, + { + "array": [ + { + "text": "The Lord of the Rings: The Return of the King" + }, + { + "exact": { + "$numberDouble": "8.9" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Animation" + } + }, + { + "name": "topRatedMovies", + "value": { + "array": [ + { + "array": [ + { + "text": "Over the Garden Wall" + }, + { + "exact": { + "$numberDouble": "9.2" + } + } + ] + }, + { + "array": [ + { + "text": "Death Note" + }, + { + "whole": { + "$numberInt": "9" + } + } + ] + }, + { + "array": [ + { + "text": "Rabbit and Deer" + }, + { + "exact": { + "$numberDouble": "8.7" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Biography" + } + }, + { + "name": "topRatedMovies", + "value": { + "array": [ + { + "array": [ + { + "text": "A Brave Heart: The Lizzie Velasquez Story" + }, + { + "exact": { + "$numberDouble": "9.4" + } + } + ] + }, + { + "array": [ + { + "text": "Schindler's List" + }, + { + "exact": { + "$numberDouble": "8.9" + } + } + ] + }, + { + "array": [ + { + "text": "Shining Night: A Portrait of Composer Morten Lauridsen" + }, + { + "exact": { + "$numberDouble": "8.8" + } + } + ] + } + ] + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Comedy" + } + }, + { + "name": "topRatedMovies", + "value": { + "array": [ + { + "array": [ + { + "text": "Over the Garden Wall" + }, + { + "exact": { + "$numberDouble": "9.2" + } + } + ] + }, + { + "array": [ + { + "text": "Heart of a Dog" + }, + { + "whole": { + "$numberInt": "9" + } + } + ] + }, + { + "array": [ + { + "text": "The Chaos Class Failed the Class" + }, + { + "whole": { + "$numberInt": "9" + } + } + ] + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "NAMED_ARGUMENTS" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/group/groupByRating/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/group/groupByRating/scenario.json new file mode 100644 index 00000000000..8adfbe0e65f --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/group/groupByRating/scenario.json @@ -0,0 +1,129 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/stages/group/groupByRating", + "title": "Group by Rating", + "context": "STAGE", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/group.txt", + "blob": "8a18fc90e2df0775fccd5531514e665a1a131341" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$group": { + "_id": "$rated", + "totalRuntime": { + "$sum": "$runtime" + } + } + }, + { + "$match": { + "totalRuntime": { + "$gte": { + "$numberInt": "100000" + } + } + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "PG-13" + } + }, + { + "name": "totalRuntime", + "value": { + "whole": { + "$numberInt": "250843" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "R" + } + }, + { + "name": "totalRuntime", + "value": { + "whole": { + "$numberInt": "582318" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "exact": null + } + }, + { + "name": "totalRuntime", + "value": { + "whole": { + "$numberInt": "967127" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "PG" + } + }, + { + "name": "totalRuntime", + "value": { + "whole": { + "$numberInt": "191204" + } + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/project/excludeFieldsFromEmbeddedDocuments/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/project/excludeFieldsFromEmbeddedDocuments/scenario.json new file mode 100644 index 00000000000..a6b0479d107 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/project/excludeFieldsFromEmbeddedDocuments/scenario.json @@ -0,0 +1,353 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/stages/project/excludeFieldsFromEmbeddedDocuments", + "title": "Exclude Fields from Embedded Documents", + "context": "STAGE", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/project.txt", + "blob": "a875b2e46f16cdd3d1c06306668fecd025e754b6" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$match": { + "title": "The Great Train Robbery" + } + }, + { + "$project": { + "imdb.id": { + "$numberInt": "0" + }, + "type": { + "$numberInt": "0" + } + } + }, + { + "$limit": { + "$numberInt": "1" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "exact": { + "$oid": "573a1390f29313caabcd42e8" + } + } + }, + { + "name": "plot", + "value": { + "text": "A group of bandits stage a brazen train hold-up, only to find a determined posse hot on their heels." + } + }, + { + "name": "genres", + "value": { + "array": [ + { + "text": "Short" + }, + { + "text": "Western" + } + ] + } + }, + { + "name": "runtime", + "value": { + "whole": { + "$numberInt": "11" + } + } + }, + { + "name": "cast", + "value": { + "array": [ + { + "text": "A.C. Abadie" + }, + { + "text": "Gilbert M. 'Broncho Billy' Anderson" + }, + { + "text": "George Barnes" + }, + { + "text": "Justus D. Barnes" + } + ] + } + }, + { + "name": "poster", + "value": { + "text": "https://m.media-amazon.com/images/M/MV5BMTU3NjE5NzYtYTYyNS00MDVmLWIwYjgtMmYwYWIxZDYyNzU2XkEyXkFqcGdeQXVyNzQzNzQxNzI@._V1_SY1000_SX677_AL_.jpg" + } + }, + { + "name": "title", + "value": { + "text": "The Great Train Robbery" + } + }, + { + "name": "fullplot", + "value": { + "text": "Among the earliest existing films in American cinema - notable as the first film that presented a narrative story to tell - it depicts a group of cowboy outlaws who hold up a train and rob the passengers. They are then pursued by a Sheriff's posse. Several scenes have color included - all hand tinted." + } + }, + { + "name": "languages", + "value": { + "array": [ + { + "text": "English" + } + ] + } + }, + { + "name": "released", + "value": { + "exact": { + "$date": { + "$numberLong": "-2085523200000" + } + } + } + }, + { + "name": "directors", + "value": { + "array": [ + { + "text": "Edwin S. Porter" + } + ] + } + }, + { + "name": "rated", + "value": { + "text": "TV-G" + } + }, + { + "name": "awards", + "value": { + "document": [ + { + "name": "wins", + "value": { + "whole": { + "$numberInt": "1" + } + } + }, + { + "name": "nominations", + "value": { + "whole": { + "$numberInt": "0" + } + } + }, + { + "name": "text", + "value": { + "text": "1 win." + } + } + ] + } + }, + { + "name": "lastupdated", + "value": { + "text": "2015-08-13 00:27:59.177000000" + } + }, + { + "name": "year", + "value": { + "whole": { + "$numberInt": "1903" + } + } + }, + { + "name": "imdb", + "value": { + "document": [ + { + "name": "rating", + "value": { + "exact": { + "$numberDouble": "7.4" + } + } + }, + { + "name": "votes", + "value": { + "whole": { + "$numberInt": "9847" + } + } + } + ] + } + }, + { + "name": "countries", + "value": { + "array": [ + { + "text": "USA" + } + ] + } + }, + { + "name": "tomatoes", + "value": { + "document": [ + { + "name": "viewer", + "value": { + "document": [ + { + "name": "rating", + "value": { + "exact": { + "$numberDouble": "3.7" + } + } + }, + { + "name": "numReviews", + "value": { + "whole": { + "$numberInt": "2559" + } + } + }, + { + "name": "meter", + "value": { + "whole": { + "$numberInt": "75" + } + } + } + ] + } + }, + { + "name": "fresh", + "value": { + "whole": { + "$numberInt": "6" + } + } + }, + { + "name": "critic", + "value": { + "document": [ + { + "name": "rating", + "value": { + "exact": { + "$numberDouble": "7.6" + } + } + }, + { + "name": "numReviews", + "value": { + "whole": { + "$numberInt": "6" + } + } + }, + { + "name": "meter", + "value": { + "whole": { + "$numberInt": "100" + } + } + } + ] + } + }, + { + "name": "rotten", + "value": { + "whole": { + "$numberInt": "0" + } + } + }, + { + "name": "lastUpdated", + "value": { + "exact": { + "$date": { + "$numberLong": "1439061370000" + } + } + } + } + ] + } + }, + { + "name": "num_mflix_comments", + "value": { + "whole": { + "$numberInt": "0" + } + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "EQ_SHORTHAND" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/project/projectNewArrayFields/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/project/projectNewArrayFields/scenario.json new file mode 100644 index 00000000000..9186a53c6bb --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/project/projectNewArrayFields/scenario.json @@ -0,0 +1,89 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/stages/project/projectNewArrayFields", + "title": "Project New Array Fields", + "context": "STAGE", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/project.txt", + "blob": "a875b2e46f16cdd3d1c06306668fecd025e754b6" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$match": { + "title": "The Great Train Robbery" + } + }, + { + "$project": { + "myArray": [ + "$year", + "$runtime" + ] + } + }, + { + "$limit": { + "$numberInt": "1" + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "exact": { + "$oid": "573a1390f29313caabcd42e8" + } + } + }, + { + "name": "myArray", + "value": { + "array": [ + { + "whole": { + "$numberInt": "1903" + } + }, + { + "whole": { + "$numberInt": "11" + } + } + ] + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [ + "EQ_SHORTHAND" + ], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/sort/ascendingAndDescendingSort/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/sort/ascendingAndDescendingSort/scenario.json new file mode 100644 index 00000000000..6bf8040b105 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/sort/ascendingAndDescendingSort/scenario.json @@ -0,0 +1,54 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/stages/sort/ascendingAndDescendingSort", + "title": "Ascending and Descending Sort", + "context": "STAGE", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/sort.txt", + "blob": "3448e7f1b4905e1d63ec48a6b455f288dab9ab2c" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$sort": { + "year": { + "$numberInt": "-1" + }, + "title": { + "$numberInt": "1" + } + } + }, + { + "$limit": { + "$numberInt": "5" + } + } + ] + }, + "expected": { + "none": "the page publishes no result" + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/unwind/unwindMultipleArrayFields/scenario.json b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/unwind/unwindMultipleArrayFields/scenario.json new file mode 100644 index 00000000000..9adaa47a880 --- /dev/null +++ b/core/src/test/resources/dev/morphia/test/generated/fixtures/stages/unwind/unwindMultipleArrayFields/scenario.json @@ -0,0 +1,191 @@ +{ + "schemaVersion": { + "$numberInt": "1" + }, + "name": "aggregation/stages/unwind/unwindMultipleArrayFields", + "title": "Unwind Multiple Array Fields", + "context": "STAGE", + "source": { + "repository": "mongodb/docs", + "commit": "e4b0c153a0f39829bb1c2e5195beee1e92a8eff7", + "path": "content/manual/manual/source/reference/operator/aggregation/unwind.txt", + "blob": "195393b7aefd488cbd70cbdab4478fde747707f1" + }, + "dataset": "sample_mflix", + "collections": {}, + "indexes": [], + "action": { + "kind": "aggregate", + "collection": "movies", + "pipeline": [ + { + "$match": { + "title": { + "$in": [ + "Inception", + "The Dark Knight", + "Interstellar" + ] + } + } + }, + { + "$project": { + "_id": { + "$numberInt": "0" + }, + "title": { + "$numberInt": "1" + }, + "genres": { + "$numberInt": "1" + }, + "cast": { + "$numberInt": "1" + } + } + }, + { + "$unwind": "$genres" + }, + { + "$unwind": "$cast" + }, + { + "$group": { + "_id": "$genres", + "castAppearances": { + "$sum": { + "$numberInt": "1" + } + } + } + } + ] + }, + "expected": { + "printed": [ + { + "document": [ + { + "name": "_id", + "value": { + "text": "Adventure" + } + }, + { + "name": "castAppearances", + "value": { + "whole": { + "$numberInt": "4" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Crime" + } + }, + { + "name": "castAppearances", + "value": { + "whole": { + "$numberInt": "4" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Action" + } + }, + { + "name": "castAppearances", + "value": { + "whole": { + "$numberInt": "8" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Drama" + } + }, + { + "name": "castAppearances", + "value": { + "whole": { + "$numberInt": "8" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Mystery" + } + }, + { + "name": "castAppearances", + "value": { + "whole": { + "$numberInt": "4" + } + } + } + ] + }, + { + "document": [ + { + "name": "_id", + "value": { + "text": "Sci-Fi" + } + }, + { + "name": "castAppearances", + "value": { + "whole": { + "$numberInt": "8" + } + } + } + ] + } + ] + }, + "comparison": { + "order": "ORDERED", + "rules": [], + "ignore": [], + "tolerance": null + }, + "requirements": { + "minimumServer": null, + "topology": "STANDALONE" + }, + "skipped": { + "results": "the example queries the sample_mflix sample dataset, which the tests do not load" + } +} diff --git a/core/src/test/resources/dev/morphia/test/generated/manifest.json b/core/src/test/resources/dev/morphia/test/generated/manifest.json index 4928f1815fd..ff90e490024 100644 --- a/core/src/test/resources/dev/morphia/test/generated/manifest.json +++ b/core/src/test/resources/dev/morphia/test/generated/manifest.json @@ -34,6 +34,11 @@ "name" : "aggregation/expressions/add/addNumbers", "scenario" : "/dev/morphia/test/aggregation/expressions/add/addNumbers/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestAdd#testAddNumbers" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/addToSet/collectTheGenresOfEachDirector", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/addToSet/collectTheGenresOfEachDirector/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestAddToSet#collectTheGenresOfEachDirector" }, { "kind" : "CONVERTED", "name" : "aggregation/expressions/and/andExpressionOperator", @@ -154,6 +159,11 @@ "name" : "aggregation/expressions/bottomN/computingNBasedOnTheGroupKeyForGroup", "scenario" : "/dev/morphia/test/aggregation/expressions/bottomN/computingNBasedOnTheGroupKeyForGroup/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestBottomN#testComputingNBasedOnTheGroupKeyForGroup" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/bottomN/findTheLowestRatedMoviesForEachGenre", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheLowestRatedMoviesForEachGenre/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestBottomN#findTheLowestRatedMoviesForEachGenre" }, { "kind" : "GENERATED", "name" : "aggregation/expressions/bottomN/findTheThreeLowestRatedMoviesInASingleGenre", @@ -354,6 +364,11 @@ "name" : "aggregation/expressions/filter/useTheLimitField", "scenario" : "/dev/morphia/test/aggregation/expressions/filter/useTheLimitField/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestFilter#testUseTheLimitField" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/first/findTheFirstMovieInEachGenre", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/first/findTheFirstMovieInEachGenre/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestFirst#findTheFirstMovieInEachGenre" }, { "kind" : "CONVERTED", "name" : "aggregation/expressions/first/missingData", @@ -369,6 +384,11 @@ "name" : "aggregation/expressions/firstN/computingNBasedOnTheGroupKeyForGroup", "scenario" : "/dev/morphia/test/aggregation/expressions/firstN/computingNBasedOnTheGroupKeyForGroup/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestFirstN#testComputingNBasedOnTheGroupKeyForGroup" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestFirstN#findTheFirstThreeMoviesAcrossMultipleGenres" }, { "kind" : "GENERATED", "name" : "aggregation/expressions/firstN/findTheFirstThreeMoviesForASingleGenre", @@ -639,6 +659,11 @@ "name" : "aggregation/expressions/minN/computingNBasedOnTheGroupKeyForGroup", "scenario" : "/dev/morphia/test/aggregation/expressions/minN/computingNBasedOnTheGroupKeyForGroup/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestMinN#testComputingNBasedOnTheGroupKeyForGroup" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestMinN#findTheMinimumThreeRatingsAcrossMultipleGenres" }, { "kind" : "GENERATED", "name" : "aggregation/expressions/minN/findTheMinimumThreeRatingsForASingleGenre", @@ -729,6 +754,11 @@ "name" : "aggregation/expressions/pow/powExpressionOperator", "scenario" : "/dev/morphia/test/aggregation/expressions/pow/powExpressionOperator/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestPow#testPowExpressionOperator" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/push/collectTheFirstGenreOfEachDirectorSMovies", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/push/collectTheFirstGenreOfEachDirectorSMovies/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestPush#collectTheFirstGenreOfEachDirectorSMovies" }, { "kind" : "CONVERTED", "name" : "aggregation/expressions/push/useInGroupStage", @@ -1099,6 +1129,11 @@ "name" : "aggregation/expressions/topN/computingNBasedOnTheGroupKeyForGroup", "scenario" : "/dev/morphia/test/aggregation/expressions/topN/computingNBasedOnTheGroupKeyForGroup/scenario.json", "test" : "dev.morphia.test.aggregation.expressions.TestTopN#testComputingNBasedOnTheGroupKeyForGroup" + }, { + "kind" : "GENERATED", + "name" : "aggregation/expressions/topN/findTheHighestRatedMoviesForEachGenre", + "scenario" : "/dev/morphia/test/generated/fixtures/expressions/topN/findTheHighestRatedMoviesForEachGenre/scenario.json", + "test" : "dev.morphia.test.generated.expressions.TestTopN#findTheHighestRatedMoviesForEachGenre" }, { "kind" : "GENERATED", "name" : "aggregation/expressions/topN/findTheThreeHighestRatedMoviesInASingleGenre", @@ -1234,6 +1269,11 @@ "name" : "aggregation/stages/graphLookup/withinASingleCollection", "scenario" : "/dev/morphia/test/aggregation/stages/graphLookup/withinASingleCollection/scenario.json", "test" : "dev.morphia.test.aggregation.stages.TestGraphLookup#testWithinASingleCollection" + }, { + "kind" : "GENERATED", + "name" : "aggregation/stages/group/groupByRating", + "scenario" : "/dev/morphia/test/generated/fixtures/stages/group/groupByRating/scenario.json", + "test" : "dev.morphia.test.generated.stages.TestGroup#groupByRating" }, { "kind" : "CONVERTED", "name" : "aggregation/stages/group/pivotData", @@ -1284,6 +1324,11 @@ "name" : "aggregation/stages/project/conditionallyExcludeFields", "scenario" : "/dev/morphia/test/aggregation/stages/project/conditionallyExcludeFields/scenario.json", "test" : "dev.morphia.test.aggregation.stages.TestProject#testConditionallyExcludeFields" + }, { + "kind" : "GENERATED", + "name" : "aggregation/stages/project/excludeFieldsFromEmbeddedDocuments", + "scenario" : "/dev/morphia/test/generated/fixtures/stages/project/excludeFieldsFromEmbeddedDocuments/scenario.json", + "test" : "dev.morphia.test.generated.stages.TestProject#excludeFieldsFromEmbeddedDocuments" }, { "kind" : "CONVERTED", "name" : "aggregation/stages/project/includeSpecificFieldsFromEmbeddedDocuments", @@ -1299,6 +1344,11 @@ "name" : "aggregation/stages/project/includeSpecificFieldsInOutputDocuments", "scenario" : "/dev/morphia/test/aggregation/stages/project/includeSpecificFieldsInOutputDocuments/scenario.json", "test" : "dev.morphia.test.aggregation.stages.TestProject#testIncludeSpecificFieldsInOutputDocuments" + }, { + "kind" : "GENERATED", + "name" : "aggregation/stages/project/projectNewArrayFields", + "scenario" : "/dev/morphia/test/generated/fixtures/stages/project/projectNewArrayFields/scenario.json", + "test" : "dev.morphia.test.generated.stages.TestProject#projectNewArrayFields" }, { "kind" : "CONVERTED", "name" : "aggregation/stages/project/suppressIdFieldInTheOutputDocuments", @@ -1404,6 +1454,11 @@ "name" : "aggregation/stages/skip/skipAggregationStage", "scenario" : "/dev/morphia/test/aggregation/stages/skip/skipAggregationStage/scenario.json", "test" : "dev.morphia.test.aggregation.stages.TestSkip#testSkipAggregationStage" + }, { + "kind" : "GENERATED", + "name" : "aggregation/stages/sort/ascendingAndDescendingSort", + "scenario" : "/dev/morphia/test/generated/fixtures/stages/sort/ascendingAndDescendingSort/scenario.json", + "test" : "dev.morphia.test.generated.stages.TestSort#ascendingAndDescendingSort" }, { "kind" : "CONVERTED", "name" : "aggregation/stages/sort/ascendingDescendingSort", @@ -1464,6 +1519,11 @@ "name" : "aggregation/stages/unwind/unwindArray", "scenario" : "/dev/morphia/test/aggregation/stages/unwind/unwindArray/scenario.json", "test" : "dev.morphia.test.aggregation.stages.TestUnwind#testUnwindArray" + }, { + "kind" : "GENERATED", + "name" : "aggregation/stages/unwind/unwindMultipleArrayFields", + "scenario" : "/dev/morphia/test/generated/fixtures/stages/unwind/unwindMultipleArrayFields/scenario.json", + "test" : "dev.morphia.test.generated.stages.TestUnwind#unwindMultipleArrayFields" }, { "kind" : "CONVERTED", "name" : "query/filters/all/useAllToMatchValues", @@ -1939,6 +1999,10 @@ "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestAdd.java", "sha256" : "0a3bed7e8749f53389cb2e7934de336864e4e47766d612e4b2cddf5738aa91af" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/expressions/TestAddToSet.java", + "sha256" : "566c3a99aa364e60aec4f855b7873733cece3f2fc01550f2f63c314803232725" }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestBottom.java", @@ -1946,11 +2010,15 @@ }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestBottomN.java", - "sha256" : "4a2bd26d75fedd9d2362420193fcf77745c91e6c62c05aed370052dd099ee641" + "sha256" : "eb63e7850be0e2e00661b41b08557f6a59ab2c79aa064bff47315b0f8020c099" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/expressions/TestFirst.java", + "sha256" : "5e65af5f87ce49298ad8ef419fd051cb4972f0ac6a00f1e39f950e5de9c20c8b" }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestFirstN.java", - "sha256" : "c95471f1b217c4881fbf8018009f52f4f50d63d21a241c99a6f42a8bebacb3f5" + "sha256" : "dfc14f4184302b0208f18340f3a5816419a7fa1b875daf61bdd4d371578c7bcc" }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestMaxN.java", @@ -1962,7 +2030,11 @@ }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestMinN.java", - "sha256" : "bc0d5fc21f1a298c678e407a4aafaf07c778dd0259ca7e8ec150e7c004d8111d" + "sha256" : "db07d7a27d6ecd12693fa1f8e79160c4c81c7f805e7dc973e276db6cd8f7223d" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/expressions/TestPush.java", + "sha256" : "c09e85a82bb775350b20264110090286a1bce763d5e958f972b80cec7d235dd8" }, { "owner" : "PROTECTED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestRound.java", @@ -1974,11 +2046,27 @@ }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/expressions/TestTopN.java", - "sha256" : "60d9727f2c4e2891bfed4f4689c7853e9248d56ab24b06ad3ab982ac17d92e9c" + "sha256" : "64924cad5268b18d9c45fe2f2a44dd823c3a9f271a7bbf1a7f2a32da119cf354" }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/filters/TestIn.java", "sha256" : "4488d2132039c96a001b74dbcd0239737633aa411d805159fbbf5c0f7d5bbaea" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/stages/TestGroup.java", + "sha256" : "bdebceeff36dbf5856d9572ec6bf77c35484159b1eab3cc9a42f01833786b4bf" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/stages/TestProject.java", + "sha256" : "25d5313092b2277d5c5d1a1128e9106d2dc61df24691352edd144c5210a86b2e" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/stages/TestSort.java", + "sha256" : "f4d64dda971de444c1656f3d721977ff3d2d2daf416c2bc0b9d4f00aa25e8c31" + }, { + "owner" : "GENERATED", + "path" : "src/test/java/dev/morphia/test/generated/stages/TestUnwind.java", + "sha256" : "76b5e9ec5285cc57c50c4974fa8ce9582588d5ad8e0363db637509a61d855c33" }, { "owner" : "GENERATED", "path" : "src/test/java/dev/morphia/test/generated/updates/TestPositionalAll.java", @@ -3107,6 +3195,10 @@ "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/add/addNonIntegerValuesToADate/scenario.json", "sha256" : "a8a5d9b730661bb7a2b4e5f9b8be75a967708b4d55c62737784210fbfe16ec2a" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/addToSet/collectTheGenresOfEachDirector/scenario.json", + "sha256" : "dc936d1af892081640343bacd13346c9246e4c8ad71619587d80567baf9cd89a" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingAcrossMultipleYears/scenario.json", @@ -3115,10 +3207,22 @@ "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottom/findTheBottomRatingInAGenre/scenario.json", "sha256" : "4128485c63db3adfac11548496f0eb6fa296f1392f2054644be532dc740cd246" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheLowestRatedMoviesForEachGenre/scenario.json", + "sha256" : "58d0354e0bd56a8abadc0292c4eb4905e35b0a3a1b07c5725f3370febf4927af" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/bottomN/findTheThreeLowestRatedMoviesInASingleGenre/scenario.json", "sha256" : "c39d5e9bf578743e5c62e1860855de6de0b16c4f97e4b7e7eb1a36d4aec8e0d0" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/first/findTheFirstMovieInEachGenre/scenario.json", + "sha256" : "8284d3ddafaced7bca0aca345578a83c36795e180b563a58ca3af712b9d2729f" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesAcrossMultipleGenres/scenario.json", + "sha256" : "682fd4c173aa52cc66d01174a247e4ba8ee49ef07ae604728dcf675f9f022363" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/firstN/findTheFirstThreeMoviesForASingleGenre/scenario.json", @@ -3135,10 +3239,18 @@ "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/maxN/findTheThreeHighestRatedMoviesForASingleYear/scenario.json", "sha256" : "d64d3877583249c2452d3065799e494cc0e990f39f24201bd2e4f3d70b2582f5" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsAcrossMultipleGenres/scenario.json", + "sha256" : "9c7aff9c83010b4df22b58be562cd0892eaa74f2fa74b3573d6aeb1f7e2efc82" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/minN/findTheMinimumThreeRatingsForASingleGenre/scenario.json", "sha256" : "a256b42390db32b61d78f9017f2d1d62871ae0d1fc83547723ea437e112d2626" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/push/collectTheFirstGenreOfEachDirectorSMovies/scenario.json", + "sha256" : "764fb7a4b75e1bb32ef789b102389d28232dddca2ded7fe9900bb42543670477" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/round/roundExpressionOperator/scenario.json", @@ -3151,6 +3263,10 @@ "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/top/findTheTopRatingInAGenre/scenario.json", "sha256" : "49525d957d45ca1c4eda22c8c8829da59f9b983aff38b251fc1d34cb208f4bc1" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheHighestRatedMoviesForEachGenre/scenario.json", + "sha256" : "9b2450f80283414298a75e4f59bd5e055a4a56b961fe2f9325a9a8666387abfc" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/expressions/topN/findTheThreeHighestRatedMoviesInASingleGenre/scenario.json", @@ -3167,6 +3283,26 @@ "owner" : "PROTECTED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/runner/printedMismatch/scenario.json", "sha256" : "ccdec466a95e3325eecd8997cb852a14de71a815c6f6c5e4cd5b77332aab5296" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/stages/group/groupByRating/scenario.json", + "sha256" : "d8015deb73c4cd96f6177904c6563bac1cf4fdceb6d87a54f2afee6f1cac5aaf" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/stages/project/excludeFieldsFromEmbeddedDocuments/scenario.json", + "sha256" : "b715944efa7e34f803f112356ae1a1e5a639a016e92f4e09dc5172c3faca5d7b" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/stages/project/projectNewArrayFields/scenario.json", + "sha256" : "8c6a8c128da3126c74e784acfc793b228658a4d7ac5d1264b566c553a259ca27" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/stages/sort/ascendingAndDescendingSort/scenario.json", + "sha256" : "a78b3f0b9dc7e5ea0ea692ddef7f34526ebdffed2304dd27104c8c8bd7840959" + }, { + "owner" : "GENERATED", + "path" : "src/test/resources/dev/morphia/test/generated/fixtures/stages/unwind/unwindMultipleArrayFields/scenario.json", + "sha256" : "33a256dc159bf043edcbff22eb78169eab7564491e1d9c60fae6f5f4de5e5804" }, { "owner" : "GENERATED", "path" : "src/test/resources/dev/morphia/test/generated/fixtures/updates/positional-all/updateAllElementsInAnArray/scenario.json", diff --git a/design/operator-audits-design.md b/design/operator-audits-design.md index e46e03423f2..0ff64c28753 100644 --- a/design/operator-audits-design.md +++ b/design/operator-audits-design.md @@ -210,7 +210,8 @@ Every example on the current operator pages, with its owner, lives in `documente from a sparse Git clone. `fetch.py current` followed by `fetch.py pages` does the same through the GitHub API, which rate-limits. 2. `GenerateMainKt inventory` extracts each page's examples and matches each one to an existing - fixture, by title or, if the title changed, by its action text. The matching uses the legacy RST + fixture: by title, or, if the title changed, by its action text, or else by its descriptive name + (the backport named every fixture for its example). The matching uses the legacy RST extractor, which is also how the fixtures were made. Each example gets one status: @@ -283,9 +284,9 @@ Examples that are not generated are listed in `gaps.json`, each with its reason: | `EXCLUDED` | A reviewed exclusion. | Its reason says what would lift it. | | `PROTECTED_CLASS` | The operator's class holds a moved handwritten body. | Move the body or the case. | -The aggregation expressions, query filters and query updates families are generated today. Stage -pages need their family enabled and more bindings; documented projections and update options -(`arrayFilters`) need generator and runner support. +All four families are generated today: aggregation expressions and stages, query filters and +updates. Most remaining gaps are bindings, database-level commands (`db.aggregate(...)`), +documented projections and update options (`arrayFilters`). ### Candidates, integration and promotion diff --git a/design/operator-audits-progress.md b/design/operator-audits-progress.md index eea615501fb..c28fdfa2531 100644 --- a/design/operator-audits-progress.md +++ b/design/operator-audits-progress.md @@ -18,7 +18,7 @@ how the audits work updates it too; this file records what each PR delivered. Every step of the plan (0–7) has been started. What stands: -- **On the runner:** 373 legacy cases (372 converted, 1 migrated), plus 14 generated cases. +- **On the runner:** 373 legacy cases (372 converted, 1 migrated), plus 26 generated cases. Core gate: 662 tests under each mapper; audits: 452. - **Generation:** inventory of mongodb/docs `e4b0c153` (297 pages read, tested snippets included; 437 examples owned, 145 unowned, none unnamed or ambiguous after review), reviewed DSL bindings checked against core's API, and the @@ -51,7 +51,6 @@ Step 5, generation and cutover: - **Deferred cutover features:** generated projections (converted cases carry theirs), update options (`arrayFilters`, `upsert`), update results as the page reads them (the whole collection, not the filter's matches), alternative commands. -- **The stage pages' family** (41 unowned examples, most on sample datasets). Step 6, monitoring: - **An accepted production baseline for capability discovery.** It is needed before @@ -2681,3 +2680,16 @@ no product-documentation changes. Legacy operator AsciiDoc tables are intentiona `selectRandomItemsFromACollection` is legacy-only: the page projects `{_id: 0, name: 1, registered: 1}`, and the test's projection omits the `_id` exclusion. - Totals: ledger 373 cases; 15 legacy-only; 183 legacy directories. Core: 692 under each mapper. + +## Stage family and common bindings (2026-11-23) + +- Branch audits-stage-family. `aggregation/stages` joins the generated families. New bindings: + `$limit`, `$skip`, `$count`, `$sortByCount`; `$sum`, `$avg`, `$first`, `$last`, `$push`, + `$addToSet`, `$max`, `$min`, `$multiply`. A `long` parameter takes integer literals. +- The inventory now also matches an example to the fixture named for it (the backport named every + fixture for its example), when its title and action text have both changed: 7 examples, among + them `$project`'s "Suppress _id Field in the Output Documents", which generation would otherwise + have duplicated. `$bitOr`'s "Bitwise OR with a Long and Integer" is owned this way, so its + generator exclusion went away (the page error stays in #4563). +- 12 more generated cases (26 in all), integrated under both mappers and promoted. Inventory: 444 + owned, 138 unowned. Core: 704 tests under each mapper; audits: 459.