<commit_before>xquery version "1.0-ml";

import module namespace match-impl = "http://marklogic.com/smart-mastering/matcher-impl"
  at "/com.marklogic.smart-mastering/matcher-impl/matcher-impl.xqy";

import module namespace test = "http://marklogic.com/test" at "/test/test-helper.xqy";

declare variable $DOCUMENT := document{
  xdmp:unquote(
    '{
      "Object": {
        "intProperty": 12,
        "strProperty": "Hello",
        "boolProperty": true,
        "dateProperty": "1987-03-17",
        "dateTimeProperty": "1956-12-09T03:55:14",
        "decimalProperty": 123.456
      }
    }'
  )
};

declare variable $COMPILED-OPTIONS := map:new((
  map:entry(
    "queries",
    (
      map:new((
        map:entry(
          "qname",
          xs:QName("intProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("strProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("boolProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("dateProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("dateTimeProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("decimalProperty")
        )
      ))
    )
  )
));

declare variable $EXPECTED-VALUES := map:new((
  map:entry(
    "boolProperty",
    fn:true()
  ),
  map:entry(
    "decimalProperty",
    xs:decimal(123.456)
  ),
  map:entry(
    "dateProperty",
    "1987-03-17"
  ),
  map:entry(
    "dateTimeProperty",
    "1956-12-09T03:55:14"
  ),
  map:entry(
    "intProperty",
    xs:integer(12)
  ),
  map:entry(
    "strProperty",
    "Hello"
  )
));

test:assert-true(
  fn:deep-equal(
    <x>{match-impl:values-by-qname(
      $DOCUMENT,
      $COMPILED-OPTIONS
    )}</x>,
    <x>{$EXPECTED-VALUES}</x>
  )
)<commit_msg>DHFPROD-3440: Update test to work with different data types<commit_after>xquery version "1.0-ml";

import module namespace match-impl = "http://marklogic.com/smart-mastering/matcher-impl"
  at "/com.marklogic.smart-mastering/matcher-impl/matcher-impl.xqy";

import module namespace test = "http://marklogic.com/test" at "/test/test-helper.xqy";

declare variable $DOCUMENT := document{
  xdmp:unquote(
    '{
    "envelope": {
      "instance":{
          "Object": {
            "intProperty": 12,
            "strProperty": "Hello",
            "boolProperty": true,
            "dateProperty": "1987-03-17",
            "dateTimeProperty": "1956-12-09T03:55:14",
            "decimalProperty": 123.456
          }
        }
      }
    }'
  )
};

declare variable $COMPILED-OPTIONS := map:new((
  map:entry(
    "queries",
    (
      map:new((
        map:entry(
          "qname",
          xs:QName("intProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("strProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("boolProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("dateProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("dateTimeProperty")
        )
      )),
      map:new((
        map:entry(
          "qname",
          xs:QName("decimalProperty")
        )
      ))
    )
  )
));

declare variable $EXPECTED-VALUES := map:new((
  map:entry(
    "boolProperty",
    fn:true()
  ),
  map:entry(
    "decimalProperty",
    xs:decimal(123.456)
  ),
  map:entry(
    "dateProperty",
    "1987-03-17"
  ),
  map:entry(
    "dateTimeProperty",
    "1956-12-09T03:55:14"
  ),
  map:entry(
    "intProperty",
    xs:integer(12)
  ),
  map:entry(
    "strProperty",
    "Hello"
  )
));

test:assert-true(
  fn:deep-equal(
    xdmp:to-json(match-impl:values-by-qname(
      $DOCUMENT,
      $COMPILED-OPTIONS
    )),
    xdmp:to-json($EXPECTED-VALUES)
  )
)
{'fraction_non_alphanumeric': 0.16562421816362272, 'fraction_numerical': 0.03202401801351013, 'mean_word_length': 1.8700646087580761, 'pattern_counts': {'":': 16, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3639630', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1416, 'n_words': 197}