--- policy: /ce/unit-test/boolean-from logic: /ce/unit-test/boolean-from/unit-test.logic.yaml executionTime: 2026-03-21T12:07:24.841211273Z generationMs: 68 executionMs: 1831 rows: - id: Test-1 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: "unitTest(Test-1): 'true'.asBoolean()" actual: "unitTest(Test-1): 'true'.asBoolean()" runtimeError: {} - id: Test-2 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: "unitTest(Test-2): 'TRUE'.asBoolean()" actual: "unitTest(Test-2): 'TRUE'.asBoolean()" runtimeError: {} - id: Test-3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: "unitTest(Test-3): ' True '.asBoolean()" actual: "unitTest(Test-3): ' True '.asBoolean()" runtimeError: {} - id: Test-4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: "unitTest(Test-4): not('false'.asBoolean())" actual: "unitTest(Test-4): not('false'.asBoolean())" runtimeError: {} - id: Test-5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 599 actual: 599 conditionText: expected: "unitTest(Test-5): not('any-text'.asBoolean())" actual: "unitTest(Test-5): not('any-text'.asBoolean())" runtimeError: {} - id: Test-6 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 601 actual: 601 conditionText: expected: '''''.isEmpty()' actual: '''''.isEmpty()' runtimeError: {} - id: Test-7 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 701 actual: 701 conditionText: expected: null.isEmpty() actual: null.isEmpty() runtimeError: {} - id: Test-8 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 801 actual: 801 conditionText: expected: '''''.isEmpty()' actual: '''''.isEmpty()' runtimeError: {} - id: Test-9 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 999 actual: 999 conditionText: expected: "unitTest(Test-9): '1'.asBoolean('1')" actual: "unitTest(Test-9): '1'.asBoolean('1')" runtimeError: {} - id: Test-10 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 1099 actual: 1099 conditionText: expected: "unitTest(Test-10): not('Off'.asBoolean('On'))" actual: "unitTest(Test-10): not('Off'.asBoolean('On'))" runtimeError: {} - id: Test-11 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 1199 actual: 1199 conditionText: expected: "unitTest(Test-11): 'ENABLED'.asBoolean('Enabled')" actual: "unitTest(Test-11): 'ENABLED'.asBoolean('Enabled')" runtimeError: {} usedFiles: - path: /ce/unit-test/boolean-from/policy.yaml md5Hash: 08F481E6FF644828182859046A2FD1C6 content: | --- names: full: BOOLEAN_FROM Unit Tests contextual: BOOLEAN_FROM description: "Unit tests for BOOLEAN_FROM operation" - path: /ce/unit-test/boolean-from/unit-test.logic.yaml md5Hash: 17F48E6E2468FB3CD3917DE32E1030E5 content: |- --- inputType: CA10__CaAwsInstance__c conditions: - status: COMPLIANT currentStateMessage: Test-1 check: UNIT_TEST: id: Test-1 expected: text: "unitTest(Test-1): 'true'.asBoolean()" arg: BOOLEAN_FROM: arg: TEXT: "true" undeterminedIf: isEmpty: "Should not happen" - status: COMPLIANT currentStateMessage: Test-2 check: UNIT_TEST: id: Test-2 expected: text: "unitTest(Test-2): 'TRUE'.asBoolean()" arg: BOOLEAN_FROM: arg: TEXT: "TRUE" undeterminedIf: isEmpty: "Should not happen" - status: COMPLIANT currentStateMessage: Test-3 check: UNIT_TEST: id: Test-3 expected: text: "unitTest(Test-3): ' True '.asBoolean()" arg: BOOLEAN_FROM: arg: TEXT: " True " undeterminedIf: isEmpty: "Should not happen" - status: COMPLIANT currentStateMessage: Test-4 check: UNIT_TEST: id: Test-4 expected: text: "unitTest(Test-4): not('false'.asBoolean())" arg: NOT: arg: BOOLEAN_FROM: arg: TEXT: "false" undeterminedIf: isEmpty: "Should not happen" - status: COMPLIANT currentStateMessage: Test-5 check: UNIT_TEST: id: Test-5 expected: text: "unitTest(Test-5): not('any-text'.asBoolean())" arg: NOT: arg: BOOLEAN_FROM: arg: TEXT: "any-text" undeterminedIf: isEmpty: "Should not happen" - status: COMPLIANT currentStateMessage: Test-6 check: UNIT_TEST: id: Test-6 expected: status: UNDETERMINED subIndex: 1 text: "''.isEmpty()" arg: BOOLEAN_FROM: arg: TEXT: "" undeterminedIf: isEmpty: "Empty text received" - status: COMPLIANT currentStateMessage: Test-7 check: UNIT_TEST: id: Test-7 expected: status: UNDETERMINED subIndex: 1 text: "null.isEmpty()" arg: BOOLEAN_FROM: arg: UNIT_TEST_NULL: returnType: TEXT undeterminedIf: isEmpty: "Empty text received" - status: COMPLIANT currentStateMessage: Test-8 check: UNIT_TEST: id: Test-8 expected: status: UNDETERMINED subIndex: 1 text: "''.isEmpty()" arg: BOOLEAN_FROM: arg: TEXT: "" trueValue: "" undeterminedIf: isEmpty: "Empty text received" - status: COMPLIANT currentStateMessage: Test-9 check: UNIT_TEST: id: Test-9 expected: text: "unitTest(Test-9): '1'.asBoolean('1')" arg: BOOLEAN_FROM: arg: TEXT: "1" trueValue: "1" undeterminedIf: isEmpty: "Should not happen" - status: COMPLIANT currentStateMessage: Test-10 check: UNIT_TEST: id: Test-10 expected: text: "unitTest(Test-10): not('Off'.asBoolean('On'))" arg: NOT: arg: BOOLEAN_FROM: arg: TEXT: "Off" trueValue: "On" undeterminedIf: isEmpty: "Should not happen" - status: COMPLIANT currentStateMessage: Test-11 check: UNIT_TEST: id: Test-11 expected: text: "unitTest(Test-11): 'ENABLED'.asBoolean('Enabled')" arg: BOOLEAN_FROM: arg: TEXT: "ENABLED" trueValue: "Enabled" undeterminedIf: isEmpty: "Should not happen" otherwise: status: INCOMPLIANT currentStateMessage: Test Failed remediationMessage: Developer Fix Required script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "Test-1", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 199, "conditionText" : "unitTest(Test-1): 'true'.asBoolean()", "runtimeError" : null } }, { "Id" : "Test-2", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 299, "conditionText" : "unitTest(Test-2): 'TRUE'.asBoolean()", "runtimeError" : null } }, { "Id" : "Test-3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 399, "conditionText" : "unitTest(Test-3): ' True '.asBoolean()", "runtimeError" : null } }, { "Id" : "Test-4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 499, "conditionText" : "unitTest(Test-4): not('false'.asBoolean())", "runtimeError" : null } }, { "Id" : "Test-5", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 599, "conditionText" : "unitTest(Test-5): not('any-text'.asBoolean())", "runtimeError" : null } }, { "Id" : "Test-6", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : 601, "conditionText" : "''.isEmpty()", "runtimeError" : null } }, { "Id" : "Test-7", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : 701, "conditionText" : "null.isEmpty()", "runtimeError" : null } }, { "Id" : "Test-8", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : 801, "conditionText" : "''.isEmpty()", "runtimeError" : null } }, { "Id" : "Test-9", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 999, "conditionText" : "unitTest(Test-9): '1'.asBoolean('1')", "runtimeError" : null } }, { "Id" : "Test-10", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 1099, "conditionText" : "unitTest(Test-10): not('Off'.asBoolean('On'))", "runtimeError" : null } }, { "Id" : "Test-11", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : 1199, "conditionText" : "unitTest(Test-11): 'ENABLED'.asBoolean('Enabled')", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsInstance__c() RETURNS ARRAY >> 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" }, { "context" : { "snapshotTime" : new Date("2024-01-01T00:00:00.000Z") }, "Id" : "Test-10" }, { "context" : { "snapshotTime" : new Date("2024-01-01T00:00:00.000Z") }, "Id" : "Test-11" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsInstance__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT 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)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); 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] function boolChecked2() { if (TextLib.isEmpty('true')) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "'true'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('true', 'true'); } try { if (obj.Id == 'Test-1' && boolChecked2()) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "unitTest(Test-1): 'true'.asBoolean()", 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 boolChecked3() { if (TextLib.isEmpty('TRUE')) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "'TRUE'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('true', 'TRUE'); } try { if (obj.Id == 'Test-2' && boolChecked3()) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "unitTest(Test-2): 'TRUE'.asBoolean()", 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 boolChecked4() { if (TextLib.isEmpty(' True ')) { throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "' True '.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('true', ' True '); } try { if (obj.Id == 'Test-3' && boolChecked4()) { return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "unitTest(Test-3): ' True '.asBoolean()", 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 boolChecked5() { if (TextLib.isEmpty('false')) { throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "'false'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('true', 'false'); } try { if (obj.Id == 'Test-4' && !boolChecked5()) { return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "unitTest(Test-4): not('false'.asBoolean())", 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 boolChecked6() { if (TextLib.isEmpty('any-text')) { throw new Error("UNDETERMINED condition:501", {cause: {status: 'UNDETERMINED', conditionIndex: 501, conditionText: "'any-text'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('true', 'any-text'); } try { if (obj.Id == 'Test-5' && !boolChecked6()) { return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "unitTest(Test-5): not('any-text'.asBoolean())", 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 boolChecked7() { if (TextLib.isEmpty('')) { throw new Error("UNDETERMINED condition:601", {cause: {status: 'UNDETERMINED', conditionIndex: 601, conditionText: "''.isEmpty()", currentStateMessage: "Empty text received", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('true', ''); } try { if (obj.Id == 'Test-6' && boolChecked7()) { return {status: 'COMPLIANT', conditionIndex: 699, conditionText: "unitTest(Test-6): ''.asBoolean()", 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] function boolChecked8() { if (TextLib.isEmpty(null)) { throw new Error("UNDETERMINED condition:701", {cause: {status: 'UNDETERMINED', conditionIndex: 701, conditionText: "null.isEmpty()", currentStateMessage: "Empty text received", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('true', null); } try { if (obj.Id == 'Test-7' && boolChecked8()) { return {status: 'COMPLIANT', conditionIndex: 799, conditionText: "unitTest(Test-7): null.asBoolean()", currentStateMessage: "Test-7", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[8], conditionIndex:[800..899] function boolChecked9() { if (TextLib.isEmpty('')) { throw new Error("UNDETERMINED condition:801", {cause: {status: 'UNDETERMINED', conditionIndex: 801, conditionText: "''.isEmpty()", currentStateMessage: "Empty text received", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('', ''); } try { if (obj.Id == 'Test-8' && boolChecked9()) { return {status: 'COMPLIANT', conditionIndex: 899, conditionText: "unitTest(Test-8): ''.asBoolean('')", 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 boolChecked10() { if (TextLib.isEmpty('1')) { throw new Error("UNDETERMINED condition:901", {cause: {status: 'UNDETERMINED', conditionIndex: 901, conditionText: "'1'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('1', '1'); } try { if (obj.Id == 'Test-9' && boolChecked10()) { return {status: 'COMPLIANT', conditionIndex: 999, conditionText: "unitTest(Test-9): '1'.asBoolean('1')", 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; } } // condition[10], conditionIndex:[1000..1099] function boolChecked11() { if (TextLib.isEmpty('Off')) { throw new Error("UNDETERMINED condition:1001", {cause: {status: 'UNDETERMINED', conditionIndex: 1001, conditionText: "'Off'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('On', 'Off'); } try { if (obj.Id == 'Test-10' && !boolChecked11()) { return {status: 'COMPLIANT', conditionIndex: 1099, conditionText: "unitTest(Test-10): not('Off'.asBoolean('On'))", currentStateMessage: "Test-10", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[11], conditionIndex:[1100..1199] function boolChecked12() { if (TextLib.isEmpty('ENABLED')) { throw new Error("UNDETERMINED condition:1101", {cause: {status: 'UNDETERMINED', conditionIndex: 1101, conditionText: "'ENABLED'.isEmpty()", currentStateMessage: "Should not happen", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TextLib.equal('Enabled', 'ENABLED'); } try { if (obj.Id == 'Test-11' && boolChecked12()) { return {status: 'COMPLIANT', conditionIndex: 1199, conditionText: "unitTest(Test-11): 'ENABLED'.asBoolean('Enabled')", currentStateMessage: "Test-11", 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: 1200, 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;