---
policy: /ce/unit-test/and
logic: /ce/unit-test/and/unit-test.logic.yaml
executionTime: 2026-01-03T12:03:48.800744322Z
generationMs: 203
executionMs: 703
rows:
  - id: Test-1
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: "unitTest(Test-1): true"
      actual: "unitTest(Test-1): true"
    runtimeError: {}
  - id: Test-2
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "unitTest(Test-2): not(false)"
      actual: "unitTest(Test-2): not(false)"
    runtimeError: {}
  - id: Test-3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: "unitTest(Test-3): not(false && false)"
      actual: "unitTest(Test-3): not(false && false)"
    runtimeError: {}
  - id: Test-4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: "unitTest(Test-4): not(true && false)"
      actual: "unitTest(Test-4): not(true && false)"
    runtimeError: {}
  - id: Test-5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: "unitTest(Test-5): not(false && true)"
      actual: "unitTest(Test-5): not(false && true)"
    runtimeError: {}
  - id: Test-6
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 699
      actual: 699
    conditionText:
      expected: "unitTest(Test-6): true && true"
      actual: "unitTest(Test-6): true && true"
    runtimeError: {}
  - id: Test-7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 799
      actual: 799
    conditionText:
      expected: "unitTest(Test-7): not(true && true && false)"
      actual: "unitTest(Test-7): not(true && true && false)"
    runtimeError: {}
  - id: Test-8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 899
      actual: 899
    conditionText:
      expected: "unitTest(Test-8): not(false && error('Short-circuit evaluation: does\
        \ not compute second argument'))"
      actual: "unitTest(Test-8): not(false && error('Short-circuit evaluation: does\
        \ not compute second argument'))"
    runtimeError: {}
  - id: Test-9
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 901
      actual: 901
    conditionText:
      expected: "error('Short-circuit evaluation: compute second argument').throw()"
      actual: "error('Short-circuit evaluation: compute second argument').throw()"
    runtimeError:
      expected: "Short-circuit evaluation: compute second argument"
      actual: "Short-circuit evaluation: compute second argument"
