Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5629

ValueMatcher should not treat all documents as root-level ones

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Unified Test Runner
    • None
    • Java Drivers

      The specification https://github.com/mongodb/specifications/blob/master/source/unified-test-format/unified-test-format.md#allowing-extra-fields-in-root-level-documents requires us to permit extra fields in root-level documents (though, it does not specify what those documents are). Our com.mongodb.client.unified.ValueMatcher.assertValuesMatch ignores extra fields in all documents regardless of the nesting level. As a result, the following expectation matches always

      "expectError": {
        "expectResult": {
          "$$unsetOrMatches": {}
        }
      }
      

      and the next one matches any insertResults, updateResults, deleteResults

      "expectError": {
        "expectResult": {
          "insertedCount": 1,
          "upsertedCount": 0,
          "matchedCount": 0,
          "modifiedCount": 0,
          "deletedCount": 0,
          "insertResults": {
            "$$unsetOrMatches": {}
          },
          "updateResults": {
            "$$unsetOrMatches": {}
          },
          "deleteResults": {
            "$$unsetOrMatches": {}
          }
        }
      }
      

      This issue was discovered when reviewing https://github.com/mongodb/specifications/pull/1665.

      Note that if we start checking that the actual document does not have any extra fields compared to the expected documents, we can't do that by simply comparing the number of fields. For example, the following field in the expected document requires its key to not be present in the actual document:

      "thisKeyMustNotBePresentInTheActualDocument": {
        "$$exists": false
      }
      

            Assignee:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Reporter:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: