---
policy: /ce/unit-test/duration-from
logic: /ce/unit-test/duration-from/unit-test.logic.yaml
executionTime: 2025-04-24T23:47:47.503476673Z
rows:
  - id: Test-1
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 101
      actual: 101
    conditionText:
      expected: '''''.isEmpty()'
      actual: '''''.isEmpty()'
    runtimeError: {}
  - id: Test-2
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 202
      actual: 202
    conditionText:
      expected: '''123''.checkFormat(''GCP'')'
      actual: '''123''.checkFormat(''GCP'')'
    runtimeError: {}
  - id: Test-3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: "unitTest(Test-3): '60s'.asDuration() == '1m'.asDuration()"
      actual: "unitTest(Test-3): '60s'.asDuration() == '1m'.asDuration()"
    runtimeError: {}
  - id: Test-4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: "unitTest(Test-4): '60m'.asDuration() == '1h'.asDuration()"
      actual: "unitTest(Test-4): '60m'.asDuration() == '1h'.asDuration()"
    runtimeError: {}
  - id: Test-5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: "unitTest(Test-5): '24h'.asDuration() == '1d'.asDuration()"
      actual: "unitTest(Test-5): '24h'.asDuration() == '1d'.asDuration()"
    runtimeError: {}
  - id: Test-6
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 699
      actual: 699
    conditionText:
      expected: "unitTest(Test-6): '1s'.asDuration() == 'PT1S'"
      actual: "unitTest(Test-6): '1s'.asDuration() == 'PT1S'"
    runtimeError: {}
  - id: Test-7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 799
      actual: 799
    conditionText:
      expected: "unitTest(Test-7): 'P1Y' != 'P365D'"
      actual: "unitTest(Test-7): 'P1Y' != 'P365D'"
    runtimeError: {}
  - id: Test-8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 899
      actual: 899
    conditionText:
      expected: "unitTest(Test-8): 'P1Y' == 'P12M'"
      actual: "unitTest(Test-8): 'P1Y' == 'P12M'"
    runtimeError: {}
  - id: Test-9
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 999
      actual: 999
    conditionText:
      expected: "unitTest(Test-9): 'P1M' == 'P30D'"
      actual: "unitTest(Test-9): 'P1M' == 'P30D'"
    runtimeError: {}
