---
policy: /ce/unit-test/collection-from/text-items
logic: /ce/unit-test/collection-from/text-items/unit-test.logic.yaml
executionTime: 2025-06-28T12:07:55.324541809Z
rows:
  - id: Test-1
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: "unitTest(Test-1): ''.asCollection(',').skipEmpty().skipDuplicates().sort().isEmpty()"
      actual: "unitTest(Test-1): ''.asCollection(',').skipEmpty().skipDuplicates().sort().isEmpty()"
    runtimeError: {}
  - id: Test-1-Keep-Empty
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "unitTest(Test-1-Keep-Empty): ''.asCollection(',').keepEmpty().skipDuplicates().sort().isNotEmpty()"
      actual: "unitTest(Test-1-Keep-Empty): ''.asCollection(',').keepEmpty().skipDuplicates().sort().isNotEmpty()"
    runtimeError: {}
  - id: Test-2
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: "unitTest(Test-2): 'a,a'.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a'].skipEmpty().skipDuplicates().sort()"
      actual: "unitTest(Test-2): 'a,a'.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a'].skipEmpty().skipDuplicates().sort()"
    runtimeError: {}
  - id: Test-2-Keep-Duplicates
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: "unitTest(Test-2-Keep-Duplicates): 'a,a'.asCollection(',').skipEmpty().keepDuplicates().sort()\
        \ != ['a'].skipEmpty().skipDuplicates().sort()"
      actual: "unitTest(Test-2-Keep-Duplicates): 'a,a'.asCollection(',').skipEmpty().keepDuplicates().sort()\
        \ != ['a'].skipEmpty().skipDuplicates().sort()"
    runtimeError: {}
  - id: Test-3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: "unitTest(Test-3): 'a,b'.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a', 'b'].skipEmpty().skipDuplicates().sort()"
      actual: "unitTest(Test-3): 'a,b'.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a', 'b'].skipEmpty().skipDuplicates().sort()"
    runtimeError: {}
  - id: Test-4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 699
      actual: 699
    conditionText:
      expected: "unitTest(Test-4): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a'].skipEmpty().skipDuplicates().sort()"
      actual: "unitTest(Test-4): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a'].skipEmpty().skipDuplicates().sort()"
    runtimeError: {}
  - id: Test-4-Keep-Duplicates
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 799
      actual: 799
    conditionText:
      expected: "unitTest(Test-4-Keep-Duplicates): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a', 'a'].skipEmpty().skipDuplicates().sort()"
      actual: "unitTest(Test-4-Keep-Duplicates): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort()\
        \ == ['a', 'a'].skipEmpty().skipDuplicates().sort()"
    runtimeError: {}
  - id: Test-5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 899
      actual: 899
    conditionText:
      expected: "unitTest(Test-5): '\\nline1\\nline2\\nline3\\n'.asCollection('\\\
        n').skipEmpty().skipDuplicates().sort() == ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().sort()"
      actual: "unitTest(Test-5): '\\nline1\\nline2\\nline3\\n'.asCollection('\\n').skipEmpty().skipDuplicates().sort()\
        \ == ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().sort()"
    runtimeError: {}
  - id: Test-5-Original-Order
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 999
      actual: 999
    conditionText:
      expected: "unitTest(Test-5-Original-Order): '\\nline1\\nline2\\nline3\\n'.asCollection('\\\
        n').skipEmpty().skipDuplicates().sort() != ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().originalOrder()"
      actual: "unitTest(Test-5-Original-Order): '\\nline1\\nline2\\nline3\\n'.asCollection('\\\
        n').skipEmpty().skipDuplicates().sort() != ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().originalOrder()"
    runtimeError: {}
  - id: Test-6
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 1099
      actual: 1099
    conditionText:
      expected: "unitTest(Test-6): [' ABC '].skipEmpty().skipDuplicates().sort().contains('\
        \   abc\\n\\t')"
      actual: "unitTest(Test-6): [' ABC '].skipEmpty().skipDuplicates().sort().contains('\
        \   abc\\n\\t')"
    runtimeError: {}
