diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 66b92a7..ae7188f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,15 +11,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ github.ref }} fetch-depth: 0 - - uses: actions/setup-node@v1 + - name: "Setup node" + uses: actions/setup-node@v4 with: - node-version: ">=14" - check-latest: true + node-version: "lts/*" - name: Install Salesforce CLI + Scanner run: | @@ -37,6 +37,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Authenticate into DevHub + id: authenticate run: | echo "${SALESFORCE_JWT_SECRET_KEY}" > server.key sf org login jwt --client-id ${{ secrets.SALESFORCE_CONSUMER_KEY }} --jwt-key-file server.key --username ${{ secrets.SALESFORCE_DEVHUB_USERNAME}} --set-default-dev-hub --alias devhub diff --git a/.husky/_/pre-commit b/.husky/_/pre-commit new file mode 100644 index 0000000..f27575a --- /dev/null +++ b/.husky/_/pre-commit @@ -0,0 +1 @@ +npm run precommit diff --git a/.prettierrc b/.prettierrc index 50f14e3..e846e6b 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,15 +1,69 @@ { - "plugins": ["prettier-plugin-apex"], + "arrowParens": "avoid", + "bracketSpacing": true, + "bracketSameLine": true, + "printWidth": 100, + "semi": true, + "singleQuote": true, "trailingComma": "none", + "endOfLine": "lf", + "apexInsertFinalNewline": false, "useTabs": true, "overrides": [ { "files": "**/lwc/**/*.html", "options": { "parser": "lwc" } }, + { + "files": "*.{cls,trigger}", + "options": { "parser": "apex", "tabWidth": 2, "useTabs": true } + }, { "files": "*.{cmp,page,component}", - "options": { "parser": "html" } + "options": { + "parser": "html", + "useTabs": true, + "htmlWhitespaceSensitivity": "css" + } + }, + { + "files": "*.{apex,soql}", + "options": { "parser": "apex-anonymous" } + }, + { + "files": "*.{yml,yaml}", + "options": { "parser": "yaml", "tabWidth": 2, "useTabs": false } + }, + { + "files": ".prettier*", + "options": { "parser": "json", "printWidth": 80, "useTabs": true } + }, + { + "files": "*.xml", + "options": { + "parser": "xml", + "useTabs": true, + "singleQuote": false, + "xmlSelfClosingSpace": true + } + }, + { + "files": "*meta.xml", + "options": { + "parser": "xml", + "useTabs": false, + "xmlSelfClosingSpace": false + } + }, + { + "files": "*.json", + "options": { + "parser": "json-stringify", + "useTabs": false, + "tabWidth": 2 + } } - ] + ], + "plugins": ["prettier-plugin-apex", "@prettier/plugin-xml"], + "$schema": "https://json.schemastore.org/prettierrc" } diff --git a/package.json b/package.json index 6664238..2377e4c 100644 --- a/package.json +++ b/package.json @@ -4,33 +4,17 @@ "version": "1.0.0", "description": "Apex Trigger Actions Framework", "scripts": { - "lint": "npm run lint:lwc && npm run lint:aura", - "lint:aura": "eslint **/aura/**", - "lint:lwc": "eslint **/lwc/**", - "test": "npm run test:unit", - "test:unit": "sfdx-lwc-jest", - "test:unit:watch": "sfdx-lwc-jest --watch", - "test:unit:debug": "sfdx-lwc-jest --debug", - "test:unit:coverage": "sfdx-lwc-jest --coverage", - "prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,yaml,yml}\"", - "prettier:verify": "prettier --list-different \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,yaml,yml}\"" + "precommit": "lint-staged", + "prepare": "husky", + "prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"", + "prettier:verify": "prettier --list-different \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"" }, "devDependencies": { - "@prettier/plugin-xml": "^0.13.1", - "@salesforce/eslint-config-lwc": "^0.11.1", - "@salesforce/eslint-plugin-aura": "^2.0.0", - "@salesforce/sfdx-lwc-jest": "^0.10.4", - "eslint": "^7.24.0", - "eslint-config-prettier": "^8.1.0", - "husky": "^6.0.0", - "lint-staged": "^10.5.4", - "prettier": "3.0.2", - "prettier-plugin-apex": "2.0.1" - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } + "@prettier/plugin-xml": "^3.4.1", + "husky": "^9.1.7", + "lint-staged": "^15.5.0", + "prettier": "3.5.3", + "prettier-plugin-apex": "2.2.5" }, "lint-staged": { "**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}": [ diff --git a/sfdx-project.json b/sfdx-project.json index 434d9e2..1422e07 100644 --- a/sfdx-project.json +++ b/sfdx-project.json @@ -45,4 +45,4 @@ "Trigger Actions Framework@0.3.1-7": "04tKY000000PdZJYA0", "Trigger Actions Framework@0.3.2": "04tKY000000PdZOYA0" } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/FinalizerHandler.cls b/trigger-actions-framework/main/default/classes/FinalizerHandler.cls index 61b81f4..8d9c274 100644 --- a/trigger-actions-framework/main/default/classes/FinalizerHandler.cls +++ b/trigger-actions-framework/main/default/classes/FinalizerHandler.cls @@ -121,10 +121,7 @@ public with sharing virtual class FinalizerHandler { * @param finalizerMetadata The metadata of the finalizer to execute. * @param context The context to pass to the finalizer's `execute` method. */ - private void callReferencedFinalizer( - DML_Finalizer__mdt finalizerMetadata, - Context context - ) { + private void callReferencedFinalizer(DML_Finalizer__mdt finalizerMetadata, Context context) { Object dynamicInstance; String className = finalizerMetadata.Apex_Class_Name__c; if (FinalizerHandler.isBypassed(className)) { @@ -166,9 +163,7 @@ public with sharing virtual class FinalizerHandler { } private void handleFinalizerException(String errorFormat, String className) { - throw new FinalizerException( - String.format(errorFormat, new List{ className }) - ); + throw new FinalizerException(String.format(errorFormat, new List{ className })); } /** @@ -178,10 +173,7 @@ public with sharing virtual class FinalizerHandler { * @param requiredPermission The required permission for the finalizer. * @return True if bypassed, false otherwise. */ - private boolean isBypassed( - String bypassPermission, - String requiredPermission - ) { + private boolean isBypassed(String bypassPermission, String requiredPermission) { return (bypassPermission != null && permissionMap.get(bypassPermission)) || (requiredPermission != null && !permissionMap.get(requiredPermission)); } @@ -192,10 +184,7 @@ public with sharing virtual class FinalizerHandler { */ private void populatePermissionMap(String permissionName) { if (permissionName != null && !permissionMap.containsKey(permissionName)) { - permissionMap.put( - permissionName, - FeatureManagement.checkPermission(permissionName) - ); + permissionMap.put(permissionName, FeatureManagement.checkPermission(permissionName)); } } @@ -231,8 +220,7 @@ public with sharing virtual class FinalizerHandler { * equal to, or greater than the specified object. */ public Integer compareTo(Object other) { - Decimal difference = (this.metadata.Order__c - - ((FinalizerSorter) other).metadata.Order__c); + Decimal difference = (this.metadata.Order__c - ((FinalizerSorter) other).metadata.Order__c); return difference < 0 ? -1 : difference == 0 ? 0 : 1; } } @@ -249,4 +237,4 @@ public with sharing virtual class FinalizerHandler { */ private class FinalizerException extends Exception { } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/FinalizerHandlerTest.cls b/trigger-actions-framework/main/default/classes/FinalizerHandlerTest.cls index 637fbb8..1c89cc7 100644 --- a/trigger-actions-framework/main/default/classes/FinalizerHandlerTest.cls +++ b/trigger-actions-framework/main/default/classes/FinalizerHandlerTest.cls @@ -94,10 +94,7 @@ private with sharing class FinalizerHandlerTest { @IsTest private static void staticallyBypassedFinalizerShouldNotExecute() { handler.allFinalizers = new List{ - new DML_Finalizer__mdt( - Apex_Class_Name__c = TEST_FOO_FINALIZER, - Order__c = 1 - ) + new DML_Finalizer__mdt(Apex_Class_Name__c = TEST_FOO_FINALIZER, Order__c = 1) }; FinalizerHandler.bypass(TEST_FOO_FINALIZER); @@ -150,14 +147,8 @@ private with sharing class FinalizerHandlerTest { @IsTest private static void finalizersShouldExecuteInOrder() { handler.allFinalizers = new List{ - new DML_Finalizer__mdt( - Apex_Class_Name__c = TEST_FOO_FINALIZER, - Order__c = 1 - ), - new DML_Finalizer__mdt( - Apex_Class_Name__c = TEST_BAR_FINALIZER, - Order__c = 2 - ) + new DML_Finalizer__mdt(Apex_Class_Name__c = TEST_FOO_FINALIZER, Order__c = 1), + new DML_Finalizer__mdt(Apex_Class_Name__c = TEST_BAR_FINALIZER, Order__c = 2) }; handler.handleDynamicFinalizers(); @@ -213,10 +204,7 @@ private with sharing class FinalizerHandlerTest { System.Assert.isNotNull(myException, EXCEPTION_SHOULD_BE_THROWN); System.Assert.areEqual( - String.format( - FinalizerHandler.INVALID_TYPE_ERROR_FINALIZER, - new List{ MY_CLASS } - ), + String.format(FinalizerHandler.INVALID_TYPE_ERROR_FINALIZER, new List{ MY_CLASS }), myException.getMessage(), EXCEPTION_SHOULD_HAVE_CORRECT_MESSAGE ); @@ -307,4 +295,4 @@ private with sharing class FinalizerHandlerTest { Database.setSavepoint(); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/FlowChangeEventHeader.cls b/trigger-actions-framework/main/default/classes/FlowChangeEventHeader.cls index 6a28a43..a72ae1c 100644 --- a/trigger-actions-framework/main/default/classes/FlowChangeEventHeader.cls +++ b/trigger-actions-framework/main/default/classes/FlowChangeEventHeader.cls @@ -113,4 +113,4 @@ public with sharing class FlowChangeEventHeader { public Integer hashCode() { return JSON.serialize(this).hashCode(); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/FlowChangeEventHeaderTest.cls b/trigger-actions-framework/main/default/classes/FlowChangeEventHeaderTest.cls index 32db838..2cf5e7d 100644 --- a/trigger-actions-framework/main/default/classes/FlowChangeEventHeaderTest.cls +++ b/trigger-actions-framework/main/default/classes/FlowChangeEventHeaderTest.cls @@ -23,10 +23,7 @@ private with sharing class FlowChangeEventHeaderTest { @IsTest private static void shouldBeAbleToConstruct() { - System.Assert.isNotNull( - header, - 'Unable to construct a FlowChangeEventHeader' - ); + System.Assert.isNotNull(header, 'Unable to construct a FlowChangeEventHeader'); } @IsTest @@ -36,9 +33,7 @@ private with sharing class FlowChangeEventHeaderTest { @IsTest private static void shouldBeAbleToCompare() { - FlowChangeEventHeader other = new FlowChangeEventHeader( - new EventBus.ChangeEventHeader() - ); + FlowChangeEventHeader other = new FlowChangeEventHeader(new EventBus.ChangeEventHeader()); other.changeType = 'CREATE'; System.Assert.areEqual( @@ -57,4 +52,4 @@ private with sharing class FlowChangeEventHeaderTest { 'Unable to detect difference between FlowChangeEventHeader and null' ); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/FormulaFilter.cls b/trigger-actions-framework/main/default/classes/FormulaFilter.cls index 842eda5..37dd400 100644 --- a/trigger-actions-framework/main/default/classes/FormulaFilter.cls +++ b/trigger-actions-framework/main/default/classes/FormulaFilter.cls @@ -23,8 +23,7 @@ global class FormulaFilter { private static final String ERROR_PREFIX = 'Please check the `SObject_Trigger_Setting__mdt` metadata for the the {0} sObject.'; @TestVisible private static final String MISSING_CLASS_NAME = - ERROR_PREFIX + - ' The record is missing the `TriggerRecord_Class_Name__c` field.'; + ERROR_PREFIX + ' The record is missing the `TriggerRecord_Class_Name__c` field.'; @TestVisible private static final String INVALID_CLASS = ERROR_PREFIX + @@ -74,18 +73,14 @@ global class FormulaFilter { List triggerOld ) { FormulaFilter.Result result = new FormulaFilter.Result(); - String entryCriteriaFormula = this.triggerActionConfiguration - ?.Entry_Criteria__c; + String entryCriteriaFormula = this.triggerActionConfiguration?.Entry_Criteria__c; if (String.isBlank(entryCriteriaFormula)) { result.triggerNew = triggerNew; result.triggerOld = triggerOld; return result; } - String nameOfType = getNameOfType( - this.triggerActionConfiguration, - this.context - ); + String nameOfType = getNameOfType(this.triggerActionConfiguration, this.context); System.Type triggerRecordSubType = getType(nameOfType); FormulaEval.FormulaInstance fx = getFormulaInstance( triggerRecordSubType, @@ -97,10 +92,7 @@ global class FormulaFilter { for (Integer i = 0; i < size; i++) { SObject record = triggerNew?.get(i); SObject recordPrior = triggerOld?.get(i); - TriggerRecord toProcess = getTriggerRecord( - triggerRecordSubType, - nameOfType - ); + TriggerRecord toProcess = getTriggerRecord(triggerRecordSubType, nameOfType); toProcess.newSobject = record; toProcess.oldSobject = recordPrior; if ((Boolean) fx.evaluate(toProcess)) { @@ -120,28 +112,19 @@ global class FormulaFilter { System.Type response = System.Type.forName(className); if (response == null) { throw new IllegalArgumentException( - String.format( - INVALID_CLASS, - new List{ this.sObjectName, className } - ) + String.format(INVALID_CLASS, new List{ this.sObjectName, className }) ); } return response; } - private TriggerRecord getTriggerRecord( - System.Type triggerRecordSubType, - String nameOfType - ) { + private TriggerRecord getTriggerRecord(System.Type triggerRecordSubType, String nameOfType) { TriggerRecord dynamicInstance; try { dynamicInstance = (TriggerRecord) triggerRecordSubType.newInstance(); } catch (System.TypeException e) { throw new IllegalArgumentException( - String.format( - INVALID_SUBTYPE, - new List{ this.sObjectName, nameOfType } - ) + String.format(INVALID_SUBTYPE, new List{ this.sObjectName, nameOfType }) ); } return dynamicInstance; @@ -204,4 +187,4 @@ global class FormulaFilter { this.triggerOld = new List(); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/FormulaFilterTest.cls b/trigger-actions-framework/main/default/classes/FormulaFilterTest.cls index 478d9be..6ed1d4d 100644 --- a/trigger-actions-framework/main/default/classes/FormulaFilterTest.cls +++ b/trigger-actions-framework/main/default/classes/FormulaFilterTest.cls @@ -13,9 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -@SuppressWarnings( - 'PMD.ApexUnitTestClassShouldHaveRunAs, PMD.AvoidGlobalModifier' -) +@SuppressWarnings('PMD.ApexUnitTestClassShouldHaveRunAs, PMD.AvoidGlobalModifier') @IsTest global class FormulaFilterTest { private static final String ACCOUNT_SOBJECT_NAME = 'Account'; @@ -45,21 +43,10 @@ global class FormulaFilterTest { ACCOUNT_SOBJECT_NAME ); - FormulaFilter.Result result = filter.filterByEntryCriteria( - triggerNew, - triggerOld - ); + FormulaFilter.Result result = filter.filterByEntryCriteria(triggerNew, triggerOld); - System.Assert.areEqual( - 2, - result.triggerNew.size(), - 'The size of triggerNew should be 2' - ); - System.Assert.areEqual( - 2, - result.triggerOld.size(), - 'The size of triggerOld should be 2' - ); + System.Assert.areEqual(2, result.triggerNew.size(), 'The size of triggerNew should be 2'); + System.Assert.areEqual(2, result.triggerOld.size(), 'The size of triggerOld should be 2'); } @IsTest @@ -72,21 +59,10 @@ global class FormulaFilterTest { ACCOUNT_SOBJECT_NAME ); - FormulaFilter.Result result = filter.filterByEntryCriteria( - triggerNew, - triggerOld - ); + FormulaFilter.Result result = filter.filterByEntryCriteria(triggerNew, triggerOld); - System.Assert.areEqual( - 2, - result.triggerNew.size(), - 'The size of triggerNew should be 2' - ); - System.Assert.areEqual( - 2, - result.triggerOld.size(), - 'The size of triggerNew should be 2' - ); + System.Assert.areEqual(2, result.triggerNew.size(), 'The size of triggerNew should be 2'); + System.Assert.areEqual(2, result.triggerOld.size(), 'The size of triggerNew should be 2'); } @IsTest @@ -98,26 +74,15 @@ global class FormulaFilterTest { ACCOUNT_SOBJECT_NAME ); - FormulaFilter.Result result = filter.filterByEntryCriteria( - triggerNew, - triggerOld - ); + FormulaFilter.Result result = filter.filterByEntryCriteria(triggerNew, triggerOld); - System.Assert.areEqual( - 1, - result.triggerNew.size(), - 'There should be 1 record in triggerNew' - ); + System.Assert.areEqual(1, result.triggerNew.size(), 'There should be 1 record in triggerNew'); System.Assert.areEqual( 'Test Account 1', ((Account) result.triggerNew[0]).Name, 'The first record triggerNew should have a name of Test Account 1' ); - System.Assert.areEqual( - 1, - result.triggerOld.size(), - 'There should be 1 record in triggerNew' - ); + System.Assert.areEqual(1, result.triggerOld.size(), 'There should be 1 record in triggerNew'); System.Assert.areEqual( 'Test Account 1', ((Account) result.triggerOld[0]).Name, @@ -134,20 +99,11 @@ global class FormulaFilterTest { ACCOUNT_SOBJECT_NAME ); - FormulaFilter.Result result = filter.filterByEntryCriteria( - triggerNew, - triggerOld - ); + FormulaFilter.Result result = filter.filterByEntryCriteria(triggerNew, triggerOld); System.Assert.isNotNull(result, 'result should not be null'); - System.Assert.isTrue( - result.triggerNew.isEmpty(), - 'triggerNew should be empty' - ); - System.Assert.isTrue( - result.triggerOld.isEmpty(), - 'triggerOld should be empty' - ); + System.Assert.isTrue(result.triggerNew.isEmpty(), 'triggerNew should be empty'); + System.Assert.isTrue(result.triggerOld.isEmpty(), 'triggerOld should be empty'); } @IsTest @@ -168,10 +124,7 @@ global class FormulaFilterTest { System.Assert.isNotNull(caught, EXCEPTION_SHOULD_BE_THROWN); System.Assert.areEqual( - String.format( - FormulaFilter.MISSING_CLASS_NAME, - new List{ ACCOUNT_SOBJECT_NAME } - ), + String.format(FormulaFilter.MISSING_CLASS_NAME, new List{ ACCOUNT_SOBJECT_NAME }), caught.getMessage(), 'The exception message should match the expected error' ); @@ -195,10 +148,7 @@ global class FormulaFilterTest { System.Assert.isNotNull(caught, EXCEPTION_SHOULD_BE_THROWN); System.Assert.areEqual( - String.format( - FormulaFilter.MISSING_CLASS_NAME, - new List{ ACCOUNT_SOBJECT_NAME } - ), + String.format(FormulaFilter.MISSING_CLASS_NAME, new List{ ACCOUNT_SOBJECT_NAME }), caught.getMessage(), 'The exception message should match the expected error' ); @@ -256,10 +206,7 @@ global class FormulaFilterTest { System.Assert.areEqual( String.format( FormulaFilter.INVALID_SUBTYPE, - new List{ - ACCOUNT_SOBJECT_NAME, - sobjectSetting.TriggerRecord_Class_Name__c - } + new List{ ACCOUNT_SOBJECT_NAME, sobjectSetting.TriggerRecord_Class_Name__c } ), caught.getMessage(), 'The exception message should match the expected error' @@ -285,10 +232,7 @@ global class FormulaFilterTest { System.Assert.areEqual( String.format( FormulaFilter.INVALID_CLASS, - new List{ - ACCOUNT_SOBJECT_NAME, - sobjectSetting.TriggerRecord_Class_Name__c - } + new List{ ACCOUNT_SOBJECT_NAME, sobjectSetting.TriggerRecord_Class_Name__c } ), caught.getMessage(), 'The exception message should match the expected error' @@ -368,4 +312,4 @@ global class FormulaFilterTest { } } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/MetadataTriggerHandler.cls b/trigger-actions-framework/main/default/classes/MetadataTriggerHandler.cls index a4fa549..04e4a34 100644 --- a/trigger-actions-framework/main/default/classes/MetadataTriggerHandler.cls +++ b/trigger-actions-framework/main/default/classes/MetadataTriggerHandler.cls @@ -235,10 +235,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem */ private void populatePermissionMap(String permissionName) { if (permissionName != null && !permissionMap.containsKey(permissionName)) { - permissionMap.put( - permissionName, - FeatureManagement.checkPermission(permissionName) - ); + permissionMap.put(permissionName, FeatureManagement.checkPermission(permissionName)); } } @@ -250,15 +247,9 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem */ private list getActionMetadata(String relationshipName) { if (!sObjectToContextToActions.containsKey(this.sObjectName)) { - sObjectToContextToActions.put( - this.sObjectName, - new Map>() - ); + sObjectToContextToActions.put(this.sObjectName, new Map>()); } - if ( - !sObjectToContextToActions.get(this.sObjectName) - .containsKey(relationshipName) - ) { + if (!sObjectToContextToActions.get(this.sObjectName).containsKey(relationshipName)) { list result = new List(); String sObjectLocalName = this.sObjectName; List split = sObjectName.split(DOUBLE_UNDERSCORE); @@ -279,20 +270,16 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem } ); for ( - Trigger_Action__mdt actionMetadata : (List) selector.query( - queryString - ) + Trigger_Action__mdt actionMetadata : (List) selector.query(queryString) ) { if (shouldExecute(actionMetadata, relationshipName)) { result.add(actionMetadata); } } - sObjectToContextToActions.get(this.sObjectName) - .put(relationshipName, result); + sObjectToContextToActions.get(this.sObjectName).put(relationshipName, result); } - return sObjectToContextToActions.get(this.sObjectName) - .get(relationshipName); + return sObjectToContextToActions.get(this.sObjectName).get(relationshipName); } /** @@ -302,10 +289,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem * @param relationshipName The name of the relationship. * @return True if the Trigger Action should be executed, false otherwise. */ - private Boolean shouldExecute( - Trigger_Action__mdt actionMetadata, - String relationshipName - ) { + private Boolean shouldExecute(Trigger_Action__mdt actionMetadata, String relationshipName) { String sObjectBypassPermissionName = (String) ((sObject_Trigger_Setting__mdt) actionMetadata.getSobject( relationshipName + RELATIONSHIP_SUFFIX )) @@ -328,8 +312,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem return !isBypassed( actionMetadata.Bypass_Permission__c, actionMetadata.Required_Permission__c - ) && - !isBypassed(sObjectBypassPermissionName, sObjectRequiredPermissionName); + ) && !isBypassed(sObjectBypassPermissionName, sObjectRequiredPermissionName); } /** @@ -339,10 +322,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem * @param requiredPermission The required permission for the Trigger Action. * @return True if bypassed, false otherwise. */ - private static boolean isBypassed( - String bypassPermission, - String requiredPermission - ) { + private static boolean isBypassed(String bypassPermission, String requiredPermission) { return (bypassPermission != null && permissionMap.get(bypassPermission)) || (requiredPermission != null && !permissionMap.get(requiredPermission)); } @@ -364,16 +344,8 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem if (!canExecute(triggerMetadata)) { continue; } - this.validateType( - context, - triggerAction, - triggerMetadata.Apex_Class_Name__c - ); - FormulaFilter.Result filtered = new FormulaFilter( - triggerMetadata, - context, - this.sObjectName - ) + this.validateType(context, triggerAction, triggerMetadata.Apex_Class_Name__c); + FormulaFilter.Result filtered = new FormulaFilter(triggerMetadata, context, this.sObjectName) .filterByEntryCriteria(triggerNew, triggerOld); if ( @@ -387,12 +359,10 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem switch on context { when BEFORE_INSERT { - ((TriggerAction.BeforeInsert) triggerAction) - .beforeInsert(filtered.triggerNew); + ((TriggerAction.BeforeInsert) triggerAction).beforeInsert(filtered.triggerNew); } when AFTER_INSERT { - ((TriggerAction.AfterInsert) triggerAction) - .afterInsert(filtered.triggerNew); + ((TriggerAction.AfterInsert) triggerAction).afterInsert(filtered.triggerNew); } when BEFORE_UPDATE { ((TriggerAction.BeforeUpdate) triggerAction) @@ -403,16 +373,13 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem .afterUpdate(filtered.triggerNew, filtered.triggerOld); } when BEFORE_DELETE { - ((TriggerAction.BeforeDelete) triggerAction) - .beforeDelete(filtered.triggerOld); + ((TriggerAction.BeforeDelete) triggerAction).beforeDelete(filtered.triggerOld); } when AFTER_DELETE { - ((TriggerAction.AfterDelete) triggerAction) - .afterDelete(filtered.triggerOld); + ((TriggerAction.AfterDelete) triggerAction).afterDelete(filtered.triggerOld); } when AFTER_UNDELETE { - ((TriggerAction.AfterUndelete) triggerAction) - .afterUndelete(filtered.triggerNew); + ((TriggerAction.AfterUndelete) triggerAction).afterUndelete(filtered.triggerNew); } } } @@ -425,9 +392,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem * @param context The TriggerOperation context for which to retrieve metadata. * @return A List of Trigger_Action__mdt metadata records corresponding to the given context. */ - private List getActionMetadata( - TriggerOperation context - ) { + private List getActionMetadata(TriggerOperation context) { List result; switch on context { when BEFORE_INSERT { @@ -474,15 +439,10 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem result = Type.forName(triggerMetadata.Apex_Class_Name__c).newInstance(); if (triggerMetadata.Flow_Name__c != null) { ((TriggerActionFlow) result).flowName = triggerMetadata.Flow_Name__c; - ((TriggerActionFlow) result) - .allowRecursion = triggerMetadata.Allow_Flow_Recursion__c; + ((TriggerActionFlow) result).allowRecursion = triggerMetadata.Allow_Flow_Recursion__c; } } catch (System.NullPointerException e) { - handleException( - INVALID_CLASS_ERROR, - triggerMetadata.Apex_Class_Name__c, - context - ); + handleException(INVALID_CLASS_ERROR, triggerMetadata.Apex_Class_Name__c, context); } return result; } @@ -496,9 +456,8 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem * @return True if the trigger action can be executed, false otherwise. */ private Boolean canExecute(Trigger_Action__mdt triggerMetadata) { - return !MetadataTriggerHandler.isBypassed( - triggerMetadata.Apex_Class_Name__c - ) && !TriggerBase.isBypassed(this.sObjectName); + return !MetadataTriggerHandler.isBypassed(triggerMetadata.Apex_Class_Name__c) && + !TriggerBase.isBypassed(this.sObjectName); } /** @@ -508,11 +467,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem * @param triggerAction The Trigger Action object. * @param className The name of the Trigger Action class. */ - private void validateType( - TriggerOperation context, - Object triggerAction, - String className - ) { + private void validateType(TriggerOperation context, Object triggerAction, String className) { try { switch on context { when BEFORE_INSERT { @@ -549,19 +504,11 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem * @param className The name of the Trigger Action class. * @param triggerOperation The Trigger Operation context. */ - private void handleException( - String error, - String className, - TriggerOperation triggerOperation - ) { + private void handleException(String error, String className, TriggerOperation triggerOperation) { throw new MetadataTriggerHandlerException( String.format( error, - new List{ - className, - String.valueOf(triggerOperation), - this.sObjectName - } + new List{ className, String.valueOf(triggerOperation), this.sObjectName } ) ); } @@ -575,9 +522,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem private List beforeInsertActionMetadata { get { if (beforeInsertActionMetadata == null) { - beforeInsertActionMetadata = getActionMetadata( - TriggerOperation.BEFORE_INSERT.name() - ); + beforeInsertActionMetadata = getActionMetadata(TriggerOperation.BEFORE_INSERT.name()); } return beforeInsertActionMetadata; } @@ -593,9 +538,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem private List afterInsertActionMetadata { get { if (afterInsertActionMetadata == null) { - afterInsertActionMetadata = getActionMetadata( - TriggerOperation.AFTER_INSERT.name() - ); + afterInsertActionMetadata = getActionMetadata(TriggerOperation.AFTER_INSERT.name()); } return afterInsertActionMetadata; } @@ -611,9 +554,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem private List beforeUpdateActionMetadata { get { if (beforeUpdateActionMetadata == null) { - beforeUpdateActionMetadata = getActionMetadata( - TriggerOperation.BEFORE_UPDATE.name() - ); + beforeUpdateActionMetadata = getActionMetadata(TriggerOperation.BEFORE_UPDATE.name()); } return beforeUpdateActionMetadata; } @@ -629,9 +570,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem private List afterUpdateActionMetadata { get { if (afterUpdateActionMetadata == null) { - afterUpdateActionMetadata = getActionMetadata( - TriggerOperation.AFTER_UPDATE.name() - ); + afterUpdateActionMetadata = getActionMetadata(TriggerOperation.AFTER_UPDATE.name()); } return afterUpdateActionMetadata; } @@ -647,9 +586,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem private List beforeDeleteActionMetadata { get { if (beforeDeleteActionMetadata == null) { - beforeDeleteActionMetadata = getActionMetadata( - TriggerOperation.BEFORE_DELETE.name() - ); + beforeDeleteActionMetadata = getActionMetadata(TriggerOperation.BEFORE_DELETE.name()); } return beforeDeleteActionMetadata; } @@ -665,9 +602,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem private List afterDeleteActionMetadata { get { if (afterDeleteActionMetadata == null) { - afterDeleteActionMetadata = getActionMetadata( - TriggerOperation.AFTER_DELETE.name() - ); + afterDeleteActionMetadata = getActionMetadata(TriggerOperation.AFTER_DELETE.name()); } return afterDeleteActionMetadata; } @@ -683,9 +618,7 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem private List afterUndeleteActionMetadata { get { if (afterUndeleteActionMetadata == null) { - afterUndeleteActionMetadata = getActionMetadata( - TriggerOperation.AFTER_UNDELETE.name() - ); + afterUndeleteActionMetadata = getActionMetadata(TriggerOperation.AFTER_UNDELETE.name()); } return afterUndeleteActionMetadata; } @@ -710,4 +643,4 @@ public inherited sharing class MetadataTriggerHandler extends TriggerBase implem */ private class MetadataTriggerHandlerException extends Exception { } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/MetadataTriggerHandlerTest.cls b/trigger-actions-framework/main/default/classes/MetadataTriggerHandlerTest.cls index 20e394b..4110f09 100644 --- a/trigger-actions-framework/main/default/classes/MetadataTriggerHandlerTest.cls +++ b/trigger-actions-framework/main/default/classes/MetadataTriggerHandlerTest.cls @@ -14,9 +14,7 @@ limitations under the License. */ -@SuppressWarnings( - 'PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ApexUnitTestClassShouldHaveRunAs' -) +@SuppressWarnings('PMD.ApexDoc, PMD.CyclomaticComplexity, PMD.ApexUnitTestClassShouldHaveRunAs') @IsTest(isParallel=true) private class MetadataTriggerHandlerTest { private static final String ACCOUNT = 'Account'; @@ -51,9 +49,7 @@ private class MetadataTriggerHandlerTest { ); private static sObject_Trigger_Setting__mdt setting = new sObject_Trigger_Setting__mdt( Object_API_Name__c = ACCOUNT, - Id = TriggerTestUtility.getFakeId( - Schema.sObject_Trigger_Setting__mdt.SObjectType - ) + Id = TriggerTestUtility.getFakeId(Schema.sObject_Trigger_Setting__mdt.SObjectType) ); private static MetadataTriggerHandler handler = new MetadataTriggerHandler(); private static Boolean executed = false; @@ -73,9 +69,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeInsertShouldSucceed() { - handler.beforeInsertActionMetadata = new List{ - action - }; + handler.beforeInsertActionMetadata = new List{ action }; handler.beforeInsert(handler.triggerNew); @@ -85,9 +79,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeInsertShouldFailWithIncorrectType() { action.Apex_Class_Name__c = TEST_AFTER_INSERT; - handler.beforeInsertActionMetadata = new List{ - action - }; + handler.beforeInsertActionMetadata = new List{ action }; try { handler.beforeInsert(handler.triggerNew); @@ -113,9 +105,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeInsertShouldFailWithIncorrectClass() { action.Apex_Class_Name__c = BOGUS_CLASS_NAME; - handler.beforeInsertActionMetadata = new List{ - action - }; + handler.beforeInsertActionMetadata = new List{ action }; try { handler.beforeInsert(handler.triggerNew); @@ -203,9 +193,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeUpdateShouldSucceed() { action.Apex_Class_Name__c = TEST_BEFORE_UPDATE; - handler.beforeUpdateActionMetadata = new List{ - action - }; + handler.beforeUpdateActionMetadata = new List{ action }; handler.beforeUpdate(handler.triggerNew, handler.triggerOld); @@ -215,9 +203,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeUpdateShouldFailWithIncorrectType() { action.Apex_Class_Name__c = TEST_BEFORE_INSERT; - handler.beforeUpdateActionMetadata = new List{ - action - }; + handler.beforeUpdateActionMetadata = new List{ action }; try { handler.beforeUpdate(handler.triggerNew, handler.triggerOld); @@ -243,9 +229,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeUpdateShouldFailWithIncorrectClass() { action.Apex_Class_Name__c = BOGUS_CLASS_NAME; - handler.beforeUpdateActionMetadata = new List{ - action - }; + handler.beforeUpdateActionMetadata = new List{ action }; try { handler.beforeUpdate(handler.triggerNew, handler.triggerOld); @@ -333,9 +317,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeDeleteShouldSucceed() { action.Apex_Class_Name__c = TEST_BEFORE_DELETE; - handler.beforeDeleteActionMetadata = new List{ - action - }; + handler.beforeDeleteActionMetadata = new List{ action }; handler.beforeDelete(handler.triggerOld); @@ -345,9 +327,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeDeleteShouldFailWithIncorrectType() { action.Apex_Class_Name__c = TEST_BEFORE_INSERT; - handler.beforeDeleteActionMetadata = new List{ - action - }; + handler.beforeDeleteActionMetadata = new List{ action }; try { handler.beforeDelete(handler.triggerOld); @@ -373,9 +353,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void beforeDeleteShouldFailWithIncorrectClass() { action.Apex_Class_Name__c = BOGUS_CLASS_NAME; - handler.beforeDeleteActionMetadata = new List{ - action - }; + handler.beforeDeleteActionMetadata = new List{ action }; try { handler.beforeDelete(handler.triggerOld); @@ -463,9 +441,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void afterUndeleteShouldSucceed() { action.Apex_Class_Name__c = TEST_AFTER_UNDELETE; - handler.afterUndeleteActionMetadata = new List{ - action - }; + handler.afterUndeleteActionMetadata = new List{ action }; handler.afterUndelete(handler.triggerOld); @@ -475,9 +451,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void afterUndeleteShouldFailWithIncorrectType() { action.Apex_Class_Name__c = TEST_BEFORE_INSERT; - handler.afterUndeleteActionMetadata = new List{ - action - }; + handler.afterUndeleteActionMetadata = new List{ action }; try { handler.afterUndelete(handler.triggerOld); @@ -503,9 +477,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void afterUndeleteShouldFailWithIncorrectClass() { action.Apex_Class_Name__c = BOGUS_CLASS_NAME; - handler.afterUndeleteActionMetadata = new List{ - action - }; + handler.afterUndeleteActionMetadata = new List{ action }; try { handler.afterUndelete(handler.triggerOld); @@ -530,9 +502,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void nothingToProcessShouldExitEarly() { - handler.beforeInsertActionMetadata = new List{ - action - }; + handler.beforeInsertActionMetadata = new List{ action }; handler.beforeInsert(new List()); @@ -633,9 +603,7 @@ private class MetadataTriggerHandlerTest { @IsTest private static void actionShouldExecuteIfNoRequiredOrBypassPermissionsAreDefinedForSObjectOrAction() { - MetadataTriggerHandler.selector = new FakeSelector( - new List{ action } - ); + MetadataTriggerHandler.selector = new FakeSelector(new List{ action }); MetadataTriggerHandler.permissionMap.clear(); @@ -648,9 +616,7 @@ private class MetadataTriggerHandlerTest { private static void actionShouldExecuteIfUserDoesNotHaveBypassPermissionForSObjectOrAction() { setting.Bypass_Permission__c = BYPASS_PERMISSION; action.Bypass_Permission__c = BYPASS_PERMISSION; - MetadataTriggerHandler.selector = new FakeSelector( - new List{ action } - ); + MetadataTriggerHandler.selector = new FakeSelector(new List{ action }); MetadataTriggerHandler.permissionMap.clear(); @@ -662,12 +628,8 @@ private class MetadataTriggerHandlerTest { @IsTest private static void actionShouldNotExecuteIfUserDoesNotHaveRequiredPermissionForSObject() { setting.Required_Permission__c = REQUIRED_PERMISSION; - MetadataTriggerHandler.selector = new FakeSelector( - new List{ action } - ); - MetadataTriggerHandler.permissionMap = new Map{ - REQUIRED_PERMISSION => false - }; + MetadataTriggerHandler.selector = new FakeSelector(new List{ action }); + MetadataTriggerHandler.permissionMap = new Map{ REQUIRED_PERMISSION => false }; handler.beforeInsert(handler.triggerNew); @@ -677,12 +639,8 @@ private class MetadataTriggerHandlerTest { @IsTest private static void actionShouldNotExecuteIfUserDoesNotHaveRequiredPermissionForAction() { action.Required_Permission__c = REQUIRED_PERMISSION; - MetadataTriggerHandler.selector = new FakeSelector( - new List{ action } - ); - MetadataTriggerHandler.permissionMap = new Map{ - REQUIRED_PERMISSION => false - }; + MetadataTriggerHandler.selector = new FakeSelector(new List{ action }); + MetadataTriggerHandler.permissionMap = new Map{ REQUIRED_PERMISSION => false }; handler.beforeInsert(handler.triggerNew); @@ -692,12 +650,8 @@ private class MetadataTriggerHandlerTest { @IsTest private static void actionShouldNotExecuteIfUserHasBypassPermissionForSObject() { setting.Bypass_Permission__c = BYPASS_PERMISSION; - MetadataTriggerHandler.selector = new FakeSelector( - new List{ action } - ); - MetadataTriggerHandler.permissionMap = new Map{ - BYPASS_PERMISSION => true - }; + MetadataTriggerHandler.selector = new FakeSelector(new List{ action }); + MetadataTriggerHandler.permissionMap = new Map{ BYPASS_PERMISSION => true }; handler.beforeInsert(handler.triggerNew); @@ -707,12 +661,8 @@ private class MetadataTriggerHandlerTest { @IsTest private static void actionShouldNotExecuteIfUserHasBypassPermissionForAction() { action.Bypass_Permission__c = BYPASS_PERMISSION; - MetadataTriggerHandler.selector = new FakeSelector( - new List{ action } - ); - MetadataTriggerHandler.permissionMap = new Map{ - BYPASS_PERMISSION => true - }; + MetadataTriggerHandler.selector = new FakeSelector(new List{ action }); + MetadataTriggerHandler.permissionMap = new Map{ BYPASS_PERMISSION => true }; handler.beforeInsert(handler.triggerNew); @@ -735,9 +685,7 @@ private class MetadataTriggerHandlerTest { action.Allow_Flow_Recursion__c = false; MetadataTriggerHandler.bypass(TriggerActionFlow.class.getName()); - handler.beforeInsertActionMetadata = new List{ - action - }; + handler.beforeInsertActionMetadata = new List{ action }; try { handler.beforeInsert(handler.triggerNew); @@ -759,18 +707,12 @@ private class MetadataTriggerHandlerTest { } } public class TestBeforeUpdate implements TriggerAction.BeforeUpdate { - public void beforeUpdate( - List triggerNew, - List triggerOld - ) { + public void beforeUpdate(List triggerNew, List triggerOld) { MetadataTriggerHandlerTest.executed = true; } } public class TestAfterUpdate implements TriggerAction.AfterUpdate { - public void afterUpdate( - List triggerNew, - List triggerOld - ) { + public void afterUpdate(List triggerNew, List triggerOld) { MetadataTriggerHandlerTest.executed = true; } } @@ -804,4 +746,4 @@ private class MetadataTriggerHandlerTest { return this.results; } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerAction.cls b/trigger-actions-framework/main/default/classes/TriggerAction.cls index 59f2fea..9144621 100644 --- a/trigger-actions-framework/main/default/classes/TriggerAction.cls +++ b/trigger-actions-framework/main/default/classes/TriggerAction.cls @@ -132,4 +132,4 @@ public class TriggerAction { */ void execute(FinalizerHandler.Context context); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionConstants.cls b/trigger-actions-framework/main/default/classes/TriggerActionConstants.cls index accf2a9..eec95aa 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionConstants.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionConstants.cls @@ -31,4 +31,4 @@ public class TriggerActionConstants { TriggerActionConstants.FLOW_STRING, TriggerActionConstants.OBJECT_STRING }; -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlow.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlow.cls index f4fdfce..1818091 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlow.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlow.cls @@ -104,9 +104,7 @@ public virtual inherited sharing class TriggerActionFlow implements TriggerActio return; } handleInvocableResults( - invokeAction( - getInterviewInputs(triggerNew, TriggerActionConstants.RECORD_VARIABLE) - ), + invokeAction(getInterviewInputs(triggerNew, TriggerActionConstants.RECORD_VARIABLE)), triggerNew ); } @@ -158,8 +156,7 @@ public virtual inherited sharing class TriggerActionFlow implements TriggerActio for (Integer i = 0; i < triggerNew.size(); i++) { sObject record = triggerNew[i]; if ( - TriggerBase.idToNumberOfTimesSeenAfterUpdate.get(record.id) == 1 || - (allowRecursion == true) + TriggerBase.idToNumberOfTimesSeenAfterUpdate.get(record.id) == 1 || (allowRecursion == true) ) { recordsNotYetProcessed.add(record); oldRecordsNotYetProcessed.add(triggerOld[i]); @@ -169,9 +166,7 @@ public virtual inherited sharing class TriggerActionFlow implements TriggerActio return; } handleInvocableResults( - invokeAction( - getInterviewInputs(recordsNotYetProcessed, oldRecordsNotYetProcessed) - ), + invokeAction(getInterviewInputs(recordsNotYetProcessed, oldRecordsNotYetProcessed)), recordsNotYetProcessed ); } @@ -186,12 +181,7 @@ public virtual inherited sharing class TriggerActionFlow implements TriggerActio return; } handleInvocableResults( - invokeAction( - getInterviewInputs( - triggerOld, - TriggerActionConstants.RECORD_PRIOR_VARIABLE - ) - ), + invokeAction(getInterviewInputs(triggerOld, TriggerActionConstants.RECORD_PRIOR_VARIABLE)), triggerOld ); } @@ -206,12 +196,7 @@ public virtual inherited sharing class TriggerActionFlow implements TriggerActio return; } handleInvocableResults( - invokeAction( - getInterviewInputs( - triggerOld, - TriggerActionConstants.RECORD_PRIOR_VARIABLE - ) - ), + invokeAction(getInterviewInputs(triggerOld, TriggerActionConstants.RECORD_PRIOR_VARIABLE)), triggerOld ); } @@ -226,40 +211,27 @@ public virtual inherited sharing class TriggerActionFlow implements TriggerActio return; } handleInvocableResults( - invokeAction( - getInterviewInputs(triggerNew, TriggerActionConstants.RECORD_VARIABLE) - ), + invokeAction(getInterviewInputs(triggerNew, TriggerActionConstants.RECORD_VARIABLE)), triggerNew ); } private Boolean flowIsBypassed() { if (String.isBlank(flowName)) { - throw new IllegalArgumentException( - TriggerActionConstants.INVALID_FLOW_NAME - ); + throw new IllegalArgumentException(TriggerActionConstants.INVALID_FLOW_NAME); } return TriggerActionFlow.isBypassed(flowName); } - private List invokeAction( - List> inputs - ) { + private List invokeAction(List> inputs) { return invocableAction.invokeAction(this.flowName, inputs); } - private void applyFlowValues( - sObject stateBeforeFlow, - sObject stateAfterFlow - ) { + private void applyFlowValues(sObject stateBeforeFlow, sObject stateAfterFlow) { Boolean hasBeenMutated = false; Set recordPopulatedFields = new Set(); - recordPopulatedFields.addAll( - stateAfterFlow.getPopulatedFieldsAsMap().keySet() - ); - recordPopulatedFields.addAll( - stateBeforeFlow.getPopulatedFieldsAsMap().keySet() - ); + recordPopulatedFields.addAll(stateAfterFlow.getPopulatedFieldsAsMap().keySet()); + recordPopulatedFields.addAll(stateBeforeFlow.getPopulatedFieldsAsMap().keySet()); for (String fieldName : recordPopulatedFields) { if (stateBeforeFlow.get(fieldName) != stateAfterFlow.get(fieldName)) { stateBeforeFlow.put(fieldName, stateAfterFlow.get(fieldName)); @@ -380,4 +352,4 @@ public virtual inherited sharing class TriggerActionFlow implements TriggerActio return action.invoke(); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowAddError.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowAddError.cls index 824e100..ffa9674 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowAddError.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowAddError.cls @@ -55,22 +55,11 @@ public inherited sharing class TriggerActionFlowAddError { * @description This class represents a request to add an error to an sObject. */ public class Request { - @InvocableVariable( - label='Record' - description='Record to add the error to' - required=true - ) + @InvocableVariable(label='Record' description='Record to add the error to' required=true) public SObject record; - @InvocableVariable( - label='Field Name' - description='API name of corresponding field' - ) + @InvocableVariable(label='Field Name' description='API name of corresponding field') public String fieldName; - @InvocableVariable( - label='Error Message' - description='Error Message' - required=true - ) + @InvocableVariable(label='Error Message' description='Error Message' required=true) public String errorMessage; } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowAddErrorTest.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowAddErrorTest.cls index 870a4f7..2d5938a 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowAddErrorTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowAddErrorTest.cls @@ -31,15 +31,8 @@ private class TriggerActionFlowAddErrorTest { TriggerActionFlowAddError.addError(requests); - System.Assert.isTrue( - account.hasErrors(), - 'The Account should have an error' - ); - System.Assert.areEqual( - 1, - account.getErrors().size(), - 'There should only be one error' - ); + System.Assert.isTrue(account.hasErrors(), 'The Account should have an error'); + System.Assert.areEqual(1, account.getErrors().size(), 'There should only be one error'); System.Assert.areEqual( MY_STRING, account.getErrors()[0].getMessage(), @@ -57,19 +50,12 @@ private class TriggerActionFlowAddErrorTest { TriggerActionFlowAddError.addError(requests); - System.Assert.isTrue( - account.hasErrors(), - 'The Account should have an error' - ); - System.Assert.areEqual( - 1, - account.getErrors().size(), - 'There should only be one error' - ); + System.Assert.isTrue(account.hasErrors(), 'The Account should have an error'); + System.Assert.areEqual(1, account.getErrors().size(), 'There should only be one error'); System.Assert.areEqual( MY_STRING, account.getErrors()[0].getMessage(), 'The error should contain the message we are looking for' ); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowBypass.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowBypass.cls index 239deed..ed1d30c 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowBypass.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowBypass.cls @@ -54,11 +54,7 @@ public inherited sharing class TriggerActionFlowBypass { required=true ) public String name; - @InvocableVariable( - label='Bypass Type' - description='Apex, Flow, or Object' - required=true - ) + @InvocableVariable(label='Bypass Type' description='Apex, Flow, or Object' required=true) public String bypassType; } @@ -75,4 +71,4 @@ public inherited sharing class TriggerActionFlowBypass { TriggerBase.bypass(name); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassProcessor.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassProcessor.cls index 0c94720..7230976 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassProcessor.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassProcessor.cls @@ -46,4 +46,4 @@ public inherited sharing abstract class TriggerActionFlowBypassProcessor { protected abstract void processApexBypasses(String requestType); protected abstract void processFlowBypasses(String requestType); protected abstract void processObjectBypasses(String requestType); -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassTest.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassTest.cls index 2a7f250..89fa148 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowBypassTest.cls @@ -30,10 +30,7 @@ private class TriggerActionFlowBypassTest { TriggerActionFlowBypass.bypass(requests); - System.Assert.isTrue( - TriggerBase.isBypassed(MY_STRING), - 'The Object should be bypassed' - ); + System.Assert.isTrue(TriggerBase.isBypassed(MY_STRING), 'The Object should be bypassed'); } @IsTest @@ -58,10 +55,7 @@ private class TriggerActionFlowBypassTest { TriggerActionFlowBypass.bypass(requests); - System.Assert.isTrue( - TriggerActionFlow.isBypassed(MY_STRING), - 'The Flow should be bypassed' - ); + System.Assert.isTrue(TriggerActionFlow.isBypassed(MY_STRING), 'The Flow should be bypassed'); } @IsTest @@ -92,4 +86,4 @@ private class TriggerActionFlowBypassTest { 'The exeption should contain the message we are looking for' ); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEvent.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEvent.cls index 45efc9b..2869b6e 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEvent.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEvent.cls @@ -66,4 +66,4 @@ public with sharing class TriggerActionFlowChangeEvent extends TriggerActionFlow throw new IllegalArgumentException(NOT_CHANGE_EVENT_ERROR); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEventTest.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEventTest.cls index 4c3068a..b8c5de8 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEventTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowChangeEventTest.cls @@ -95,4 +95,4 @@ private with sharing class TriggerActionFlowChangeEventTest { 'The value for "header" is constructed improperly' ); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypasses.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypasses.cls index a4aa158..64fe2bf 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypasses.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypasses.cls @@ -60,4 +60,4 @@ public inherited sharing class TriggerActionFlowClearAllBypasses { TriggerBase.clearAllBypasses(); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypassesTest.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypassesTest.cls index 503ff66..76300d9 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypassesTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearAllBypassesTest.cls @@ -27,10 +27,7 @@ private class TriggerActionFlowClearAllBypassesTest { new List{ TriggerActionConstants.OBJECT_STRING } ); - System.Assert.isFalse( - TriggerBase.isBypassed(MY_STRING), - 'The Object should not be bypassed' - ); + System.Assert.isFalse(TriggerBase.isBypassed(MY_STRING), 'The Object should not be bypassed'); } @IsTest @@ -66,9 +63,7 @@ private class TriggerActionFlowClearAllBypassesTest { Exception myException; try { - TriggerActionFlowClearAllBypasses.clearAllBypasses( - new List{ MY_STRING } - ); + TriggerActionFlowClearAllBypasses.clearAllBypasses(new List{ MY_STRING }); } catch (Exception e) { myException = e; } @@ -89,4 +84,4 @@ private class TriggerActionFlowClearAllBypassesTest { 'The exeption should contain the message we are looking for' ); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypass.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypass.cls index 6c9dd81..14aae99 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypass.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypass.cls @@ -62,11 +62,7 @@ public inherited sharing class TriggerActionFlowClearBypass { required=true ) public String name; - @InvocableVariable( - label='Bypass Type' - description='Apex, Flow, or Object' - required=true - ) + @InvocableVariable(label='Bypass Type' description='Apex, Flow, or Object' required=true) public String bypassType; } @@ -91,4 +87,4 @@ public inherited sharing class TriggerActionFlowClearBypass { TriggerBase.clearBypass(name); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypassTest.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypassTest.cls index aec67e1..1894cfa 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypassTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowClearBypassTest.cls @@ -31,10 +31,7 @@ private class TriggerActionFlowClearBypassTest { TriggerActionFlowClearBypass.clearBypass(requests); - System.Assert.isFalse( - TriggerBase.isBypassed(MY_STRING), - 'The Object should not be bypassed' - ); + System.Assert.isFalse(TriggerBase.isBypassed(MY_STRING), 'The Object should not be bypassed'); } @IsTest @@ -95,4 +92,4 @@ private class TriggerActionFlowClearBypassTest { 'The exeption should contain the message we are looking for' ); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassed.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassed.cls index 1b90586..3d20019 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassed.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassed.cls @@ -95,4 +95,4 @@ public inherited sharing class TriggerActionFlowIsBypassed { this.hasBeenBypassed = TriggerBase.isBypassed(name); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassedTest.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassedTest.cls index 8a0bd6d..73aedde 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassedTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowIsBypassedTest.cls @@ -30,11 +30,7 @@ private class TriggerActionFlowIsBypassedTest { List isBypassed = TriggerActionFlowIsBypassed.isBypassed(requests); - System.Assert.areEqual( - 1, - isBypassed.size(), - 'We should only have one result for our request' - ); + System.Assert.areEqual(1, isBypassed.size(), 'We should only have one result for our request'); System.Assert.areEqual( TriggerBase.isBypassed(MY_STRING), isBypassed[0], @@ -50,11 +46,7 @@ private class TriggerActionFlowIsBypassedTest { List isBypassed = TriggerActionFlowIsBypassed.isBypassed(requests); - System.Assert.areEqual( - 1, - isBypassed.size(), - 'We should only have one result for our request' - ); + System.Assert.areEqual(1, isBypassed.size(), 'We should only have one result for our request'); System.Assert.areEqual( MetadataTriggerHandler.isBypassed(MY_STRING), isBypassed[0], @@ -70,11 +62,7 @@ private class TriggerActionFlowIsBypassedTest { List isBypassed = TriggerActionFlowIsBypassed.isBypassed(requests); - System.Assert.areEqual( - 1, - isBypassed.size(), - 'We should only have one result for our request' - ); + System.Assert.areEqual(1, isBypassed.size(), 'We should only have one result for our request'); System.Assert.areEqual( TriggerActionFlow.isBypassed(MY_STRING), isBypassed[0], @@ -111,4 +99,4 @@ private class TriggerActionFlowIsBypassedTest { 'The exeption should contain the message we are looking for' ); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerActionFlowTest.cls b/trigger-actions-framework/main/default/classes/TriggerActionFlowTest.cls index b9d9a0f..707b4c0 100644 --- a/trigger-actions-framework/main/default/classes/TriggerActionFlowTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerActionFlowTest.cls @@ -39,10 +39,7 @@ private class TriggerActionFlowTest { Name = MY_ACCOUNT, Id = TriggerTestUtility.getFakeId(Schema.Account.SObjectType) ); - private static Account oldAccount = new Account( - Name = OLD_NAME, - Id = myAccount.Id - ); + private static Account oldAccount = new Account(Name = OLD_NAME, Id = myAccount.Id); private static Account myAccountAfterFlow = myAccount.clone(true); private static List triggerNew = new List{ myAccount }; private static List triggerOld = new List{ oldAccount }; @@ -52,9 +49,7 @@ private class TriggerActionFlowTest { private static Invocable.Action.Result successResult = new InvocableActionResultBuilder() .setSuccess(true) .setOutputParameters( - new Map{ - TriggerActionConstants.RECORD_VARIABLE => myAccountAfterFlow - } + new Map{ TriggerActionConstants.RECORD_VARIABLE => myAccountAfterFlow } ) .build(); @@ -135,22 +130,14 @@ private class TriggerActionFlowTest { System.Assert.areEqual(FOO, myAccount.Name, NAME_SET_FROM_FLOW); System.Assert.areEqual(true, myAccount.hasErrors(), ERROR_SHOULD_BE_ADDED); System.Assert.areEqual(1, myAccount.getErrors().size(), ONE_ERROR); - System.Assert.areEqual( - TEST, - myAccount.getErrors()[0].getMessage(), - ERROR_MESSAGE_SHOULD_MATCH - ); + System.Assert.areEqual(TEST, myAccount.getErrors()[0].getMessage(), ERROR_MESSAGE_SHOULD_MATCH); } @IsTest private static void afterInsertShouldSucceed() { actionFlow.afterInsert(triggerNew); - System.Assert.areEqual( - false, - myAccount.hasErrors(), - ERROR_SHOULD_NOT_BE_ADDED - ); + System.Assert.areEqual(false, myAccount.hasErrors(), ERROR_SHOULD_NOT_BE_ADDED); } @IsTest @@ -160,11 +147,7 @@ private class TriggerActionFlowTest { System.Assert.areEqual(FOO, myAccount.Name, NAME_SET_FROM_FLOW); System.Assert.areEqual(true, myAccount.hasErrors(), ERROR_SHOULD_BE_ADDED); System.Assert.areEqual(1, myAccount.getErrors().size(), ONE_ERROR); - System.Assert.areEqual( - TEST, - myAccount.getErrors()[0].getMessage(), - ERROR_MESSAGE_SHOULD_MATCH - ); + System.Assert.areEqual(TEST, myAccount.getErrors()[0].getMessage(), ERROR_MESSAGE_SHOULD_MATCH); } @IsTest @@ -181,11 +164,7 @@ private class TriggerActionFlowTest { private static void afterUpdateShouldSucceed() { actionFlow.afterUpdate(triggerNew, triggerOld); - System.Assert.areEqual( - false, - myAccount.hasErrors(), - ERROR_SHOULD_NOT_BE_ADDED - ); + System.Assert.areEqual(false, myAccount.hasErrors(), ERROR_SHOULD_NOT_BE_ADDED); } @IsTest @@ -195,44 +174,28 @@ private class TriggerActionFlowTest { actionFlow.afterUpdate(triggerNew, triggerOld); - System.Assert.areEqual( - false, - myAccount.hasErrors(), - ERROR_SHOULD_NOT_BE_ADDED - ); + System.Assert.areEqual(false, myAccount.hasErrors(), ERROR_SHOULD_NOT_BE_ADDED); } @IsTest private static void beforeDeleteShouldSucceed() { actionFlow.beforeDelete(triggerOld); - System.Assert.areEqual( - false, - oldAccount.hasErrors(), - ERROR_SHOULD_NOT_BE_ADDED - ); + System.Assert.areEqual(false, oldAccount.hasErrors(), ERROR_SHOULD_NOT_BE_ADDED); } @IsTest private static void afterDeleteShouldSucceed() { actionFlow.afterDelete(triggerOld); - System.Assert.areEqual( - false, - oldAccount.hasErrors(), - ERROR_SHOULD_NOT_BE_ADDED - ); + System.Assert.areEqual(false, oldAccount.hasErrors(), ERROR_SHOULD_NOT_BE_ADDED); } @IsTest private static void afterUndeleteShouldSucceed() { actionFlow.afterUndelete(triggerOld); - System.Assert.areEqual( - false, - myAccount.hasErrors(), - ERROR_SHOULD_NOT_BE_ADDED - ); + System.Assert.areEqual(false, myAccount.hasErrors(), ERROR_SHOULD_NOT_BE_ADDED); } @IsTest @@ -249,24 +212,18 @@ private class TriggerActionFlowTest { System.Assert.areEqual( true, - myException.getMessage() - .contains(TriggerActionFlow.RECORD_VARIABLE_NOT_FOUND_ERROR), + myException.getMessage().contains(TriggerActionFlow.RECORD_VARIABLE_NOT_FOUND_ERROR), EXCEPTION_SHOULD_HAVE_THE_CORRECT_MESSAGE ); } @IsTest private static void noRecordMutationsShouldSucceed() { - successResult.getOutputParameters() - .put(TriggerActionConstants.RECORD_VARIABLE, myAccount); + successResult.getOutputParameters().put(TriggerActionConstants.RECORD_VARIABLE, myAccount); actionFlow.beforeInsert(triggerNew); - System.Assert.areEqual( - false, - myAccount.hasErrors(), - ERROR_SHOULD_NOT_BE_ADDED - ); + System.Assert.areEqual(false, myAccount.hasErrors(), ERROR_SHOULD_NOT_BE_ADDED); } @IsTest @@ -288,16 +245,11 @@ private class TriggerActionFlowTest { new InvocableActionResultBuilder() .setSuccess(false) .setOutputParameters( - new Map{ - TriggerActionConstants.RECORD_VARIABLE => myAccountAfterFlow - } + new Map{ TriggerActionConstants.RECORD_VARIABLE => myAccountAfterFlow } ) .setErrors( new List{ - new InvocableActionErrorBuilder() - .setCode(TEST) - .setMessage(FOO) - .build() + new InvocableActionErrorBuilder().setCode(TEST).setMessage(FOO).build() } ) .build() @@ -362,17 +314,10 @@ private class TriggerActionFlowTest { @IsTest private static void invokeFlowShouldReturnUnsuccessfulResponseWithBogusFlowName() { List results = new TriggerActionFlow.InvocableAction() - .invokeAction( - BOGUS, - new List>{ new Map() } - ); + .invokeAction(BOGUS, new List>{ new Map() }); System.Assert.areEqual(1, results.size(), ONE_ERROR); - System.Assert.areEqual( - false, - results[0].isSuccess(), - 'It should have failed with bogus name' - ); + System.Assert.areEqual(false, results[0].isSuccess(), 'It should have failed with bogus name'); } private virtual class FakeInvocableAction extends TriggerActionFlow.InvocableAction { @@ -394,9 +339,7 @@ private class TriggerActionFlowTest { private Invocable.Action action; private List errors; - public InvocableActionResultBuilder setOutputParameters( - Map outputParameters - ) { + public InvocableActionResultBuilder setOutputParameters(Map outputParameters) { this.outputParameters = outputParameters; return this; } @@ -408,9 +351,7 @@ private class TriggerActionFlowTest { this.action = action; return this; } - public InvocableActionResultBuilder setErrors( - List errors - ) { + public InvocableActionResultBuilder setErrors(List errors) { this.errors = errors; return this; } @@ -447,11 +388,9 @@ private class TriggerActionFlowTest { public Invocable.Action.error build() { return (Invocable.Action.error) JSON.deserialize( - JSON.serialize( - new Map{ 'code' => code, 'message' => message } - ), + JSON.serialize(new Map{ 'code' => code, 'message' => message }), Invocable.Action.error.class ); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerBase.cls b/trigger-actions-framework/main/default/classes/TriggerBase.cls index 61389ec..dd46e62 100644 --- a/trigger-actions-framework/main/default/classes/TriggerBase.cls +++ b/trigger-actions-framework/main/default/classes/TriggerBase.cls @@ -192,15 +192,13 @@ public inherited sharing virtual class TriggerBase { this instanceof TriggerAction.BeforeUpdate ) { this.incrementUpdateCounts(this.context, this.triggerNew); - ((TriggerAction.BeforeUpdate) this) - .beforeUpdate(this.triggerNew, this.triggerOld); + ((TriggerAction.BeforeUpdate) this).beforeUpdate(this.triggerNew, this.triggerOld); } else if ( this.context == System.TriggerOperation.AFTER_UPDATE && this instanceof TriggerAction.AfterUpdate ) { this.incrementUpdateCounts(this.context, this.triggerNew); - ((TriggerAction.AfterUpdate) this) - .afterUpdate(this.triggerNew, this.triggerOld); + ((TriggerAction.AfterUpdate) this).afterUpdate(this.triggerNew, this.triggerOld); } else if ( this.context == System.TriggerOperation.BEFORE_DELETE && this instanceof TriggerAction.BeforeDelete @@ -252,9 +250,7 @@ public inherited sharing virtual class TriggerBase { List records ) { for (SObject obj : records) { - Map idToUpdateCount = CONTEXT_TO_UPDATE_COUNT.get( - triggerContext - ); + Map idToUpdateCount = CONTEXT_TO_UPDATE_COUNT.get(triggerContext); Integer updateCount = idToUpdateCount.get(obj.Id); if (updateCount == null) { updateCount = 0; @@ -313,10 +309,7 @@ public inherited sharing virtual class TriggerBase { protected String sObjectName { get { if (sObjectName == null) { - sObjectName = this.sObjectType.getDescribe( - SObjectDescribeOptions.DEFERRED - ) - .getName(); + sObjectName = this.sObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(); } return sObjectName; } @@ -358,9 +351,7 @@ public inherited sharing virtual class TriggerBase { private Integer triggerSize { get { - return triggerNew != null - ? triggerNew.size() - : triggerOld != null ? triggerOld.size() : 0; + return triggerNew != null ? triggerNew.size() : triggerOld != null ? triggerOld.size() : 0; } } @@ -428,4 +419,4 @@ public inherited sharing virtual class TriggerBase { @TestVisible private class EmptyStackException extends Exception { } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerBaseTest.cls b/trigger-actions-framework/main/default/classes/TriggerBaseTest.cls index 54e65f9..0687010 100644 --- a/trigger-actions-framework/main/default/classes/TriggerBaseTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerBaseTest.cls @@ -70,16 +70,8 @@ private class TriggerBaseTest { base.triggerNew = null; base.triggerOld = null; - System.Assert.areEqual( - null, - base.triggerNew, - 'triggerNew should match Trigger.new' - ); - System.Assert.areEqual( - null, - base.triggerOld, - 'triggerOld should match Trigger.old' - ); + System.Assert.areEqual(null, base.triggerNew, 'triggerNew should match Trigger.new'); + System.Assert.areEqual(null, base.triggerOld, 'triggerOld should match Trigger.old'); } @IsTest @@ -182,11 +174,7 @@ private class TriggerBaseTest { myException = e; } - System.Assert.areNotEqual( - null, - myException, - 'An exception should be thrown' - ); + System.Assert.areNotEqual(null, myException, 'An exception should be thrown'); System.Assert.areEqual( TriggerBase.HANDLER_OUTSIDE_TRIGGER_MESSAGE, myException.getMessage(), @@ -276,10 +264,7 @@ private class TriggerBaseTest { private static void isBypassedShouldSucceed() { TriggerBase.bypass(ACCOUNT); - System.Assert.isTrue( - TriggerBase.isBypassed(ACCOUNT), - BYPASSES_SHOULD_BE_CONFIGURED_CORRECTLY - ); + System.Assert.isTrue(TriggerBase.isBypassed(ACCOUNT), BYPASSES_SHOULD_BE_CONFIGURED_CORRECTLY); } @IsTest @@ -299,11 +284,7 @@ private class TriggerBaseTest { private static void offsetRowsShouldWork() { TriggerBase.offsetExistingDmlRows(); - System.Assert.areEqual( - 0, - TriggerBase.existingDmlRowsOffset, - 'Offset is not working properly' - ); + System.Assert.areEqual(0, TriggerBase.existingDmlRowsOffset, 'Offset is not working properly'); } @IsTest @@ -343,10 +324,7 @@ private class TriggerBaseTest { stack.push(FIRST); stack.pop(); - System.Assert.isTrue( - stack.isEmpty(), - 'The stack is empty but unable to identify as such' - ); + System.Assert.isTrue(stack.isEmpty(), 'The stack is empty but unable to identify as such'); } @IsTest @@ -387,11 +365,7 @@ private class TriggerBaseTest { stack.push(SECOND); stack.push(THIRD); - System.Assert.areEqual( - THIRD, - stack.peek(), - 'The last element in the stack is not peeked' - ); + System.Assert.areEqual(THIRD, stack.peek(), 'The last element in the stack is not peeked'); } @IsTest @@ -401,11 +375,7 @@ private class TriggerBaseTest { stack.push(SECOND); stack.push(THIRD); - System.Assert.areEqual( - 3, - stack.depth(), - 'The stack is not properly calculating its depth' - ); + System.Assert.areEqual(3, stack.depth(), 'The stack is not properly calculating its depth'); } @IsTest @@ -452,16 +422,10 @@ private class TriggerBaseTest { public void afterInsert(List triggerNew) { this.executed = true; } - public void beforeUpdate( - List triggerNew, - List triggerOld - ) { + public void beforeUpdate(List triggerNew, List triggerOld) { this.executed = true; } - public void afterUpdate( - List triggerNew, - List triggerOld - ) { + public void afterUpdate(List triggerNew, List triggerOld) { this.executed = true; } public void beforeDelete(List triggerOld) { @@ -484,4 +448,4 @@ private class TriggerBaseTest { return super.getDmlRows(); } } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerRecord.cls b/trigger-actions-framework/main/default/classes/TriggerRecord.cls index fff6e45..5733709 100644 --- a/trigger-actions-framework/main/default/classes/TriggerRecord.cls +++ b/trigger-actions-framework/main/default/classes/TriggerRecord.cls @@ -28,4 +28,4 @@ global abstract class TriggerRecord { * @description The previous version of the SObject that triggered the current execution context. */ global SObject oldSobject; -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerRecordTest.cls b/trigger-actions-framework/main/default/classes/TriggerRecordTest.cls index f111235..a8aca7b 100644 --- a/trigger-actions-framework/main/default/classes/TriggerRecordTest.cls +++ b/trigger-actions-framework/main/default/classes/TriggerRecordTest.cls @@ -34,4 +34,4 @@ private class TriggerRecordTest { private class AccountTriggerRecord extends TriggerRecord { } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/classes/TriggerTestUtility.cls b/trigger-actions-framework/main/default/classes/TriggerTestUtility.cls index 1353a32..7992d0c 100644 --- a/trigger-actions-framework/main/default/classes/TriggerTestUtility.cls +++ b/trigger-actions-framework/main/default/classes/TriggerTestUtility.cls @@ -35,9 +35,8 @@ public class TriggerTestUtility { */ public static Id getFakeId(Schema.SObjectType sObjectType) { String result = String.valueOf(myNumber++); - return (Id) (sObjectType.getDescribe(SObjectDescribeOptions.DEFERRED) - .getKeyPrefix() + + return (Id) (sObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getKeyPrefix() + '0'.repeat(12 - result.length()) + result); } -} +} \ No newline at end of file diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Delete__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Delete__c.field-meta.xml index 68f7025..11fd070 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Delete__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Delete__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the sObject you want to have this action execute on during the after delete context false DeveloperControlled - Enter the name of the sObject you want to have this action execute on during the after delete context + Enter the name of the sObject you want to have this action execute on during the after delete context sObject_Trigger_Setting__mdt After Delete diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Insert__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Insert__c.field-meta.xml index 302fb0b..2adfa11 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Insert__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Insert__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the sObject you want to have this action execute on during the after insert context false DeveloperControlled - Enter the name of the sObject you want to have this action execute on during the after insert context + Enter the name of the sObject you want to have this action execute on during the after insert context sObject_Trigger_Setting__mdt After Insert diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Undelete__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Undelete__c.field-meta.xml index 3fd9b8b..30a40a1 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Undelete__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Undelete__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the sObject you want to have this action execute on during the after undelete context false DeveloperControlled - Enter the name of the sObject you want to have this action execute on during the after undelete context + Enter the name of the sObject you want to have this action execute on during the after undelete context sObject_Trigger_Setting__mdt After Undelete diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Update__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Update__c.field-meta.xml index c3b0fe5..2b899ad 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Update__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/After_Update__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the sObject you want to have this action execute on during the after update context false DeveloperControlled - Enter the name of the sObject you want to have this action execute on during the after update context + Enter the name of the sObject you want to have this action execute on during the after update context sObject_Trigger_Setting__mdt After Update diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Allow_Flow_Recursion__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Allow_Flow_Recursion__c.field-meta.xml index c286467..9c53675 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Allow_Flow_Recursion__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Allow_Flow_Recursion__c.field-meta.xml @@ -6,8 +6,7 @@ >Check this box to allow the flow to execute recursively false DeveloperControlled - Check this box to allow the flow to execute recursively + Check this box to allow the flow to execute recursively Checkbox diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Apex_Class_Name__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Apex_Class_Name__c.field-meta.xml index 90ec74b..d242a5f 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Apex_Class_Name__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Apex_Class_Name__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the Apex Class which defines the action to be taken false DeveloperControlled - Enter the name of the Apex Class which defines the action to be taken + Enter the name of the Apex Class which defines the action to be taken 255 true diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Delete__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Delete__c.field-meta.xml index e65d335..fa95b94 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Delete__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Delete__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the sObject you want to have this action execute on during the before delete context false DeveloperControlled - Enter the name of the sObject you want to have this action execute on during the before delete context + Enter the name of the sObject you want to have this action execute on during the before delete context sObject_Trigger_Setting__mdt Before Delete diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Insert__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Insert__c.field-meta.xml index e1a0925..3d5d94b 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Insert__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Insert__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the sObject you want to have this action execute on during the before insert context false DeveloperControlled - Enter the name of the sObject you want to have this action execute on during the before insert context + Enter the name of the sObject you want to have this action execute on during the before insert context sObject_Trigger_Setting__mdt Before Insert diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Update__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Update__c.field-meta.xml index d3ed1f4..8bcc800 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Update__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Before_Update__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the name of the sObject you want to have this action execute on during the before update context false DeveloperControlled - Enter the name of the sObject you want to have this action execute on during the before update context + Enter the name of the sObject you want to have this action execute on during the before update context sObject_Trigger_Setting__mdt Before Update diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Execution__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Execution__c.field-meta.xml index 90bc22f..3e6ed47 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Execution__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Execution__c.field-meta.xml @@ -6,8 +6,7 @@ >Set this to true to bypass this Trigger Action from being called false DeveloperControlled - Set this to true to bypass this Trigger Action from being called + Set this to true to bypass this Trigger Action from being called Checkbox diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Permission__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Permission__c.field-meta.xml index ea16c02..e7dd391 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Permission__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Bypass_Permission__c.field-meta.xml @@ -5,8 +5,7 @@ >Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will be bypassed if the running user has the custom permission identified. false DeveloperControlled - Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will be bypassed if the running user has the custom permission identified. + Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will be bypassed if the running user has the custom permission identified. 255 false diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Flow_Name__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Flow_Name__c.field-meta.xml index f5362c6..9ee380a 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Flow_Name__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Flow_Name__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the API name of the flow you would like to execute. false DeveloperControlled - Enter the API name of the flow you would like to execute. + Enter the API name of the flow you would like to execute. 255 false diff --git a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Required_Permission__c.field-meta.xml b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Required_Permission__c.field-meta.xml index 32ce281..5b0e9c1 100644 --- a/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Required_Permission__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/Trigger_Action__mdt/fields/Required_Permission__c.field-meta.xml @@ -5,8 +5,7 @@ >Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will only execute if the running user has the custom permission identified. false DeveloperControlled - Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will only execute if the running user has the custom permission identified. + Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will only execute if the running user has the custom permission identified. 255 false diff --git a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Execution__c.field-meta.xml b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Execution__c.field-meta.xml index 9f31adb..351e229 100644 --- a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Execution__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Execution__c.field-meta.xml @@ -6,8 +6,7 @@ >Set this to true to bypass all Trigger Actions from being called on this sObject false DeveloperControlled - Set this to true to bypass all Trigger Actions from being called on this sObject + Set this to true to bypass all Trigger Actions from being called on this sObject Checkbox diff --git a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Permission__c.field-meta.xml b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Permission__c.field-meta.xml index ea16c02..e7dd391 100644 --- a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Permission__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Bypass_Permission__c.field-meta.xml @@ -5,8 +5,7 @@ >Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will be bypassed if the running user has the custom permission identified. false DeveloperControlled - Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will be bypassed if the running user has the custom permission identified. + Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will be bypassed if the running user has the custom permission identified. 255 false diff --git a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_API_Name__c.field-meta.xml b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_API_Name__c.field-meta.xml index 946b62f..81ff96a 100644 --- a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_API_Name__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_API_Name__c.field-meta.xml @@ -5,8 +5,7 @@ >Enter the API Name of the object for this trigger. If this object is part of a managed package, do not include the prefix. false DeveloperControlled - Enter the API Name of the object for this trigger. If this object is part of a managed package, do not include the prefix. + Enter the API Name of the object for this trigger. If this object is part of a managed package, do not include the prefix. 255 true diff --git a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_Namespace__c.field-meta.xml b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_Namespace__c.field-meta.xml index 9539903..b0f8e89 100644 --- a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_Namespace__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Object_Namespace__c.field-meta.xml @@ -4,8 +4,7 @@ Enter the namespace object for this trigger. false DeveloperControlled - Enter the namespace object for this trigger. + Enter the namespace object for this trigger. 255 false diff --git a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Required_Permission__c.field-meta.xml b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Required_Permission__c.field-meta.xml index ed1a9c4..845b950 100644 --- a/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Required_Permission__c.field-meta.xml +++ b/trigger-actions-framework/main/default/objects/sObject_Trigger_Setting__mdt/fields/Required_Permission__c.field-meta.xml @@ -5,8 +5,7 @@ >Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will only execute if the running user has the custom permission identified. false DeveloperControlled - Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will only execute if the running user has the custom permission identified. + Optional. Enter the API name of a permission. If this field has a value, then the triggers on this object will only execute if the running user has the custom permission identified. 255 false