usedFiles:
  - path: /ce/unit-test/duration-from/policy.yaml
    md5Hash: BE11A177BFEC1D582F926CD8DD51831F
    content: |
      ---
      names:
        full: DURATION_FROM Unit Tests
        contextual: DURATION_FROM
      description: ""
  - path: /ce/unit-test/duration-from/unit-test.logic.yaml
    md5Hash: D9BB89FF51CB896950C9B03A5DA06C72
    content: "---\ninputType: CA10__CaGoogleCloudKmsCryptoKey__c\ntestData:\n  - file:\
      \ test-data.json\nconditions:\n  - status: COMPLIANT\n    currentStateMessage:\
      \ Test-1\n    check:\n      UNIT_TEST:\n        id: Test-1\n        arg:\n \
      \         IS_EMPTY:\n            arg:\n              DURATION_FROM:\n      \
      \          arg:\n                  TEXT: \"\"\n                format: GCP\n\
      \                undeterminedIf:\n                  isEmpty: \"Empty text received\"\
      \n                  invalidFormat: \"Should not happen\"\n  - status: COMPLIANT\n\
      \    currentStateMessage: Test-2\n    check:\n      UNIT_TEST:\n        id:\
      \ Test-2\n        arg:\n          IS_EMPTY:\n            arg:\n            \
      \  DURATION_FROM:\n                arg:\n                  TEXT: \"123\"\n \
      \               format: GCP\n                undeterminedIf:\n             \
      \     isEmpty: \"Should not happen\"\n                  invalidFormat: \"Invalid\
      \ value received\"\n  - status: COMPLIANT\n    currentStateMessage: Test-3\n\
      \    check:\n      UNIT_TEST:\n        id: Test-3\n        arg:\n          IS_EQUAL:\n\
      \            left:\n              DURATION_FROM:\n                arg:\n   \
      \               TEXT: \"60s\"\n                format: GCP\n               \
      \ undeterminedIf:\n                  isEmpty: \"Should not happen\"\n      \
      \            invalidFormat: \"Should not happen\"\n            right:\n    \
      \          DURATION_FROM:\n                arg:\n                  TEXT: \"\
      1m\"\n                format: GCP\n                undeterminedIf:\n       \
      \           isEmpty: \"Should not happen\"\n                  invalidFormat:\
      \ \"Should not happen\"\n  - status: COMPLIANT\n    currentStateMessage: Test-4\n\
      \    check:\n      UNIT_TEST:\n        id: Test-4\n        arg:\n          IS_EQUAL:\n\
      \            left:\n              DURATION_FROM:\n                arg:\n   \
      \               TEXT: \"60m\"\n                format: GCP\n               \
      \ undeterminedIf:\n                  isEmpty: \"Should not happen\"\n      \
      \            invalidFormat: \"Should not happen\"\n            right:\n    \
      \          DURATION_FROM:\n                arg:\n                  TEXT: \"\
      1h\"\n                format: GCP\n                undeterminedIf:\n       \
      \           isEmpty: \"Should not happen\"\n                  invalidFormat:\
      \ \"Should not happen\"\n  - status: COMPLIANT\n    currentStateMessage: Test-5\n\
      \    check:\n      UNIT_TEST:\n        id: Test-5\n        arg:\n          IS_EQUAL:\n\
      \            left:\n              DURATION_FROM:\n                arg:\n   \
      \               TEXT: \"24h\"\n                format: GCP\n               \
      \ undeterminedIf:\n                  isEmpty: \"Should not happen\"\n      \
      \            invalidFormat: \"Should not happen\"\n            right:\n    \
      \          DURATION_FROM:\n                arg:\n                  TEXT: \"\
      1d\"\n                format: GCP\n                undeterminedIf:\n       \
      \           isEmpty: \"Should not happen\"\n                  invalidFormat:\
      \ \"Should not happen\"  \n  - status: COMPLIANT\n    currentStateMessage: Test-6\n\
      \    check:\n      UNIT_TEST:\n        id: Test-6\n        arg:\n          IS_EQUAL:\n\
      \            left:\n              DURATION_FROM:\n                arg:\n   \
      \               TEXT: \"1s\"\n                format: GCP\n                undeterminedIf:\n\
      \                  isEmpty: \"Should not happen\"\n                  invalidFormat:\
      \ \"Should not happen\"\n            right:\n              DURATION: \"PT1S\"\
      \n  - status: COMPLIANT\n    currentStateMessage: Test-7\n    check:\n     \
      \ UNIT_TEST:\n        id: Test-7\n        arg:\n          NOT_EQUAL:\n     \
      \       left:\n              DURATION: \"P1Y\"\n            right:\n       \
      \       DURATION: \"P365D\"\n  - status: COMPLIANT\n    currentStateMessage:\
      \ Test-8\n    check:\n      UNIT_TEST:\n        id: Test-8\n        arg:\n \
      \         IS_EQUAL:\n            left:\n              DURATION: \"P1Y\"\n  \
      \          right:\n              DURATION: \"P12M\"\n  - status: COMPLIANT\n\
      \    currentStateMessage: Test-9\n    check:\n      UNIT_TEST:\n        id:\
      \ Test-9\n        arg:\n          IS_EQUAL:\n            left:\n           \
      \   DURATION: \"P1M\"\n            right:\n              DURATION: \"P30D\"\n\
      otherwise:\n  status: INCOMPLIANT\n  currentStateMessage: Test Failed\n  remediationMessage:\
      \ Developer Fix Required"
  - path: /ce/unit-test/duration-from/test-data.json
    md5Hash: 2974FDE76272AC4081300BC7B4DE58FE
    content: |-
      [
        {
          "expectedResult": {
            "status": "UNDETERMINED",
            "conditionIndex": "101",
            "conditionText": "''.isEmpty()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-1",
          "Name": "Test-1",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "UNDETERMINED",
            "conditionIndex": "202",
            "conditionText": "'123'.checkFormat('GCP')",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-2",
          "Name": "Test-2",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "399",
            "conditionText": "unitTest(Test-3): '60s'.asDuration() == '1m'.asDuration()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-3",
          "Name": "Test-3",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "499",
            "conditionText": "unitTest(Test-4): '60m'.asDuration() == '1h'.asDuration()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-4",
          "Name": "Test-4",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "599",
            "conditionText": "unitTest(Test-5): '24h'.asDuration() == '1d'.asDuration()",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-5",
          "Name": "Test-5",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "699",
            "conditionText": "unitTest(Test-6): '1s'.asDuration() == 'PT1S'",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-6",
          "Name": "Test-6",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "799",
            "conditionText": "unitTest(Test-7): 'P1Y' != 'P365D'",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-7",
          "Name": "Test-7",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "899",
            "conditionText": "unitTest(Test-8): 'P1Y' == 'P12M'",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-8",
          "Name": "Test-8",
          "CA10__disappearanceTime__c": null
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "999",
            "conditionText": "unitTest(Test-9): 'P1M' == 'P30D'",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2024-01-01T00:00:00Z"
          },
          "Id": "Test-9",
          "Name": "Test-9",
          "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" : "UNDETERMINED",
      "conditionIndex" : "101",
      "conditionText" : "''.isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-2",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "202",
      "conditionText" : "'123'.checkFormat('GCP')",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "unitTest(Test-3): '60s'.asDuration() == '1m'.asDuration()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "unitTest(Test-4): '60m'.asDuration() == '1h'.asDuration()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "unitTest(Test-5): '24h'.asDuration() == '1d'.asDuration()",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-6",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "699",
      "conditionText" : "unitTest(Test-6): '1s'.asDuration() == 'PT1S'",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "799",
      "conditionText" : "unitTest(Test-7): 'P1Y' != 'P365D'",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "899",
      "conditionText" : "unitTest(Test-8): 'P1Y' == 'P12M'",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-9",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "999",
      "conditionText" : "unitTest(Test-9): 'P1M' == 'P30D'",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleCloudKmsCryptoKey__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-2"
  }, {
    "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-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-8"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-01-01T00:00:00Z")
    },
    "Id" : "Test-9"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaGoogleCloudKmsCryptoKey__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 DurationLib = new function () {
          var googleFormatRegex = /(?<duration>^\d+)(?<unit>[smhd])/;
          var iso8601DurationRegex = /^P(?:(?<years>\d+)Y)?(?:(?<months>\d+)M)?(?:(?<days>\d+)D)?(?:T(?:(?<hours>\d+)H)?(?:(?<minutes>\d+)M)?(?:(?<seconds>\d+(?:\.\d+)?)S)?)?$/;
          this.parseGoogleFormat = function(arg) {
              var parsed = arg.toLowerCase().match(googleFormatRegex);
              if (parsed == null || parsed.groups == null || parsed.groups.duration == null || parsed.groups.unit == null) {
                  throw new Error("Invalid duration value: " + arg + ". Must match: \d+[smhd]");
              } else {
                  var durationValue = parseFloat(parsed.groups.duration);
                  var multiplier;
                  switch (parsed.groups.unit) {
                      case ('s'):
                          multiplier = 1;
                          break;
                      case ('m'):
                          multiplier = 60;
                          break;
                      case ('h'):
                          multiplier = 60*60;
                          break;
                      case ('d'):
                          multiplier = 60*60*24;
                          break;
                  }
                  return durationValue*multiplier;
              }
          };
          this.checkGoogleFormat = function(arg) {
              return arg != null && googleFormatRegex.test(arg);
          };
          this.parseIso8601Format = function(arg) {
              var parsed = arg.match(iso8601DurationRegex);
              if (parsed == null || parsed.groups == null) {
                  throw new Error("Invalid duration value: " + arg + ". Must match ISO 8601 duration format.");
              } else {
                  var out = 0;
                  if (parsed.groups.years) {
                      // simpliest way for normalizing - it's calculate month as 30 days in year and months convertings, otherwise P1Y != P12M
                      out += parseFloat(parsed.groups.years) * 60*60*24*30*12;
                  }
                  if (parsed.groups.months) {
                      out += parseFloat(parsed.groups.months) * 60*60*24*30;
                  }
                  if (parsed.groups.days) {
                      out += parseFloat(parsed.groups.days) * 60*60*24;
                  }
                  if (parsed.groups.hours) {
                      out += parseFloat(parsed.groups.hours) * 60*60;
                  }
                  if (parsed.groups.minutes) {
                      out += parseFloat(parsed.groups.minutes) * 60;
                  }
                  if (parsed.groups.seconds) {
                      out += parseFloat(parsed.groups.seconds);
                  }
                  return out;
              }
          }
          this.checkIso8601Format = function(arg) {
              return arg != null && iso8601DurationRegex.test(arg);
          };
          this.isEmpty = function(arg) {
              return arg == null || arg.trim() == '';
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Google [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]
      function durationChecked2() {
          var durationFrom3 = '';
          if (DurationLib.isEmpty(durationFrom3)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "''.isEmpty()", currentStateMessage: "Empty text received", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom3)) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "''.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom3);
      }
      try {
          if (obj.Id == 'Test-1' && DurationLib.isEmpty(durationChecked2())) {
              return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "unitTest(Test-1): ''.asDuration().isEmpty()", currentStateMessage: "Test-1", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function durationChecked4() {
          var durationFrom5 = '123';
          if (DurationLib.isEmpty(durationFrom5)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "'123'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom5)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "'123'.checkFormat('GCP')", currentStateMessage: "Invalid value received", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom5);
      }
      try {
          if (obj.Id == 'Test-2' && DurationLib.isEmpty(durationChecked4())) {
              return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "unitTest(Test-2): '123'.asDuration().isEmpty()", currentStateMessage: "Test-2", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function durationChecked6() {
          var durationFrom7 = '60s';
          if (DurationLib.isEmpty(durationFrom7)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "'60s'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom7)) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "'60s'.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom7);
      }
      function durationChecked8() {
          var durationFrom9 = '1m';
          if (DurationLib.isEmpty(durationFrom9)) {
              throw new Error("UNDETERMINED condition:303", {cause: {status: 'UNDETERMINED', conditionIndex: 303, conditionText: "'1m'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom9)) {
              throw new Error("UNDETERMINED condition:304", {cause: {status: 'UNDETERMINED', conditionIndex: 304, conditionText: "'1m'.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom9);
      }
      try {
          if (obj.Id == 'Test-3' && durationChecked6() == durationChecked8()) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "unitTest(Test-3): '60s'.asDuration() == '1m'.asDuration()", currentStateMessage: "Test-3", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[4], conditionIndex:[400..499]
      function durationChecked10() {
          var durationFrom11 = '60m';
          if (DurationLib.isEmpty(durationFrom11)) {
              throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "'60m'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom11)) {
              throw new Error("UNDETERMINED condition:402", {cause: {status: 'UNDETERMINED', conditionIndex: 402, conditionText: "'60m'.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom11);
      }
      function durationChecked12() {
          var durationFrom13 = '1h';
          if (DurationLib.isEmpty(durationFrom13)) {
              throw new Error("UNDETERMINED condition:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "'1h'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom13)) {
              throw new Error("UNDETERMINED condition:404", {cause: {status: 'UNDETERMINED', conditionIndex: 404, conditionText: "'1h'.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom13);
      }
      try {
          if (obj.Id == 'Test-4' && durationChecked10() == durationChecked12()) {
              return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "unitTest(Test-4): '60m'.asDuration() == '1h'.asDuration()", currentStateMessage: "Test-4", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[5], conditionIndex:[500..599]
      function durationChecked14() {
          var durationFrom15 = '24h';
          if (DurationLib.isEmpty(durationFrom15)) {
              throw new Error("UNDETERMINED condition:501", {cause: {status: 'UNDETERMINED', conditionIndex: 501, conditionText: "'24h'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom15)) {
              throw new Error("UNDETERMINED condition:502", {cause: {status: 'UNDETERMINED', conditionIndex: 502, conditionText: "'24h'.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom15);
      }
      function durationChecked16() {
          var durationFrom17 = '1d';
          if (DurationLib.isEmpty(durationFrom17)) {
              throw new Error("UNDETERMINED condition:503", {cause: {status: 'UNDETERMINED', conditionIndex: 503, conditionText: "'1d'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom17)) {
              throw new Error("UNDETERMINED condition:504", {cause: {status: 'UNDETERMINED', conditionIndex: 504, conditionText: "'1d'.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom17);
      }
      try {
          if (obj.Id == 'Test-5' && durationChecked14() == durationChecked16()) {
              return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "unitTest(Test-5): '24h'.asDuration() == '1d'.asDuration()", currentStateMessage: "Test-5", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[6], conditionIndex:[600..699]
      function durationChecked18() {
          var durationFrom19 = '1s';
          if (DurationLib.isEmpty(durationFrom19)) {
              throw new Error("UNDETERMINED condition:601", {cause: {status: 'UNDETERMINED', conditionIndex: 601, conditionText: "'1s'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (!DurationLib.checkGoogleFormat(durationFrom19)) {
              throw new Error("UNDETERMINED condition:602", {cause: {status: 'UNDETERMINED', conditionIndex: 602, conditionText: "'1s'.checkFormat('GCP')", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return DurationLib.parseGoogleFormat(durationFrom19);
      }
      try {
          if (obj.Id == 'Test-6' && durationChecked18() == DurationLib.parseIso8601Format('PT1S')) {
              return {status: 'COMPLIANT', conditionIndex: 699, conditionText: "unitTest(Test-6): '1s'.asDuration() == 'PT1S'", currentStateMessage: "Test-6", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[7], conditionIndex:[700..799]
      if (obj.Id == 'Test-7' && DurationLib.parseIso8601Format('P1Y') != DurationLib.parseIso8601Format('P365D')) {
          return {status: 'COMPLIANT', conditionIndex: 799, conditionText: "unitTest(Test-7): 'P1Y' != 'P365D'", currentStateMessage: "Test-7", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[8], conditionIndex:[800..899]
      if (obj.Id == 'Test-8' && DurationLib.parseIso8601Format('P1Y') == DurationLib.parseIso8601Format('P12M')) {
          return {status: 'COMPLIANT', conditionIndex: 899, conditionText: "unitTest(Test-8): 'P1Y' == 'P12M'", currentStateMessage: "Test-8", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[9], conditionIndex:[900..999]
      if (obj.Id == 'Test-9' && DurationLib.parseIso8601Format('P1M') == DurationLib.parseIso8601Format('P30D')) {
          return {status: 'COMPLIANT', conditionIndex: 999, conditionText: "unitTest(Test-9): 'P1M' == 'P30D'", currentStateMessage: "Test-9", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 1000, 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__CaGoogleCloudKmsCryptoKey__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaGoogleCloudKmsCryptoKey__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