usedFiles:
  - path: /ce/unit-test/and/policy.yaml
    md5Hash: CE65BADE101E4634663712661F2AD758
    content: |
      ---
      names:
        full: AND Unit Tests
        contextual: AND
      description: ""
  - path: /ce/unit-test/and/unit-test.logic.yaml
    md5Hash: 8ACD378FED89B7C7E87AED3FAB96D6D4
    content: |-
      ---
      inputType: CA10__CaAwsInstance__c
      conditions:
        - status: COMPLIANT
          currentStateMessage: Test-1
          check:
            UNIT_TEST:
              id: Test-1
              arg:
                AND:
                  args:
                    - BOOLEAN: true
              expected:
                text: "unitTest(Test-1): true"
        - status: COMPLIANT
          currentStateMessage: Test-2
          check:
            UNIT_TEST:
              id: Test-2
              arg:
                NOT:
                  arg:
                    AND:
                      args:
                        - BOOLEAN: false
              expected:
                text: "unitTest(Test-2): not(false)"
        - status: COMPLIANT
          currentStateMessage: Test-3
          check:
            UNIT_TEST:
              id: Test-3
              arg:
                NOT:
                  arg:
                    AND:
                      args:
                        - BOOLEAN: false
                        - BOOLEAN: false
              expected:
                text: "unitTest(Test-3): not(false && false)"
        - status: COMPLIANT
          currentStateMessage: Test-4
          check:
            UNIT_TEST:
              id: Test-4
              arg:
                NOT:
                  arg:
                    AND:
                      args:
                        - BOOLEAN: true
                        - BOOLEAN: false
              expected:
                text: "unitTest(Test-4): not(true && false)"
        - status: COMPLIANT
          currentStateMessage: Test-5
          check:
            UNIT_TEST:
              id: Test-5
              arg:
                NOT:
                  arg:
                    AND:
                      args:
                        - BOOLEAN: false
                        - BOOLEAN: true
              expected:
                text: "unitTest(Test-5): not(false && true)"
        - status: COMPLIANT
          currentStateMessage: Test-6
          check:
            UNIT_TEST:
              id: Test-6
              arg:
                AND:
                  args:
                    - BOOLEAN: true
                    - BOOLEAN: true
              expected:
                text: "unitTest(Test-6): true && true"
        - status: COMPLIANT
          currentStateMessage: Test-7
          check:
            UNIT_TEST:
              id: Test-7
              arg:
                NOT:
                  arg:
                    AND:
                      args:
                        - BOOLEAN: true
                        - BOOLEAN: true
                        - BOOLEAN: false
              expected:
                text: "unitTest(Test-7): not(true && true && false)"
        - status: COMPLIANT
          currentStateMessage: Test-8
          check:
            UNIT_TEST:
              id: Test-8
              arg:
                NOT:
                  arg:
                    AND:
                      args:
                        - BOOLEAN: false
                        - UNIT_TEST_RUNTIME_ERROR:
                            returnType: BOOLEAN
                            message: "Short-circuit evaluation: does not compute second argument"
              expected:
                text: "unitTest(Test-8): not(false && error('Short-circuit evaluation: does not compute second argument'))"
        - status: COMPLIANT
          currentStateMessage: Test-9
          check:
            UNIT_TEST:
              id: Test-9
              arg:
                AND:
                  args:
                    - BOOLEAN: true
                    - UNIT_TEST_RUNTIME_ERROR:
                        returnType: BOOLEAN
                        message: "Short-circuit evaluation: compute second argument"
              expected:
                status: UNDETERMINED
                subIndex: 1
                text: "error('Short-circuit evaluation: compute second argument').throw()"
                runtimeError: "Short-circuit evaluation: compute second argument"
      otherwise:
        status: INCOMPLIANT
        currentStateMessage: Test Failed
        remediationMessage: Developer Fix Required
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): true",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-2",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : 299,
      "conditionText" : "unitTest(Test-2): not(false)",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : 399,
      "conditionText" : "unitTest(Test-3): not(false && false)",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : 499,
      "conditionText" : "unitTest(Test-4): not(true && false)",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : 599,
      "conditionText" : "unitTest(Test-5): not(false && true)",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-6",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : 699,
      "conditionText" : "unitTest(Test-6): true && true",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : 799,
      "conditionText" : "unitTest(Test-7): not(true && true && false)",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : 899,
      "conditionText" : "unitTest(Test-8): not(false && error('Short-circuit evaluation: does not compute second argument'))",
      "runtimeError" : null
    }
  }, {
    "Id" : "Test-9",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : 901,
      "conditionText" : "error('Short-circuit evaluation: compute second argument').throw()",
      "runtimeError" : "Short-circuit evaluation: compute second argument"
    }
  } ];
  """;

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

  CREATE TEMP FUNCTION process_CA10__CaAwsInstance__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      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' && (true)) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "unitTest(Test-1): true", currentStateMessage: "Test-1", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      if (obj.Id == 'Test-2' && !(false)) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "unitTest(Test-2): not(false)", currentStateMessage: "Test-2", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      if (obj.Id == 'Test-3' && !(false && false)) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "unitTest(Test-3): not(false && false)", currentStateMessage: "Test-3", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      if (obj.Id == 'Test-4' && !(true && false)) {
          return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "unitTest(Test-4): not(true && false)", currentStateMessage: "Test-4", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      if (obj.Id == 'Test-5' && !(false && true)) {
          return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "unitTest(Test-5): not(false && true)", currentStateMessage: "Test-5", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[6], conditionIndex:[600..699]
      if (obj.Id == 'Test-6' && (true && true)) {
          return {status: 'COMPLIANT', conditionIndex: 699, conditionText: "unitTest(Test-6): true && true", currentStateMessage: "Test-6", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[7], conditionIndex:[700..799]
      if (obj.Id == 'Test-7' && !(true && true && false)) {
          return {status: 'COMPLIANT', conditionIndex: 799, conditionText: "unitTest(Test-7): not(true && true && false)", currentStateMessage: "Test-7", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[8], conditionIndex:[800..899]
      function unitTestRuntimeError2() {
              throw new Error("UNDETERMINED condition:801", {cause: {status: 'UNDETERMINED', conditionIndex: 801, conditionText: "error('Short-circuit evaluation: does not compute second argument').throw()", currentStateMessage: "Short-circuit evaluation: does not compute second argument", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: new Error('Short-circuit evaluation: does not compute second argument').message}});
          return null;
      }
      try {
          if (obj.Id == 'Test-8' && !(false && unitTestRuntimeError2())) {
              return {status: 'COMPLIANT', conditionIndex: 899, conditionText: "unitTest(Test-8): not(false && error('Short-circuit evaluation: does not compute second argument'))", currentStateMessage: "Test-8", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[9], conditionIndex:[900..999]
      function unitTestRuntimeError3() {
              throw new Error("UNDETERMINED condition:901", {cause: {status: 'UNDETERMINED', conditionIndex: 901, conditionText: "error('Short-circuit evaluation: compute second argument').throw()", currentStateMessage: "Short-circuit evaluation: compute second argument", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: new Error('Short-circuit evaluation: compute second argument').message}});
          return null;
      }
      try {
          if (obj.Id == 'Test-9' && (true && unitTestRuntimeError3())) {
              return {status: 'COMPLIANT', conditionIndex: 999, conditionText: "unitTest(Test-9): true && error('Short-circuit evaluation: compute second argument')", currentStateMessage: "Test-9", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.Id AS Id,
          process_CA10__CaAwsInstance__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsInstance__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