usedFiles:
  - path: /ce/unit-test/collection-from/text-items/policy.yaml
    md5Hash: 016FB660B1DC9A019F4D3227B673CCE8
    content: |
      ---
      names:
        full: COLLECTION_FROM Unit Tests for Text Items
        contextual: Text Items
      description: ""
  - path: /ce/unit-test/collection-from/text-items/unit-test.logic.yaml
    md5Hash: 6841A542A4B49F4134F33C11BB3068B5
    content: |-
      ---
      inputType: CA10__CaAwsInstance__c
      testData:
        - file: test-data.json
      conditions:
        - status: COMPLIANT
          currentStateMessage: Test-1
          check:
            UNIT_TEST:
              id: Test-1
              arg:
                IS_EMPTY:
                  arg:
                    COLLECTION_FROM:
                      separator: ","
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: ""
        - status: COMPLIANT
          currentStateMessage: Test-1-Keep-Empty
          check:
            UNIT_TEST:
              id: Test-1-Keep-Empty
              arg:
                NOT_EMPTY:
                  arg:
                    COLLECTION_FROM:
                      separator: ","
                      emptyValues: KEEP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: ""
        - status: COMPLIANT
          currentStateMessage: Test-2
          check:
            UNIT_TEST:
              id: Test-2
              arg:
                IS_EQUAL:
                  left:
                    COLLECTION_FROM:
                      separator: ","
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: "a,a"
                  right:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      itemType: TEXT
                      items:
                        - a
        - status: COMPLIANT
          currentStateMessage: Test-2-Keep-Duplicates
          check:
            UNIT_TEST:
              id: Test-2-Keep-Duplicates
              arg:
                NOT_EQUAL:
                  left:
                    COLLECTION_FROM:
                      separator: ","
                      emptyValues: SKIP
                      duplicateValues: KEEP
                      ordering: SORTED
                      arg:
                        TEXT: "a,a"
                  right:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      itemType: TEXT
                      items:
                        - a
        - status: COMPLIANT
          currentStateMessage: Test-3
          check:
            UNIT_TEST:
              id: Test-3
              arg:
                IS_EQUAL:
                  left:
                    COLLECTION_FROM:
                      separator: ","
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: "a,b"
                  right:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      itemType: TEXT
                      items:
                        - a
                        - b
        - status: COMPLIANT
          currentStateMessage: Test-4
          check:
            UNIT_TEST:
              id: Test-4
              arg:
                IS_EQUAL:
                  left:
                    COLLECTION_FROM:
                      separator: ","
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: "A\n, a "
                  right:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      itemType: TEXT
                      items:
                        - a
        - status: COMPLIANT
          currentStateMessage: Test-4-Keep-Duplicates
          check:
            UNIT_TEST:
              id: Test-4-Keep-Duplicates
              arg:
                IS_EQUAL:
                  left:
                    COLLECTION_FROM:
                      separator: ","
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: "A\n, a "
                  right:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      itemType: TEXT
                      items:
                        - a
                        - a
        - status: COMPLIANT
          currentStateMessage: Test-5
          check:
            UNIT_TEST:
              id: Test-5
              arg:
                IS_EQUAL:
                  left:
                    COLLECTION_FROM:
                      separator: "\n"
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: "\nline1\nline2\nline3\n"
                  right:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      itemType: TEXT
                      items:
                        - line3
                        - line2
                        - line1
        - status: COMPLIANT
          currentStateMessage: Test-5-Original-Order
          check:
            UNIT_TEST:
              id: Test-5-Original-Order
              arg:
                NOT_EQUAL:
                  left:
                    COLLECTION_FROM:
                      separator: "\n"
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      arg:
                        TEXT: "\nline1\nline2\nline3\n"
                  right:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: ORIGINAL
                      itemType: TEXT
                      items:
                        - line3
                        - line2
                        - line1
        - status: COMPLIANT
          currentStateMessage: Test-6
          check:
            UNIT_TEST:
              id: Test-6
              arg:
                COLLECTION_CONTAINS:
                  arg:
                    COLLECTION:
                      emptyValues: SKIP
                      duplicateValues: SKIP
                      ordering: SORTED
                      itemType: TEXT
                      items:
                        - " ABC "
                  search:
                    TEXT: "   abc\n\t"
      otherwise:
        status: INCOMPLIANT
        currentStateMessage: Test Failed
        remediationMessage: Developer Fix Required
  - path: /ce/unit-test/collection-from/text-items/test-data.json
    md5Hash: 04A0D1E9CDB77B5FDBAF2A0D31795767
    content: |-
      [
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "unitTest(Test-1): ''.asCollection(',').skipEmpty().skipDuplicates().sort().isEmpty()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-1",
          "Name": "Test-1",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "unitTest(Test-1-Keep-Empty): ''.asCollection(',').keepEmpty().skipDuplicates().sort().isNotEmpty()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-1-Keep-Empty",
          "Name": "Test-1-Keep-Empty",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "399",
            "conditionText": "unitTest(Test-2): 'a,a'.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a'].skipEmpty().skipDuplicates().sort()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-2",
          "Name": "Test-2",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "499",
            "conditionText": "unitTest(Test-2-Keep-Duplicates): 'a,a'.asCollection(',').skipEmpty().keepDuplicates().sort() != ['a'].skipEmpty().skipDuplicates().sort()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-2-Keep-Duplicates",
          "Name": "Test-2-Keep-Duplicates",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "599",
            "conditionText": "unitTest(Test-3): 'a,b'.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a', 'b'].skipEmpty().skipDuplicates().sort()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-3",
          "Name": "Test-3",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "699",
            "conditionText": "unitTest(Test-4): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a'].skipEmpty().skipDuplicates().sort()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-4",
          "Name": "Test-4",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "799",
            "conditionText": "unitTest(Test-4-Keep-Duplicates): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a', 'a'].skipEmpty().skipDuplicates().sort()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-4-Keep-Duplicates",
          "Name": "Test-4-Keep-Duplicates",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "899",
            "conditionText": "unitTest(Test-5): '\\nline1\\nline2\\nline3\\n'.asCollection('\\n').skipEmpty().skipDuplicates().sort() == ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().sort()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-5",
          "Name": "Test-5",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "999",
            "conditionText": "unitTest(Test-5-Original-Order): '\\nline1\\nline2\\nline3\\n'.asCollection('\\n').skipEmpty().skipDuplicates().sort() != ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().originalOrder()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-5-Original-Order",
          "Name": "Test-5-Original-Order",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "1099",
            "conditionText": "unitTest(Test-6): [' ABC '].skipEmpty().skipDuplicates().sort().contains('   abc\\n\\t')",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-6",
          "Name": "Test-6",
          "CA10__disappearanceTime__c": null
        }
      ]
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "Test-1",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "unitTest(Test-1): ''.asCollection(',').skipEmpty().skipDuplicates().sort().isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-1-Keep-Empty",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "unitTest(Test-1-Keep-Empty): ''.asCollection(',').keepEmpty().skipDuplicates().sort().isNotEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-2",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "unitTest(Test-2): 'a,a'.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a'].skipEmpty().skipDuplicates().sort()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-2-Keep-Duplicates",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "unitTest(Test-2-Keep-Duplicates): 'a,a'.asCollection(',').skipEmpty().keepDuplicates().sort() != ['a'].skipEmpty().skipDuplicates().sort()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "unitTest(Test-3): 'a,b'.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a', 'b'].skipEmpty().skipDuplicates().sort()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "699",
      "conditionText" : "unitTest(Test-4): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a'].skipEmpty().skipDuplicates().sort()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-4-Keep-Duplicates",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "799",
      "conditionText" : "unitTest(Test-4-Keep-Duplicates): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a', 'a'].skipEmpty().skipDuplicates().sort()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "899",
      "conditionText" : "unitTest(Test-5): '\\nline1\\nline2\\nline3\\n'.asCollection('\\n').skipEmpty().skipDuplicates().sort() == ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().sort()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-5-Original-Order",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "999",
      "conditionText" : "unitTest(Test-5-Original-Order): '\\nline1\\nline2\\nline3\\n'.asCollection('\\n').skipEmpty().skipDuplicates().sort() != ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().originalOrder()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-6",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "1099",
      "conditionText" : "unitTest(Test-6): [' ABC '].skipEmpty().skipDuplicates().sort().contains('   abc\\n\\t')",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsInstance__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-1-Keep-Empty"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-2-Keep-Duplicates"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-4-Keep-Duplicates"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-5-Original-Order"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-6"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsInstance__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var CollectionLib = new function () {
          this.parse = function(arg, separator, skipEmpty, skipDuplicates, sort, normalize) {
              if (arg == null) return [];
              let parts = arg.split(separator);
              return this.fromArray(parts, skipEmpty, skipDuplicates, sort, normalize);
          };
          this.fromArray = function(arr, skipEmpty, skipDuplicates, sort, normalize) {
              if (arr == null) return [];
              let result = [];
              let seen = new Set();
              arr.forEach(el => {
                  if (!skipEmpty || TextLib.isNotEmpty(el)) {
                      let normalized = normalize ? TextLib.normalize(el) : el;
                      if (!skipDuplicates || !seen.has(normalized)) {
                          if (skipDuplicates) seen.add(normalized);
                          result.push(normalized);
                      }
                  }
              });
              if (sort) result.sort();
              return result;
          };
          this.equal = function(left, right) {
              left = left == null ? [] : left;
              right = right == null ? [] : right;
              if (left.length !== right.length) return false;
              for (let i = 0; i < left.length; i++) {
                  if (left[i] !== right[i]) return false;
              }
              return true;
          };
          this.notEqual = function(left, right) {
              return !this.equal(left, right);
          };
          this.contains = function(collection, search, normalize) {
              if (collection == null) return false;
              return collection.includes(normalize ? TextLib.normalize(search) : search);
          };
          this.size = function(collection) {
              return collection == null ? 0 : collection.length;
          };
      }();
      var TextLib = new function () {
          this.normalize = function(arg) {
              return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
          };
          this.isEmpty = function(arg) {
              return this.normalize(arg) == '';
          };
          this.isNotEmpty = function(arg) {
              return this.normalize(arg) != '';
          };
          this.equal = function(left, right) {
              return this.normalize(left) == this.normalize(right);
          };
          this.notEqual = function(left, right) {
              return this.normalize(left) != this.normalize(right);
          };
          this.startsWith = function(arg, substring) {
              return this.normalize(arg).startsWith(this.normalize(substring));
          };
          this.endsWith = function(arg, substring) {
              return this.normalize(arg).endsWith(this.normalize(substring));
          };
          this.contains = function(arg, substring) {
              return this.normalize(arg).includes(this.normalize(substring));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      if (obj.Id == 'Test-1' && CollectionLib.size(CollectionLib.parse('', ',', true, true, true, true)) == 0) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "unitTest(Test-1): ''.asCollection(',').skipEmpty().skipDuplicates().sort().isEmpty()", currentStateMessage: "Test-1", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      if (obj.Id == 'Test-1-Keep-Empty' && CollectionLib.size(CollectionLib.parse('', ',', false, true, true, true)) > 0) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "unitTest(Test-1-Keep-Empty): ''.asCollection(',').keepEmpty().skipDuplicates().sort().isNotEmpty()", currentStateMessage: "Test-1-Keep-Empty", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      if (obj.Id == 'Test-2' && CollectionLib.equal(CollectionLib.parse('a,a', ',', true, true, true, true), CollectionLib.fromArray(['a'], true, true, true, true))) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "unitTest(Test-2): 'a,a'.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a'].skipEmpty().skipDuplicates().sort()", currentStateMessage: "Test-2", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      if (obj.Id == 'Test-2-Keep-Duplicates' && CollectionLib.notEqual(CollectionLib.parse('a,a', ',', true, false, true, true), CollectionLib.fromArray(['a'], true, true, true, true))) {
          return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "unitTest(Test-2-Keep-Duplicates): 'a,a'.asCollection(',').skipEmpty().keepDuplicates().sort() != ['a'].skipEmpty().skipDuplicates().sort()", currentStateMessage: "Test-2-Keep-Duplicates", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      if (obj.Id == 'Test-3' && CollectionLib.equal(CollectionLib.parse('a,b', ',', true, true, true, true), CollectionLib.fromArray(['a', 'b'], true, true, true, true))) {
          return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "unitTest(Test-3): 'a,b'.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a', 'b'].skipEmpty().skipDuplicates().sort()", currentStateMessage: "Test-3", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[6], conditionIndex:[600..699]
      if (obj.Id == 'Test-4' && CollectionLib.equal(CollectionLib.parse('A\n, a ', ',', true, true, true, true), CollectionLib.fromArray(['a'], true, true, true, true))) {
          return {status: 'COMPLIANT', conditionIndex: 699, conditionText: "unitTest(Test-4): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a'].skipEmpty().skipDuplicates().sort()", currentStateMessage: "Test-4", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[7], conditionIndex:[700..799]
      if (obj.Id == 'Test-4-Keep-Duplicates' && CollectionLib.equal(CollectionLib.parse('A\n, a ', ',', true, true, true, true), CollectionLib.fromArray(['a', 'a'], true, true, true, true))) {
          return {status: 'COMPLIANT', conditionIndex: 799, conditionText: "unitTest(Test-4-Keep-Duplicates): 'A\\n, a '.asCollection(',').skipEmpty().skipDuplicates().sort() == ['a', 'a'].skipEmpty().skipDuplicates().sort()", currentStateMessage: "Test-4-Keep-Duplicates", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[8], conditionIndex:[800..899]
      if (obj.Id == 'Test-5' && CollectionLib.equal(CollectionLib.parse('\nline1\nline2\nline3\n', '\n', true, true, true, true), CollectionLib.fromArray(['line3', 'line2', 'line1'], true, true, true, true))) {
          return {status: 'COMPLIANT', conditionIndex: 899, conditionText: "unitTest(Test-5): '\\nline1\\nline2\\nline3\\n'.asCollection('\\n').skipEmpty().skipDuplicates().sort() == ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().sort()", currentStateMessage: "Test-5", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[9], conditionIndex:[900..999]
      if (obj.Id == 'Test-5-Original-Order' && CollectionLib.notEqual(CollectionLib.parse('\nline1\nline2\nline3\n', '\n', true, true, true, true), CollectionLib.fromArray(['line3', 'line2', 'line1'], true, true, false, true))) {
          return {status: 'COMPLIANT', conditionIndex: 999, conditionText: "unitTest(Test-5-Original-Order): '\\nline1\\nline2\\nline3\\n'.asCollection('\\n').skipEmpty().skipDuplicates().sort() != ['line3', 'line2', 'line1'].skipEmpty().skipDuplicates().originalOrder()", currentStateMessage: "Test-5-Original-Order", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[10], conditionIndex:[1000..1099]
      if (obj.Id == 'Test-6' && CollectionLib.contains(CollectionLib.fromArray([' ABC '], true, true, true, true), '   abc\n\t', true)) {
          return {status: 'COMPLIANT', conditionIndex: 1099, conditionText: "unitTest(Test-6): [' ABC '].skipEmpty().skipDuplicates().sort().contains('   abc\\n\\t')", currentStateMessage: "Test-6", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 1100, conditionText: "otherwise", currentStateMessage: "Test Failed", currentStateReferences: references1.join('\n'), remediation: "Developer Fix Required", runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.Id AS Id,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          process_CA10__CaAwsInstance__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsInstance__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
