---
policy: /ce/ca/azure/virtual-machine/virtual-machine-idle
logic: /ce/ca/azure/virtual-machine/virtual-machine-idle/prod.logic.yaml
executionTime: 2025-05-10T12:04:13.175635778Z
rows:
  - id: test1
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__powerState__c') != 'VM running'
      actual: extract('CA10__powerState__c') != 'VM running'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: not(extract('CA10__timeCreated__c').beyondLastDays(14))
      actual: not(extract('CA10__timeCreated__c').beyondLastDays(14))
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10__monitorCpuAvg14Day__c') < number(5.0) && extract('CA10__monitorCpuMax14Day__c')
        < number(15.0) && extract('CA10__monitorNetworkInMbSum14Day__c') < number(100.0)
        && extract('CA10__monitorNetworkOutMbSum14Day__c') < number(100.0)
      actual: extract('CA10__monitorCpuAvg14Day__c') < number(5.0) && extract('CA10__monitorCpuMax14Day__c')
        < number(15.0) && extract('CA10__monitorNetworkInMbSum14Day__c') < number(100.0)
        && extract('CA10__monitorNetworkOutMbSum14Day__c') < number(100.0)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 500
      actual: 500
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/virtual-machine/virtual-machine-idle/policy.yaml
    md5Hash: F319682F11AFCD287882B42C47525861
    content: "---\nnames:\n  full: \"Azure Virtual Machine is idle\"\n  contextual:\
      \ \"Virtual Machine is idle\"\ndescription: >\n  Identify and address idle Azure\
      \ Virtual Machines to optimize costs by stopping, \n  terminating, or downscaling\
      \ VMs with low utilization. VMs are \n  considered idle if their average CPU\
      \ utilization is below 5%, maximum CPU \n  utilization is below 15%, and average\
      \ network I/O is below 100 MB over a 14-day period.\ncategories:\n  - \"COST\"\
      \n  - \"PERFORMANCE\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n  -\
      \ \"/frameworks/cloudaware/cost-efficiency-and-optimization/waste-reduction\"\
      \n  - \"/frameworks/cloudaware/resource-performance/workload-efficiency\""
  - path: /ce/ca/azure/virtual-machine/virtual-machine-idle/prod.logic.yaml
    md5Hash: F374915250598131BE87B48DAF076D1F
    content: |-
      ---
      inputType: "CA10__CaAzureVirtualMachine__c"
      testData:
        - file: test-data.json
      importExtracts:
        - file: /types/CA10__CaAzureVirtualMachine__c/object.extracts.yaml
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "Only for running VM"
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10__powerState__c"
              right:
                TEXT: "VM running"
        - status: "INAPPLICABLE"
          currentStateMessage: "The VM has been running for less than 14 days."
          check:
            NOT:
              arg:
                IS_BEYOND_LAST_DAYS:
                  offsetDays: 14
                  arg:
                    EXTRACT: "CA10__timeCreated__c"
        - status: UNDETERMINED
          currentStateMessage: "There is not enough data in the CMDB to identify if the VM is idle."
          check:
            OR:
              args:
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10__monitorCpuAvg14Day__c"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10__monitorCpuMax14Day__c"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10__monitorNetworkInMbSum14Day__c"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10__monitorNetworkOutMbSum14Day__c"
        - status: INCOMPLIANT
          currentStateMessage: "The VM is idle with Average CPU Utilization < 5%,\
            \ Max CPU Utilization < 15%, and Average Network I/O < 100 MB."
          remediationMessage: "Consider stopping, terminating, or rightsizing the instance."
          check:
            AND:
              args:
                - LESS_THAN:
                    left:
                      EXTRACT: CA10__monitorCpuAvg14Day__c
                    right:
                      NUMBER: 5.0
                - LESS_THAN:
                    left:
                      EXTRACT: CA10__monitorCpuMax14Day__c
                    right:
                      NUMBER: 15.0
                - LESS_THAN:
                    left:
                      EXTRACT: CA10__monitorNetworkInMbSum14Day__c
                    right:
                      NUMBER: 100.0
                - LESS_THAN:
                    left:
                      EXTRACT: CA10__monitorNetworkOutMbSum14Day__c
                    right:
                      NUMBER: 100.0
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The VM is not idle."
  - path: /types/CA10__CaAzureVirtualMachine__c/object.extracts.yaml
    md5Hash: 6E9F97B836205092BD497D4536766346
    content: "---\nextracts:\n# Values: TrustedLaunch, ConfidentialVM. Nullable. Retrieved\
      \ via Microsoft.Compute/virtualMachines\n  - name: \"CA10__securityProfileSecurityType__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__securityProfileSecurityType__c\"\
      \n# Values: Enabled, Disabled. Nullable. Retrieved via Microsoft.Compute/virtualMachines\n\
      \  - name: \"CA10__uefiSettingsVTpm__c\"\n    value: \n      FIELD:\n      \
      \  path: \"CA10__uefiSettingsVTpm__c\"\n# Values: Enabled, Disabled. Nullable.\
      \ Retrieved via Microsoft.Compute/virtualMachines\n  - name: \"CA10__uefiSettingsSecureBoot__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__uefiSettingsSecureBoot__c\"\
      \   \n# Values: \"VM creating\", \"VM starting\",  \"VM running\", \"VM stopping\"\
      ,  \"VM stopped\", \"VM deallocating\",  \"VM deallocated\"\n  - name: \"CA10__powerState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__powerState__c\" \n# Percent\n\
      \  - name: \"CA10__monitorCpuAvg14Day__c\"\n    value: \n      FIELD:\n    \
      \    path: \"CA10__monitorCpuAvg14Day__c\" \n# Percent\n  - name: \"CA10__monitorCpuMax14Day__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__monitorCpuMax14Day__c\" \n\
      \  - name: \"CA10__monitorNetworkInMbSum14Day__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__monitorNetworkInMbSum14Day__c\" \n  - name: \"CA10__monitorNetworkOutMbSum14Day__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__monitorNetworkOutMbSum14Day__c\"\
      \ \n# Date/time\n  - name: \"CA10__timeCreated__c\"\n    value:\n      FIELD:\n\
      \        path: \"CA10__timeCreated__c\""
  - path: /ce/ca/azure/virtual-machine/virtual-machine-idle/test-data.json
    md5Hash: F929E4C33054499CFC2478573C79BD08
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-04-24T01:44:28Z"
              },
              "Id": "test1",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": "2025-04-17T10:19:57Z",
              "CA10__powerState__c": "VM running",
              "CA10__timeCreated__c": "2024-04-16T19:01:32Z",
              "CA10__monitorCpuAvg14Day__c": 5.0,
              "CA10__monitorCpuMax14Day__c": 10.0,
              "CA10__monitorNetworkInMbSum14Day__c": 10.0,
              "CA10__monitorNetworkOutMbSum14Day__c": 10.0,
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachine",
                  "Id": "RecordTypeId"
              }
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__powerState__c') != 'VM running'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-04-24T01:44:28Z"
              },
              "Id": "test2",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__powerState__c": "VM deallocated",
              "CA10__timeCreated__c": "2024-04-02T04:10:49Z",
              "CA10__monitorCpuAvg14Day__c": 5.0,
              "CA10__monitorCpuMax14Day__c": 10.0,
              "CA10__monitorNetworkInMbSum14Day__c": 10.0,
              "CA10__monitorNetworkOutMbSum14Day__c": 10.0,
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachine",
                  "Id": "RecordTypeId"
              }
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "299",
                  "conditionText": "not(extract('CA10__timeCreated__c').beyondLastDays(14))",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-04-24T01:44:28Z"
              },
              "Id": "test3",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__powerState__c": "VM running",
              "CA10__timeCreated__c": "2025-04-24T01:44:28Z",
              "CA10__monitorCpuAvg14Day__c": 5.0,
              "CA10__monitorCpuMax14Day__c": 10.0,
              "CA10__monitorNetworkInMbSum14Day__c": 10.0,
              "CA10__monitorNetworkOutMbSum14Day__c": 10.0,
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachine",
                  "Id": "RecordTypeId"
              }
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "extract('CA10__monitorCpuAvg14Day__c') < number(5.0) && extract('CA10__monitorCpuMax14Day__c') < number(15.0) && extract('CA10__monitorNetworkInMbSum14Day__c') < number(100.0) && extract('CA10__monitorNetworkOutMbSum14Day__c') < number(100.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-04-24T01:44:28Z"
              },
              "Id": "test4",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__powerState__c": "VM running",
              "CA10__timeCreated__c": "2024-06-17T09:40:03Z",
              "CA10__monitorCpuAvg14Day__c": 1.0,
              "CA10__monitorCpuMax14Day__c": 10.0,
              "CA10__monitorNetworkInMbSum14Day__c": 10.0,
              "CA10__monitorNetworkOutMbSum14Day__c": 10.0,
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachine",
                  "Id": "RecordTypeId"
              }
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "500",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-04-24T01:44:28Z"
              },
              "Id": "test5",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__powerState__c": "VM running",
              "CA10__timeCreated__c": "2024-04-01T21:29:13Z",
              "CA10__monitorCpuAvg14Day__c": 9.0,
              "CA10__monitorCpuMax14Day__c": 99.0,
              "CA10__monitorNetworkInMbSum14Day__c": 1000.0,
              "CA10__monitorNetworkOutMbSum14Day__c": 1000.0,
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachine",
                  "Id": "RecordTypeId"
              }
          }
      ]
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" : "test1",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__powerState__c') != 'VM running'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "299",
      "conditionText" : "not(extract('CA10__timeCreated__c').beyondLastDays(14))",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('CA10__monitorCpuAvg14Day__c') < number(5.0) && extract('CA10__monitorCpuMax14Day__c') < number(15.0) && extract('CA10__monitorNetworkInMbSum14Day__c') < number(100.0) && extract('CA10__monitorNetworkOutMbSum14Day__c') < number(100.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "500",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureVirtualMachine__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__powerState__c STRING,
      CA10__timeCreated__c TIMESTAMP,
      CA10__monitorCpuAvg14Day__c FLOAT64,
      CA10__monitorCpuMax14Day__c FLOAT64,
      CA10__monitorNetworkInMbSum14Day__c FLOAT64,
      CA10__monitorNetworkOutMbSum14Day__c FLOAT64,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-24T01:44:28Z")
    },
    "Id" : "test1",
    "RecordTypeId" : "RecordTypeId",
    "CA10__disappearanceTime__c" : new Date("2025-04-17T10:19:57Z"),
    "CA10__powerState__c" : "VM running",
    "CA10__timeCreated__c" : new Date("2024-04-16T19:01:32Z"),
    "CA10__monitorCpuAvg14Day__c" : 5.0,
    "CA10__monitorCpuMax14Day__c" : 10.0,
    "CA10__monitorNetworkInMbSum14Day__c" : 10.0,
    "CA10__monitorNetworkOutMbSum14Day__c" : 10.0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-24T01:44:28Z")
    },
    "Id" : "test2",
    "RecordTypeId" : "RecordTypeId",
    "CA10__powerState__c" : "VM deallocated",
    "CA10__timeCreated__c" : new Date("2024-04-02T04:10:49Z"),
    "CA10__monitorCpuAvg14Day__c" : 5.0,
    "CA10__monitorCpuMax14Day__c" : 10.0,
    "CA10__monitorNetworkInMbSum14Day__c" : 10.0,
    "CA10__monitorNetworkOutMbSum14Day__c" : 10.0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-24T01:44:28Z")
    },
    "Id" : "test3",
    "RecordTypeId" : "RecordTypeId",
    "CA10__powerState__c" : "VM running",
    "CA10__timeCreated__c" : new Date("2025-04-24T01:44:28Z"),
    "CA10__monitorCpuAvg14Day__c" : 5.0,
    "CA10__monitorCpuMax14Day__c" : 10.0,
    "CA10__monitorNetworkInMbSum14Day__c" : 10.0,
    "CA10__monitorNetworkOutMbSum14Day__c" : 10.0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-24T01:44:28Z")
    },
    "Id" : "test4",
    "RecordTypeId" : "RecordTypeId",
    "CA10__powerState__c" : "VM running",
    "CA10__timeCreated__c" : new Date("2024-06-17T09:40:03Z"),
    "CA10__monitorCpuAvg14Day__c" : 1.0,
    "CA10__monitorCpuMax14Day__c" : 10.0,
    "CA10__monitorNetworkInMbSum14Day__c" : 10.0,
    "CA10__monitorNetworkOutMbSum14Day__c" : 10.0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-24T01:44:28Z")
    },
    "Id" : "test5",
    "RecordTypeId" : "RecordTypeId",
    "CA10__powerState__c" : "VM running",
    "CA10__timeCreated__c" : new Date("2024-04-01T21:29:13Z"),
    "CA10__monitorCpuAvg14Day__c" : 9.0,
    "CA10__monitorCpuMax14Day__c" : 99.0,
    "CA10__monitorNetworkInMbSum14Day__c" : 1000.0,
    "CA10__monitorNetworkOutMbSum14Day__c" : 1000.0
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      DeveloperName STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-24T01:44:28Z")
    },
    "DeveloperName" : "caAzureRMVirtualMachine",
    "Id" : "RecordTypeId"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureVirtualMachine__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__powerState__c STRING,
          CA10__timeCreated__c TIMESTAMP,
          CA10__monitorCpuAvg14Day__c FLOAT64,
          CA10__monitorCpuMax14Day__c FLOAT64,
          CA10__monitorNetworkInMbSum14Day__c FLOAT64,
          CA10__monitorNetworkOutMbSum14Day__c FLOAT64,
          RecordType STRUCT<
              DeveloperName STRING,
              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 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 todayMinus14Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-14 * 86400000);
      var IsEmptyLib = new function () {
          this.simpleIsEmpty = function(arg) {
              return arg == null;
          };
          this.simpleIsNotEmpty = function(arg) {
              return arg != null;
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Azure [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 extract3() { if (!this.out) { this.out = obj.CA10__powerState__c; } return this.out; };
      references1.push('Power State [obj.CA10__powerState__c]: ' + obj.CA10__powerState__c);
      if (TextLib.notEqual(extract3.call(extract3), 'VM running')) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__powerState__c') != 'VM running'", currentStateMessage: "Only for running VM", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__timeCreated__c; } return this.out; };
      references1.push('Time Created [obj.CA10__timeCreated__c]: ' + obj.CA10__timeCreated__c);
      if (!(extract6.call(extract6) != null && extract6.call(extract6).getTime() < todayMinus14Day)) {
          return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "not(extract('CA10__timeCreated__c').beyondLastDays(14))", currentStateMessage: "The VM has been running for less than 14 days.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract10() { if (!this.out) { this.out = obj.CA10__monitorCpuAvg14Day__c; } return this.out; };
      function extract13() { if (!this.out) { this.out = obj.CA10__monitorCpuMax14Day__c; } return this.out; };
      function extract16() { if (!this.out) { this.out = obj.CA10__monitorNetworkInMbSum14Day__c; } return this.out; };
      function extract19() { if (!this.out) { this.out = obj.CA10__monitorNetworkOutMbSum14Day__c; } return this.out; };
      references1.push('Monitor: CPU, 14-Day [obj.CA10__monitorCpuAvg14Day__c]: ' + obj.CA10__monitorCpuAvg14Day__c);
      references1.push('Monitor: CPU Max, 14-Day [obj.CA10__monitorCpuMax14Day__c]: ' + obj.CA10__monitorCpuMax14Day__c);
      references1.push('Monitor: Network In, MB, 14-Day [obj.CA10__monitorNetworkInMbSum14Day__c]: ' + obj.CA10__monitorNetworkInMbSum14Day__c);
      references1.push('Monitor: Network Out, MB, 14-Day [obj.CA10__monitorNetworkOutMbSum14Day__c]: ' + obj.CA10__monitorNetworkOutMbSum14Day__c);
      if (IsEmptyLib.simpleIsEmpty(extract10.call(extract10)) || IsEmptyLib.simpleIsEmpty(extract13.call(extract13)) || IsEmptyLib.simpleIsEmpty(extract16.call(extract16)) || IsEmptyLib.simpleIsEmpty(extract19.call(extract19))) {
          return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "extract('CA10__monitorCpuAvg14Day__c').isEmpty() || extract('CA10__monitorCpuMax14Day__c').isEmpty() || extract('CA10__monitorNetworkInMbSum14Day__c').isEmpty() || extract('CA10__monitorNetworkOutMbSum14Day__c').isEmpty()", currentStateMessage: "There is not enough data in the CMDB to identify if the VM is idle.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function extract23() { if (!this.out) { this.out = obj.CA10__monitorCpuAvg14Day__c; } return this.out; };
      function extract27() { if (!this.out) { this.out = obj.CA10__monitorCpuMax14Day__c; } return this.out; };
      function extract31() { if (!this.out) { this.out = obj.CA10__monitorNetworkInMbSum14Day__c; } return this.out; };
      function extract35() { if (!this.out) { this.out = obj.CA10__monitorNetworkOutMbSum14Day__c; } return this.out; };
      if ((extract23.call(extract23) != null && 5.0 != null && extract23.call(extract23) < 5.0) && (extract27.call(extract27) != null && 15.0 != null && extract27.call(extract27) < 15.0) && (extract31.call(extract31) != null && 100.0 != null && extract31.call(extract31) < 100.0) && (extract35.call(extract35) != null && 100.0 != null && extract35.call(extract35) < 100.0)) {
          return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__monitorCpuAvg14Day__c') < number(5.0) && extract('CA10__monitorCpuMax14Day__c') < number(15.0) && extract('CA10__monitorNetworkInMbSum14Day__c') < number(100.0) && extract('CA10__monitorNetworkOutMbSum14Day__c') < number(100.0)", currentStateMessage: "The VM is idle with Average CPU Utilization < 5%, Max CPU Utilization < 15%, and Average Network I/O < 100 MB.", currentStateReferences: references1.join('\n'), remediation: "Consider stopping, terminating, or rightsizing the instance.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The VM is not idle.", currentStateReferences: references1.join('\n'), remediation: null, 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.RecordTypeId AS RecordTypeId,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__powerState__c AS CA10__powerState__c,
          sObject.CA10__timeCreated__c AS CA10__timeCreated__c,
          sObject.CA10__monitorCpuAvg14Day__c AS CA10__monitorCpuAvg14Day__c,
          sObject.CA10__monitorCpuMax14Day__c AS CA10__monitorCpuMax14Day__c,
          sObject.CA10__monitorNetworkInMbSum14Day__c AS CA10__monitorNetworkInMbSum14Day__c,
          sObject.CA10__monitorNetworkOutMbSum14Day__c AS CA10__monitorNetworkOutMbSum14Day__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          process_CA10__CaAzureVirtualMachine__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__powerState__c AS CA10__powerState__c,
                  sObject.CA10__timeCreated__c AS CA10__timeCreated__c,
                  sObject.CA10__monitorCpuAvg14Day__c AS CA10__monitorCpuAvg14Day__c,
                  sObject.CA10__monitorCpuMax14Day__c AS CA10__monitorCpuMax14Day__c,
                  sObject.CA10__monitorNetworkInMbSum14Day__c AS CA10__monitorNetworkInMbSum14Day__c,
                  sObject.CA10__monitorNetworkOutMbSum14Day__c AS CA10__monitorNetworkOutMbSum14Day__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureVirtualMachine__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
  ) sObject ON sObject.Id = expectedResult.Id;
