From 441cd822d9f17514c177728791d6896ade865f61 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Tue, 25 Jan 2022 14:53:16 -0500 Subject: [PATCH 01/21] change getter to make it available for unit tests --- .../classes/STG_PanelDataImportAdvancedMapping_CTRL.cls | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls index d8d5b31a2f..2dcb5073e4 100644 --- a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls +++ b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls @@ -109,11 +109,15 @@ public with sharing class STG_PanelDataImportAdvancedMapping_CTRL extends STG_Pa /******************************************************************************************************* * @description is the running user an admin */ + @TestVisible public Boolean isAdmin { get { - return STG_Panel.runningUserIsAdmin(); + if (isAdmin == null) { + isAdmin = STG_Panel.runningUserIsAdmin(); + } + return isAdmin; } - set; + private set; } /******************************************************************************************************* From ef0a325a19b6e38f01d1c0b23c3414fd6e7af7cf Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Tue, 25 Jan 2022 17:46:07 -0500 Subject: [PATCH 02/21] add enable advanced mapping action and unit test for callable api --- .../main/default/classes/Callable_API.cls | 27 +++++++++++- .../default/classes/Callable_API_TEST.cls | 42 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/force-app/main/default/classes/Callable_API.cls b/force-app/main/default/classes/Callable_API.cls index 591b59b0c5..66d0e7a910 100644 --- a/force-app/main/default/classes/Callable_API.cls +++ b/force-app/main/default/classes/Callable_API.cls @@ -42,6 +42,21 @@ global with sharing class Callable_API implements System.Callable { ********************************************************************************************************/ public class MalformedMethodInvocationException extends Exception {} + /******************************************************************************************************* + * @description Data Import controller + ********************************************************************************************************/ + @TestVisible + private STG_PanelDataImportAdvancedMapping_CTRL panelMappingController { + get { + if (panelMappingController == null) { + panelMappingController = new STG_PanelDataImportAdvancedMapping_CTRL(); + } + return panelMappingController; + } + set; + } + + /******************************************************************************************************* * @description call function implementation of the callable Interface will dispatch to the appropriate * action handler based on the action text @@ -159,7 +174,17 @@ global with sharing class Callable_API implements System.Callable { // It returns the Job ID of the Scheduled Job. return CallableApiApexDelegationService.handleApexScheduleJob(params); - } when else { + } when 'settings.enableadvancedmapping' { + panelMappingController.enableDataImportFieldMapping(); + + return null; + + } when 'settings.enableGiftEntry' { + panelMappingController.enableGiftEntry(); + + return null; + } + when else { throw new MalformedMethodInvocationException( String.format(System.Label.CallableApiMethodNotImplemented, new List { action }) ); diff --git a/force-app/main/default/classes/Callable_API_TEST.cls b/force-app/main/default/classes/Callable_API_TEST.cls index 8f8aceb8fe..0eaa566d0d 100644 --- a/force-app/main/default/classes/Callable_API_TEST.cls +++ b/force-app/main/default/classes/Callable_API_TEST.cls @@ -43,6 +43,7 @@ private with sharing class Callable_API_TEST { private static final String RD2_ENABLE_ACTION = 'Settings.EnableEnhancedRecurringDonations'; private static final String JOB_SCHEDULE_ACTION = 'Apex.ScheduleJob'; private static final String RD2_PAUSE_ACTION = 'rd2.pause'; + private static final String ADVANCED_MAPPING_ACTION = 'settings.enableadvancedmapping'; /** * @description verify the TDTM Callable action returns an Object @@ -117,6 +118,21 @@ private with sharing class Callable_API_TEST { Test.stopTest(); } + @IsTest + private static void shouldCallEnableAdvancedMappingOnAction() { + + Test.startTest(); + Callable_API callableApi = new Callable_API(); + STG_PanelDataImportAdvancedMapping_CTRLMock controllerMock = new STG_PanelDataImportAdvancedMapping_CTRLMock(); + callableApi.panelMappingController = stubFor(controllerMock); + + callableApi.call(ADVANCED_MAPPING_ACTION, null); + Test.stopTest(); + + System.assert(controllerMock.enableDataImportMappingCalled, 'The enabled advanced mapping controller method ' + + 'should be called.'); + } + /** * @description Verifies if Enhanced Recurring Donations are enabled */ @@ -189,4 +205,30 @@ private with sharing class Callable_API_TEST { new List { UTIL_UnitTestData_TEST.MOCK_ACCOUNT_ID }); System.assertEquals(expectedErrorMessage, returnPause.error, 'An error with unexpected Id should be return'); } + + private static STG_PanelDataImportAdvancedMapping_CTRL stubFor(STG_PanelDataImportAdvancedMapping_CTRLMock + advancedMappingControllerMock) { + return (STG_PanelDataImportAdvancedMapping_CTRL) Test.createStub( + STG_PanelDataImportAdvancedMapping_CTRL.class, advancedMappingControllerMock); + } + + private class STG_PanelDataImportAdvancedMapping_CTRLMock implements StubProvider { + Boolean enableDataImportMappingCalled = false; + + public Object handleMethodCall( + Object stubbedObject, + String stubbedMethodName, + Type returnType, + List listOfParamTypes, + List listOfParamNames, + List listOfArgs) { + + switch on (stubbedMethodName) { + when 'enableDataImportFieldMapping' { + enableDataImportMappingCalled = true; + } + } + return null; + } + } } From 037b2b200c1cb045a72b1406b574812296400e92 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 26 Jan 2022 12:58:56 -0500 Subject: [PATCH 03/21] add test scenario for enabling gift entry in callable api --- .../main/default/classes/Callable_API.cls | 2 +- .../default/classes/Callable_API_TEST.cls | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/force-app/main/default/classes/Callable_API.cls b/force-app/main/default/classes/Callable_API.cls index 66d0e7a910..09bd7b1b3b 100644 --- a/force-app/main/default/classes/Callable_API.cls +++ b/force-app/main/default/classes/Callable_API.cls @@ -179,7 +179,7 @@ global with sharing class Callable_API implements System.Callable { return null; - } when 'settings.enableGiftEntry' { + } when 'settings.enablegiftentry' { panelMappingController.enableGiftEntry(); return null; diff --git a/force-app/main/default/classes/Callable_API_TEST.cls b/force-app/main/default/classes/Callable_API_TEST.cls index 0eaa566d0d..bbca1ddc7e 100644 --- a/force-app/main/default/classes/Callable_API_TEST.cls +++ b/force-app/main/default/classes/Callable_API_TEST.cls @@ -44,6 +44,7 @@ private with sharing class Callable_API_TEST { private static final String JOB_SCHEDULE_ACTION = 'Apex.ScheduleJob'; private static final String RD2_PAUSE_ACTION = 'rd2.pause'; private static final String ADVANCED_MAPPING_ACTION = 'settings.enableadvancedmapping'; + private static final String GIFT_ENTRY_ACTION = 'settings.enablegiftentry'; /** * @description verify the TDTM Callable action returns an Object @@ -133,6 +134,20 @@ private with sharing class Callable_API_TEST { 'should be called.'); } + @IsTest + private static void shouldCallEnableGiftEntryOnAction() { + Test.startTest(); + Callable_API callableApi = new Callable_API(); + STG_PanelDataImportAdvancedMapping_CTRLMock controllerMock = new STG_PanelDataImportAdvancedMapping_CTRLMock(); + callableApi.panelMappingController = stubFor(controllerMock); + + callableApi.call(GIFT_ENTRY_ACTION, null); + Test.stopTest(); + + System.assert(controllerMock.enableGiftEntryCalled, 'The enabled gift entry controller method ' + + 'should be called.'); + } + /** * @description Verifies if Enhanced Recurring Donations are enabled */ @@ -214,6 +229,7 @@ private with sharing class Callable_API_TEST { private class STG_PanelDataImportAdvancedMapping_CTRLMock implements StubProvider { Boolean enableDataImportMappingCalled = false; + Boolean enableGiftEntryCalled = false; public Object handleMethodCall( Object stubbedObject, @@ -227,6 +243,9 @@ private with sharing class Callable_API_TEST { when 'enableDataImportFieldMapping' { enableDataImportMappingCalled = true; } + when 'enableGiftEntry' { + enableGiftEntryCalled = true; + } } return null; } From 40660d112f2aaa71a127d024de21396f5e79929b Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 26 Jan 2022 13:38:10 -0500 Subject: [PATCH 04/21] don't call advanced mapping deploy if mapping is already enabled and add test scenario --- .../main/default/classes/Callable_API.cls | 19 +++++++++++++++++ .../default/classes/Callable_API_TEST.cls | 21 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/force-app/main/default/classes/Callable_API.cls b/force-app/main/default/classes/Callable_API.cls index 09bd7b1b3b..a903bd1b4c 100644 --- a/force-app/main/default/classes/Callable_API.cls +++ b/force-app/main/default/classes/Callable_API.cls @@ -56,6 +56,16 @@ global with sharing class Callable_API implements System.Callable { set; } + @TestVisible + private UTIL_CustomSettingsFacade customSettingsFacade { + get { + if (customSettingsFacade == null) { + customSettingsFacade = new UTIL_CustomSettingsFacade(); + } + return customSettingsFacade; + } + set; + } /******************************************************************************************************* * @description call function implementation of the callable Interface will dispatch to the appropriate @@ -175,6 +185,11 @@ global with sharing class Callable_API implements System.Callable { return CallableApiApexDelegationService.handleApexScheduleJob(params); } when 'settings.enableadvancedmapping' { + Data_Import_Settings__c dataImportSettings = UTIL_CustomSettingsFacade.getDataImportSettings(); + if (isAdvancedMappingEnabled(dataImportSettings)) { + return null; + } + panelMappingController.enableDataImportFieldMapping(); return null; @@ -195,4 +210,8 @@ global with sharing class Callable_API implements System.Callable { return true; } + private Boolean isAdvancedMappingEnabled(Data_Import_Settings__c dataImportSettings) { + return dataImportSettings.Field_Mapping_Method__c == BDI_MigrationMappingUtility.DATA_IMPORT_FIELD_MAPPING; + } + } diff --git a/force-app/main/default/classes/Callable_API_TEST.cls b/force-app/main/default/classes/Callable_API_TEST.cls index bbca1ddc7e..db4fda0d88 100644 --- a/force-app/main/default/classes/Callable_API_TEST.cls +++ b/force-app/main/default/classes/Callable_API_TEST.cls @@ -130,10 +130,29 @@ private with sharing class Callable_API_TEST { callableApi.call(ADVANCED_MAPPING_ACTION, null); Test.stopTest(); - System.assert(controllerMock.enableDataImportMappingCalled, 'The enabled advanced mapping controller method ' + + System.assert(controllerMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + 'should be called.'); } + @IsTest + private static void shouldNotCallEnableAdvancedMappingIfMappingIsEnabled() { + Data_Import_Settings__c dataImportSettings = new Data_Import_Settings__c(); + dataImportSettings.Field_Mapping_Method__c = BDI_MigrationMappingUtility.DATA_IMPORT_FIELD_MAPPING; + UTIL_CustomSettingsFacade.setDataImportSettings(dataImportSettings); + + Callable_API callableApi = new Callable_API(); + STG_PanelDataImportAdvancedMapping_CTRLMock controllerMock = new + STG_PanelDataImportAdvancedMapping_CTRLMock(); + callableApi.panelMappingController = stubFor(controllerMock); + + Test.startTest(); + callableApi.call(ADVANCED_MAPPING_ACTION, null); + Test.stopTest(); + + System.assert(!controllerMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + + 'should not be called.'); + } + @IsTest private static void shouldCallEnableGiftEntryOnAction() { Test.startTest(); From 5ad258525b8a33fade0b0995d3d84437b55829f2 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Mon, 31 Jan 2022 13:39:35 -0500 Subject: [PATCH 05/21] introduce advanced mapping enablement service --- .../AdvancedMappingEnablementService.cls | 63 +++++++++++++++ ...ancedMappingEnablementService.cls-meta.xml | 5 ++ .../AdvancedMappingEnablementService_TEST.cls | 78 +++++++++++++++++++ ...MappingEnablementService_TEST.cls-meta.xml | 5 ++ .../main/default/classes/Callable_API.cls | 27 ++----- ...TG_PanelDataImportAdvancedMapping_CTRL.cls | 19 +++-- 6 files changed, 170 insertions(+), 27 deletions(-) create mode 100644 force-app/main/default/classes/AdvancedMappingEnablementService.cls create mode 100644 force-app/main/default/classes/AdvancedMappingEnablementService.cls-meta.xml create mode 100644 force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls create mode 100644 force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls-meta.xml diff --git a/force-app/main/default/classes/AdvancedMappingEnablementService.cls b/force-app/main/default/classes/AdvancedMappingEnablementService.cls new file mode 100644 index 0000000000..f16c8ce262 --- /dev/null +++ b/force-app/main/default/classes/AdvancedMappingEnablementService.cls @@ -0,0 +1,63 @@ +/* + Copyright (c) 2019, Salesforce.org + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Salesforce.org nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/** + * @author: Salesforce.org + * @date: 2021 + * @description: Service to enable the advanced mapping feature + */ +public with sharing class AdvancedMappingEnablementService { + + @TestVisible + private BDI_MigrationMappingUtility migrationMappingUtility { + get { + if (migrationMappingUtility == null) { + migrationMappingUtility = new BDI_MigrationMappingUtility(new BDI_MigrationMappingHelper()); + } + return migrationMappingUtility; + } + set; + } + + public Id enable() { + migrationMappingUtility.migrateHelpTextToCustomMetadata(); + + Id deploymentId = CMT_MetadataAPI.deployMetadata( + migrationMappingUtility.queuedMetadataTypesForDeploy, + new BDI_MigrationMappingUtility.DeploymentCallback()); + + return deploymentId; + } + + public Boolean isEnabled() { + Data_Import_Settings__c dataImportSettings = UTIL_CustomSettingsFacade.getDataImportSettings(); + + return dataImportSettings.Field_Mapping_Method__c == BDI_MigrationMappingUtility.DATA_IMPORT_FIELD_MAPPING; + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/AdvancedMappingEnablementService.cls-meta.xml b/force-app/main/default/classes/AdvancedMappingEnablementService.cls-meta.xml new file mode 100644 index 0000000000..f928c8e56b --- /dev/null +++ b/force-app/main/default/classes/AdvancedMappingEnablementService.cls-meta.xml @@ -0,0 +1,5 @@ + + + 53.0 + Active + diff --git a/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls b/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls new file mode 100644 index 0000000000..aeae339508 --- /dev/null +++ b/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls @@ -0,0 +1,78 @@ +@IsTest +private class AdvancedMappingEnablementService_TEST { + + @IsTest + private static void shouldExecuteHelpTextMigrationOnEnable() { + AdvancedMappingEnablementService mappingService = new AdvancedMappingEnablementService(); + BDI_MigrationMappingUtilityMock migrationMappingUtilityMock = new BDI_MigrationMappingUtilityMock(); + mappingService.migrationMappingUtility = stubFor(migrationMappingUtilityMock); + mappingService.migrationMappingUtility.queuedMetadataTypesForDeploy = getMockMetadata(); + + Test.startTest(); + mappingService.enable(); + Test.stopTest(); + + System.assert(migrationMappingUtilityMock.migrateHelpTextCalled, 'The migration of help text to custom ' + + 'metadata should execute.'); + } + + @IsTest + private static void shouldUpdateCustomSettingsForDataImportFieldMapping() { + BDI_MigrationMappingUtility.DeploymentCallback callback = new BDI_MigrationMappingUtility.DeploymentCallback(); + TestingDeployCallbackContext context = new TestingDeployCallbackContext(); + + Metadata.DeployResult deployResult = new Metadata.DeployResult(); + deployResult.status = Metadata.DeployStatus.Succeeded; + + Test.startTest(); + callback.handleResult(deployResult, context); + Test.stopTest(); + + Data_Import_Settings__c dataImportSettings = UTIL_CustomSettingsFacade.getDataImportSettings(); + + System.assertNotEquals(Metadata.DeployStatus.Succeeded.name(), dataImportSettings.CMT_API_Status__c); + + + System.assert(new AdvancedMappingEnablementService().isEnabled(), 'Advanced mapping should be enabled.'); + } + + private static List getMockMetadata() { + List mockCustomMetadataRecords = new List(); + Metadata.CustomMetadata mockCustomMetadata1 = new Metadata.CustomMetadata(); + + mockCustomMetadata1.description = 'test'; + mockCustomMetadata1.fullName = 'test_metadata'; + mockCustomMetadata1.label = 'test'; + mockCustomMetadataRecords.add(mockCustomMetadata1); + + return mockCustomMetadataRecords; + } + + private static BDI_MigrationMappingUtility stubFor(BDI_MigrationMappingUtilityMock migrationMappingUtilityMock) { + + return (BDI_MigrationMappingUtility) Test.createStub( + BDI_MigrationMappingUtility.class, migrationMappingUtilityMock); + } + + private class BDI_MigrationMappingUtilityMock implements StubProvider { + private Boolean migrateHelpTextCalled = false; + + public Object handleMethodCall(Object stubbedObject, String stubbedMethodName, Type returnType, + List listOfParamTypes, List listOfParamNames, List listOfArgs) { + + switch on (stubbedMethodName) { + when 'migrateHelpTextToCustomMetadata' { + migrateHelpTextCalled = true; + } + } + + return null; + } + } + + private class TestingDeployCallbackContext extends Metadata.DeployCallbackContext { + public override Id getCallbackJobId() { + return '000000000122345'; + } + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls-meta.xml b/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls-meta.xml new file mode 100644 index 0000000000..f928c8e56b --- /dev/null +++ b/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls-meta.xml @@ -0,0 +1,5 @@ + + + 53.0 + Active + diff --git a/force-app/main/default/classes/Callable_API.cls b/force-app/main/default/classes/Callable_API.cls index a903bd1b4c..8054a96981 100644 --- a/force-app/main/default/classes/Callable_API.cls +++ b/force-app/main/default/classes/Callable_API.cls @@ -42,27 +42,14 @@ global with sharing class Callable_API implements System.Callable { ********************************************************************************************************/ public class MalformedMethodInvocationException extends Exception {} - /******************************************************************************************************* - * @description Data Import controller - ********************************************************************************************************/ - @TestVisible - private STG_PanelDataImportAdvancedMapping_CTRL panelMappingController { - get { - if (panelMappingController == null) { - panelMappingController = new STG_PanelDataImportAdvancedMapping_CTRL(); - } - return panelMappingController; - } - set; - } @TestVisible - private UTIL_CustomSettingsFacade customSettingsFacade { + private AdvancedMappingEnablementService advancedMappingEnablementService { get { - if (customSettingsFacade == null) { - customSettingsFacade = new UTIL_CustomSettingsFacade(); + if (advancedMappingEnablementService == null) { + advancedMappingEnablementService = new AdvancedMappingEnablementService(); } - return customSettingsFacade; + return advancedMappingEnablementService; } set; } @@ -185,17 +172,15 @@ global with sharing class Callable_API implements System.Callable { return CallableApiApexDelegationService.handleApexScheduleJob(params); } when 'settings.enableadvancedmapping' { - Data_Import_Settings__c dataImportSettings = UTIL_CustomSettingsFacade.getDataImportSettings(); - if (isAdvancedMappingEnabled(dataImportSettings)) { + if (advancedMappingEnablementService.isEnabled()) { return null; } - panelMappingController.enableDataImportFieldMapping(); + advancedMappingEnablementService.enable(); return null; } when 'settings.enablegiftentry' { - panelMappingController.enableGiftEntry(); return null; } diff --git a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls index 2dcb5073e4..91b0bbc906 100644 --- a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls +++ b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls @@ -141,6 +141,17 @@ public with sharing class STG_PanelDataImportAdvancedMapping_CTRL extends STG_Pa set; } + @TestVisible + private AdvancedMappingEnablementService advancedMappingEnablementService { + get { + if (advancedMappingEnablementService == null) { + advancedMappingEnablementService = new AdvancedMappingEnablementService(); + } + return advancedMappingEnablementService; + } + set; + } + /******************************************************************************************************* * @description Instance of BDI_MigrationMappingUtility */ @@ -199,13 +210,9 @@ public with sharing class STG_PanelDataImportAdvancedMapping_CTRL extends STG_Pa isPolling = true; // Start the migration, collect help text mappings, and compare against existing cmt mappings - migrationMappingUtility.migrateHelpTextToCustomMetadata(); - - Id deploymentId = CMT_MetadataAPI.deployMetadata( - migrationMappingUtility.queuedMetadataTypesForDeploy, - new BDI_MigrationMappingUtility.DeploymentCallback()); + Id metadataDeploymentId = advancedMappingEnablementService.enable(); - saveDeploymentId(deploymentId); + saveDeploymentId(metadataDeploymentId); } catch (Exception e) { Database.rollback(sp); From 0d013fe2eb1f2922d184203a405aa252d448b3d9 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Mon, 31 Jan 2022 13:43:07 -0500 Subject: [PATCH 06/21] update callable api tests to use advanced mapping enablement service --- .../default/classes/Callable_API_TEST.cls | 40 +++++-------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/force-app/main/default/classes/Callable_API_TEST.cls b/force-app/main/default/classes/Callable_API_TEST.cls index db4fda0d88..3f13bef30d 100644 --- a/force-app/main/default/classes/Callable_API_TEST.cls +++ b/force-app/main/default/classes/Callable_API_TEST.cls @@ -124,13 +124,13 @@ private with sharing class Callable_API_TEST { Test.startTest(); Callable_API callableApi = new Callable_API(); - STG_PanelDataImportAdvancedMapping_CTRLMock controllerMock = new STG_PanelDataImportAdvancedMapping_CTRLMock(); - callableApi.panelMappingController = stubFor(controllerMock); + AdvancedMappingEnablementServiceMock mappingServiceMock = new AdvancedMappingEnablementServiceMock(); + callableApi.advancedMappingEnablementService = stubFor(mappingServiceMock); callableApi.call(ADVANCED_MAPPING_ACTION, null); Test.stopTest(); - System.assert(controllerMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + + System.assert(mappingServiceMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + 'should be called.'); } @@ -141,32 +141,18 @@ private with sharing class Callable_API_TEST { UTIL_CustomSettingsFacade.setDataImportSettings(dataImportSettings); Callable_API callableApi = new Callable_API(); - STG_PanelDataImportAdvancedMapping_CTRLMock controllerMock = new - STG_PanelDataImportAdvancedMapping_CTRLMock(); - callableApi.panelMappingController = stubFor(controllerMock); + AdvancedMappingEnablementServiceMock mappingServiceMock = new + AdvancedMappingEnablementServiceMock(); + callableApi.advancedMappingEnablementService = stubFor(mappingServiceMock); Test.startTest(); callableApi.call(ADVANCED_MAPPING_ACTION, null); Test.stopTest(); - System.assert(!controllerMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + + System.assert(!mappingServiceMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + 'should not be called.'); } - @IsTest - private static void shouldCallEnableGiftEntryOnAction() { - Test.startTest(); - Callable_API callableApi = new Callable_API(); - STG_PanelDataImportAdvancedMapping_CTRLMock controllerMock = new STG_PanelDataImportAdvancedMapping_CTRLMock(); - callableApi.panelMappingController = stubFor(controllerMock); - - callableApi.call(GIFT_ENTRY_ACTION, null); - Test.stopTest(); - - System.assert(controllerMock.enableGiftEntryCalled, 'The enabled gift entry controller method ' + - 'should be called.'); - } - /** * @description Verifies if Enhanced Recurring Donations are enabled */ @@ -240,15 +226,14 @@ private with sharing class Callable_API_TEST { System.assertEquals(expectedErrorMessage, returnPause.error, 'An error with unexpected Id should be return'); } - private static STG_PanelDataImportAdvancedMapping_CTRL stubFor(STG_PanelDataImportAdvancedMapping_CTRLMock + private static AdvancedMappingEnablementService stubFor(AdvancedMappingEnablementServiceMock advancedMappingControllerMock) { - return (STG_PanelDataImportAdvancedMapping_CTRL) Test.createStub( - STG_PanelDataImportAdvancedMapping_CTRL.class, advancedMappingControllerMock); + return (AdvancedMappingEnablementService) Test.createStub( + AdvancedMappingEnablementService.class, advancedMappingControllerMock); } - private class STG_PanelDataImportAdvancedMapping_CTRLMock implements StubProvider { + private class AdvancedMappingEnablementServiceMock implements StubProvider { Boolean enableDataImportMappingCalled = false; - Boolean enableGiftEntryCalled = false; public Object handleMethodCall( Object stubbedObject, @@ -262,9 +247,6 @@ private with sharing class Callable_API_TEST { when 'enableDataImportFieldMapping' { enableDataImportMappingCalled = true; } - when 'enableGiftEntry' { - enableGiftEntryCalled = true; - } } return null; } From eec0e18c1ee8385358a910cb41cd8f3f3e6d7de6 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Mon, 31 Jan 2022 18:00:18 -0500 Subject: [PATCH 07/21] update logic to use new gift entry enablement service --- .../main/default/classes/Callable_API.cls | 23 ++++-- .../default/classes/Callable_API_TEST.cls | 70 ++++++++++++++++--- .../classes/GiftEntryEnablementService.cls | 47 +++++++++++++ .../GiftEntryEnablementService.cls-meta.xml | 5 ++ ...TG_PanelDataImportAdvancedMapping_CTRL.cls | 8 +-- 5 files changed, 133 insertions(+), 20 deletions(-) create mode 100644 force-app/main/default/classes/GiftEntryEnablementService.cls create mode 100644 force-app/main/default/classes/GiftEntryEnablementService.cls-meta.xml diff --git a/force-app/main/default/classes/Callable_API.cls b/force-app/main/default/classes/Callable_API.cls index 8054a96981..a70ab8b665 100644 --- a/force-app/main/default/classes/Callable_API.cls +++ b/force-app/main/default/classes/Callable_API.cls @@ -54,6 +54,17 @@ global with sharing class Callable_API implements System.Callable { set; } + @TestVisible + private GiftEntryEnablementService giftEntryEnablementService { + get { + if (giftEntryEnablementService == null) { + giftEntryEnablementService = new GiftEntryEnablementService(); + } + return giftEntryEnablementService; + } + set; + } + /******************************************************************************************************* * @description call function implementation of the callable Interface will dispatch to the appropriate * action handler based on the action text @@ -175,12 +186,17 @@ global with sharing class Callable_API implements System.Callable { if (advancedMappingEnablementService.isEnabled()) { return null; } - ++ advancedMappingEnablementService.enable(); return null; } when 'settings.enablegiftentry' { + if (giftEntryEnablementService.isEnabled()) { + return null; + } + + giftEntryEnablementService.enable(); return null; } @@ -194,9 +210,4 @@ global with sharing class Callable_API implements System.Callable { // if the action does not return a value then return success return true; } - - private Boolean isAdvancedMappingEnabled(Data_Import_Settings__c dataImportSettings) { - return dataImportSettings.Field_Mapping_Method__c == BDI_MigrationMappingUtility.DATA_IMPORT_FIELD_MAPPING; - } - } diff --git a/force-app/main/default/classes/Callable_API_TEST.cls b/force-app/main/default/classes/Callable_API_TEST.cls index 3f13bef30d..c49b8a3cc6 100644 --- a/force-app/main/default/classes/Callable_API_TEST.cls +++ b/force-app/main/default/classes/Callable_API_TEST.cls @@ -121,16 +121,15 @@ private with sharing class Callable_API_TEST { @IsTest private static void shouldCallEnableAdvancedMappingOnAction() { + Callable_API callableApi = new Callable_API(); + AdvancedMappingEnablementServiceMock mappingServiceMock = new AdvancedMappingEnablementServiceMock(); + callableApi.advancedMappingEnablementService = stubFor(mappingServiceMock); Test.startTest(); - Callable_API callableApi = new Callable_API(); - AdvancedMappingEnablementServiceMock mappingServiceMock = new AdvancedMappingEnablementServiceMock(); - callableApi.advancedMappingEnablementService = stubFor(mappingServiceMock); - callableApi.call(ADVANCED_MAPPING_ACTION, null); Test.stopTest(); - System.assert(mappingServiceMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + + System.assert(mappingServiceMock.enableAdvancedMappingCalled, 'The enable advanced mapping service method ' + 'should be called.'); } @@ -149,10 +148,24 @@ private with sharing class Callable_API_TEST { callableApi.call(ADVANCED_MAPPING_ACTION, null); Test.stopTest(); - System.assert(!mappingServiceMock.enableDataImportMappingCalled, 'The enable advanced mapping controller method ' + + System.assert(!mappingServiceMock.enableAdvancedMappingCalled, 'The enable advanced mapping service method ' + 'should not be called.'); } + @IsTest + private static void shouldCallEnableGiftEntryOnAction() { + Callable_API callableApi = new Callable_API(); + GiftEntryEnablementServiceMock giftEntryEnablementServiceMock = new GiftEntryEnablementServiceMock(); + callableApi.giftEntryEnablementService = stubFor(giftEntryEnablementServiceMock); + + Test.startTest(); + callableApi.call(GIFT_ENTRY_ACTION, null); + Test.stopTest(); + + System.assert(giftEntryEnablementServiceMock.enableGiftEntryCalled, 'The enable gift entry service method ' + + 'should be called.'); + } + /** * @description Verifies if Enhanced Recurring Donations are enabled */ @@ -226,14 +239,47 @@ private with sharing class Callable_API_TEST { System.assertEquals(expectedErrorMessage, returnPause.error, 'An error with unexpected Id should be return'); } + private static GiftEntryEnablementService stubFor(GiftEntryEnablementServiceMock giftEntryEnablementServiceMock) { + return (GiftEntryEnablementService) Test.createStub( + GiftEntryEnablementService.class, giftEntryEnablementServiceMock); + } + private static AdvancedMappingEnablementService stubFor(AdvancedMappingEnablementServiceMock advancedMappingControllerMock) { return (AdvancedMappingEnablementService) Test.createStub( AdvancedMappingEnablementService.class, advancedMappingControllerMock); } + private class GiftEntryEnablementServiceMock implements StubProvider { + Boolean enableGiftEntryCalled = false; + Boolean isEnabled = false; + + private void setEnabled() { + isEnabled = true; + } + + public Object handleMethodCall( + Object stubbedObject, + String stubbedMethodName, + Type returnType, + List listOfParamTypes, + List listOfParamNames, + List listOfArgs) { + + switch on (stubbedMethodName) { + when 'enable' { + enableGiftEntryCalled = true; + } + when 'isEnabled' { + return UTIL_CustomSettingsFacade.getGiftEntrySettings().Enable_Gift_Entry__c; + } + } + return null; + } + } + private class AdvancedMappingEnablementServiceMock implements StubProvider { - Boolean enableDataImportMappingCalled = false; + Boolean enableAdvancedMappingCalled = false; public Object handleMethodCall( Object stubbedObject, @@ -244,8 +290,14 @@ private with sharing class Callable_API_TEST { List listOfArgs) { switch on (stubbedMethodName) { - when 'enableDataImportFieldMapping' { - enableDataImportMappingCalled = true; + when 'enable' { + enableAdvancedMappingCalled = true; + } + when 'isEnabled' { + Data_Import_Settings__c dataImportSettings = UTIL_CustomSettingsFacade.getDataImportSettings(); + + return dataImportSettings.Field_Mapping_Method__c == + BDI_MigrationMappingUtility.DATA_IMPORT_FIELD_MAPPING; } } return null; diff --git a/force-app/main/default/classes/GiftEntryEnablementService.cls b/force-app/main/default/classes/GiftEntryEnablementService.cls new file mode 100644 index 0000000000..89d3e4ed22 --- /dev/null +++ b/force-app/main/default/classes/GiftEntryEnablementService.cls @@ -0,0 +1,47 @@ +/* + Copyright (c) 2020, Salesforce.org + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Salesforce.org nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/** +* @author Salesforce.org +* @date 2021 +* @description Enablement Service for the Gift Entry feature +*/ +public with sharing class GiftEntryEnablementService { + + public Boolean isEnabled() { + return UTIL_CustomSettingsFacade.getGiftEntrySettings().Enable_Gift_Entry__c; + } + + public void enable() { + Gift_Entry_Settings__c giftEntrySettings = UTIL_CustomSettingsFacade.getGiftEntrySettings(); + giftEntrySettings.Enable_Gift_Entry__c = true; + + upsert giftEntrySettings; + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/GiftEntryEnablementService.cls-meta.xml b/force-app/main/default/classes/GiftEntryEnablementService.cls-meta.xml new file mode 100644 index 0000000000..f928c8e56b --- /dev/null +++ b/force-app/main/default/classes/GiftEntryEnablementService.cls-meta.xml @@ -0,0 +1,5 @@ + + + 53.0 + Active + diff --git a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls index 91b0bbc906..1615182b05 100644 --- a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls +++ b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls @@ -374,12 +374,10 @@ public with sharing class STG_PanelDataImportAdvancedMapping_CTRL extends STG_Pa * @return null */ public PageReference enableGiftEntry() { - Gift_Entry_Settings__c giftEntrySettings = - GE_GiftEntryController.getGiftEntrySettings(); - if (!giftEntrySettings.Enable_Gift_Entry__c) { - giftEntrySettings.Enable_Gift_Entry__c = true; + GiftEntryEnablementService giftEntryEnablementService = new GiftEntryEnablementService(); + if (!giftEntryEnablementService.isEnabled()) { try { - upsert giftEntrySettings; + giftEntryEnablementService.enable(); addPageMessage(ApexPages.Severity.CONFIRM, System.Label.geEnableGiftEntrySuccess); } catch(DmlException e) { addPageMessage(ApexPages.Severity.ERROR, From fb9c01425d89311967a55d8e759c014a6839cb78 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Mon, 31 Jan 2022 19:11:12 -0500 Subject: [PATCH 08/21] add managed and unmanaged options to YAML --- cumulusci.yml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/cumulusci.yml b/cumulusci.yml index aabfb77826..7bf246a9e7 100644 --- a/cumulusci.yml +++ b/cumulusci.yml @@ -938,6 +938,71 @@ flows: 2: task: update_admin_profile + enable_gift_entry_managed: + description: Enable the Gift Entry feature in a scratch org (managed package only) + group: NPSP + steps: + 1: + flow: enable_advanced_mapping_managed + 2: + task: execute_anon + options: + managed: true + unmanaged: false + apex: > + String namespace = ('%%%NAMESPACE%%%').replace('__',''); + Type t = Type.forName(namespace, 'Callable_Api'); + Callable apiClass = (Callable)t.newInstance(); + apiClass.call('settings.enablegiftentry', null); + + enable_gift_entry: + description: Enable the Gift Entry feature in a scratch org (unmanaged code only). + group: NPSP + steps: + 1: + flow: enable_advanced_mapping + 2: + task: execute_anon + options: + apex: > + String namespace = ('%%%NAMESPACE%%%').replace('__',''); + Type t = Type.forName(namespace, 'Callable_Api'); + Callable apiClass = (Callable)t.newInstance(); + apiClass.call('settings.enablegiftentry', null); + + enable_advanced_mapping_managed: + description: Enable the BDI Advanced Mapping feature (managed package only) + group: NPSP + steps: + 1: + flow: enable_advanced_mapping + options: + execute_anon: + managed: true + unmanaged: false + custom_settings_value_wait: + managed: true + unmanaged: false + + enable_advanced_mapping: + description: Enable the BDI Advanced Mapping feature (unmanaged code only). + group: NPSP + steps: + 1: + task: execute_anon + options: + apex: > + String namespace = ('%%%NAMESPACE%%%').replace('__',''); + Type t = Type.forName(namespace, 'Callable_Api'); + Callable apiClass = (Callable)t.newInstance(); + apiClass.call('settings.enableadvancedmapping', null); + 2: + task: custom_settings_value_wait + options: + object: "%%%NAMESPACE%%%Data_Import_Settings__c" + field: "%%%NAMESPACE%%%Field_Mapping_Method__c" + value: "Data Import Field Mapping" + enable_rd2: description: 'Fully configures and enables a Scratch org with Enhanced Recurring Donations (unmanaged code only)' group: NPSP From 497cd3ce179db309e44fdaac30b3b2730f5451bf Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Tue, 1 Feb 2022 10:10:12 -0500 Subject: [PATCH 09/21] add test for GE enablement service --- .../classes/GiftEntryEnablement_TEST.cls | 42 +++++++++++++++++++ .../GiftEntryEnablement_TEST.cls-meta.xml | 5 +++ 2 files changed, 47 insertions(+) create mode 100644 force-app/main/default/classes/GiftEntryEnablement_TEST.cls create mode 100644 force-app/main/default/classes/GiftEntryEnablement_TEST.cls-meta.xml diff --git a/force-app/main/default/classes/GiftEntryEnablement_TEST.cls b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls new file mode 100644 index 0000000000..f399693863 --- /dev/null +++ b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls @@ -0,0 +1,42 @@ +/* + Copyright (c) 2020, Salesforce.org + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Salesforce.org nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +@IsTest +private class GiftEntryEnablement_TEST { + + @IsTest + private static void enableShouldUpdateCustomSetting() { + GiftEntryEnablementService enablementService = new GiftEntryEnablementService(); + Test.startTest(); + enablementService.enable(); + Test.stopTest(); + + System.assert(enablementService.isEnabled(), 'Gift entry should be enabled'); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/GiftEntryEnablement_TEST.cls-meta.xml b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls-meta.xml new file mode 100644 index 0000000000..f928c8e56b --- /dev/null +++ b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls-meta.xml @@ -0,0 +1,5 @@ + + + 53.0 + Active + From 99377806c890741553871def31ebda06f6c40be5 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Tue, 1 Feb 2022 12:42:24 -0500 Subject: [PATCH 10/21] implement review feedback to update copyright info --- .../AdvancedMappingEnablementService.cls | 4 +-- .../AdvancedMappingEnablementService_TEST.cls | 29 +++++++++++++++++++ .../main/default/classes/Callable_API.cls | 2 +- .../classes/GiftEntryEnablementService.cls | 6 ++-- .../classes/GiftEntryEnablement_TEST.cls | 2 +- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/force-app/main/default/classes/AdvancedMappingEnablementService.cls b/force-app/main/default/classes/AdvancedMappingEnablementService.cls index f16c8ce262..3d382f992b 100644 --- a/force-app/main/default/classes/AdvancedMappingEnablementService.cls +++ b/force-app/main/default/classes/AdvancedMappingEnablementService.cls @@ -1,5 +1,5 @@ /* - Copyright (c) 2019, Salesforce.org + Copyright (c) 2022, Salesforce.org All rights reserved. Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ */ /** * @author: Salesforce.org - * @date: 2021 + * @date: 2022 * @description: Service to enable the advanced mapping feature */ public with sharing class AdvancedMappingEnablementService { diff --git a/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls b/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls index aeae339508..ab316753a3 100644 --- a/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls +++ b/force-app/main/default/classes/AdvancedMappingEnablementService_TEST.cls @@ -1,3 +1,32 @@ +/* + Copyright (c) 2022, Salesforce.org + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Salesforce.org nor the names of + its contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ @IsTest private class AdvancedMappingEnablementService_TEST { diff --git a/force-app/main/default/classes/Callable_API.cls b/force-app/main/default/classes/Callable_API.cls index a70ab8b665..50e754ba7a 100644 --- a/force-app/main/default/classes/Callable_API.cls +++ b/force-app/main/default/classes/Callable_API.cls @@ -186,7 +186,7 @@ global with sharing class Callable_API implements System.Callable { if (advancedMappingEnablementService.isEnabled()) { return null; } -+ + advancedMappingEnablementService.enable(); return null; diff --git a/force-app/main/default/classes/GiftEntryEnablementService.cls b/force-app/main/default/classes/GiftEntryEnablementService.cls index 89d3e4ed22..dd37e875c8 100644 --- a/force-app/main/default/classes/GiftEntryEnablementService.cls +++ b/force-app/main/default/classes/GiftEntryEnablementService.cls @@ -1,5 +1,5 @@ -/* - Copyright (c) 2020, Salesforce.org +/** + Copyright (c) 2022, Salesforce.org All rights reserved. Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ */ /** * @author Salesforce.org -* @date 2021 +* @date 2022 * @description Enablement Service for the Gift Entry feature */ public with sharing class GiftEntryEnablementService { diff --git a/force-app/main/default/classes/GiftEntryEnablement_TEST.cls b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls index f399693863..5ced4a5992 100644 --- a/force-app/main/default/classes/GiftEntryEnablement_TEST.cls +++ b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls @@ -1,5 +1,5 @@ /* - Copyright (c) 2020, Salesforce.org + Copyright (c) 2022, Salesforce.org All rights reserved. Redistribution and use in source and binary forms, with or without From f10e19397cb67cf1d85b83289171129d1cef9b20 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Tue, 1 Feb 2022 12:42:48 -0500 Subject: [PATCH 11/21] remove unnecessary code change --- .../classes/STG_PanelDataImportAdvancedMapping_CTRL.cls | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls index 1615182b05..93df8926ff 100644 --- a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls +++ b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls @@ -109,15 +109,11 @@ public with sharing class STG_PanelDataImportAdvancedMapping_CTRL extends STG_Pa /******************************************************************************************************* * @description is the running user an admin */ - @TestVisible public Boolean isAdmin { get { - if (isAdmin == null) { - isAdmin = STG_Panel.runningUserIsAdmin(); - } - return isAdmin; + return STG_Panel.runningUserIsAdmin(); } - private set; + set; } /******************************************************************************************************* From 9be34449ad7ccbe834d18b70fe52d0cb6fda41f1 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Tue, 1 Feb 2022 12:48:24 -0500 Subject: [PATCH 12/21] update yml and documentation descriptions --- cumulusci.yml | 4 ++-- documentation/automation.md | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cumulusci.yml b/cumulusci.yml index 7bf246a9e7..d2666c1218 100644 --- a/cumulusci.yml +++ b/cumulusci.yml @@ -939,7 +939,7 @@ flows: task: update_admin_profile enable_gift_entry_managed: - description: Enable the Gift Entry feature in a scratch org (managed package only) + description: Enable the Gift Entry feature (managed package only) group: NPSP steps: 1: @@ -956,7 +956,7 @@ flows: apiClass.call('settings.enablegiftentry', null); enable_gift_entry: - description: Enable the Gift Entry feature in a scratch org (unmanaged code only). + description: Enable the Gift Entry feature (unmanaged code only). group: NPSP steps: 1: diff --git a/documentation/automation.md b/documentation/automation.md index 29c794fbfb..b842a5e822 100644 --- a/documentation/automation.md +++ b/documentation/automation.md @@ -79,6 +79,20 @@ as well as many other features needed to define the workspace for the org's inte | `enable_crlp` | Task | Enable the NPSP Customizable Rollups feature (works for both Managed and Unmanaged) | | `enable_incremental_rollups` | Task | Configure NPSP Customizable Rollups to activate Incremental Rollups | +### Advanced Mapping + +| Name | Type | Description | +| ----------------------------- | ---- | -------------------------------------------------------------------------------------------- | +| `enable_advanced_mapping` | Flow | Enable the BDI Advanced Mapping feature (unmanaged code only). +| `enable_advanced_mapping_managed` | Flow | Enable the BDI Advanced Mapping feature (managed package only) + +### Gift Entry + +| Name | Type | Description | +| ----------------------------- | ---- | -------------------------------------------------------------------------------------------- | +| `enable_gift_entry` | Flow | Enable the Gift Entry feature (unmanaged code only). +| `enable_gift_entry_managed` | Flow | Enable the Gift Entry feature (managed package only) + ### Enhanced Recurring Donations | Name | Type | Description | From e8dbee8b6b57ecf41e1423f1ab83792759e10de3 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Tue, 1 Feb 2022 15:07:08 -0500 Subject: [PATCH 13/21] add exception if advanced mapping is not enabled --- .../classes/GiftEntryEnablementService.cls | 17 +++++++++++++++++ .../STG_PanelDataImportAdvancedMapping_CTRL.cls | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/force-app/main/default/classes/GiftEntryEnablementService.cls b/force-app/main/default/classes/GiftEntryEnablementService.cls index dd37e875c8..4d702b0cec 100644 --- a/force-app/main/default/classes/GiftEntryEnablementService.cls +++ b/force-app/main/default/classes/GiftEntryEnablementService.cls @@ -33,15 +33,32 @@ * @description Enablement Service for the Gift Entry feature */ public with sharing class GiftEntryEnablementService { + @TestVisible + private AdvancedMappingEnablementService advancedMappingEnablementService { + get { + if (advancedMappingEnablementService == null) { + advancedMappingEnablementService = new AdvancedMappingEnablementService(); + } + return advancedMappingEnablementService; + } + set; + } public Boolean isEnabled() { return UTIL_CustomSettingsFacade.getGiftEntrySettings().Enable_Gift_Entry__c; } public void enable() { + if (!advancedMappingEnablementService.isEnabled()) { + throw new GiftEntryEnablementException('Advanced mapping is not enabled. First enable advanced mapping ' + + 'before gift entry can be enabled.'); + } + Gift_Entry_Settings__c giftEntrySettings = UTIL_CustomSettingsFacade.getGiftEntrySettings(); giftEntrySettings.Enable_Gift_Entry__c = true; upsert giftEntrySettings; } + + private class GiftEntryEnablementException extends Exception {} } \ No newline at end of file diff --git a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls index 93df8926ff..80106f24d3 100644 --- a/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls +++ b/force-app/main/default/classes/STG_PanelDataImportAdvancedMapping_CTRL.cls @@ -375,9 +375,9 @@ public with sharing class STG_PanelDataImportAdvancedMapping_CTRL extends STG_Pa try { giftEntryEnablementService.enable(); addPageMessage(ApexPages.Severity.CONFIRM, System.Label.geEnableGiftEntrySuccess); - } catch(DmlException e) { + } catch(Exception e) { addPageMessage(ApexPages.Severity.ERROR, - e.getDmlMessage(0)); + e.getMessage()); } } return null; From 14824f56590b73bc9e3509607b405fbaaff74af6 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 2 Feb 2022 12:51:28 -0500 Subject: [PATCH 14/21] add additional callable test scenario and set enabled in stub --- .../default/classes/Callable_API_TEST.cls | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/force-app/main/default/classes/Callable_API_TEST.cls b/force-app/main/default/classes/Callable_API_TEST.cls index c49b8a3cc6..1c6fbb9632 100644 --- a/force-app/main/default/classes/Callable_API_TEST.cls +++ b/force-app/main/default/classes/Callable_API_TEST.cls @@ -135,13 +135,11 @@ private with sharing class Callable_API_TEST { @IsTest private static void shouldNotCallEnableAdvancedMappingIfMappingIsEnabled() { - Data_Import_Settings__c dataImportSettings = new Data_Import_Settings__c(); - dataImportSettings.Field_Mapping_Method__c = BDI_MigrationMappingUtility.DATA_IMPORT_FIELD_MAPPING; - UTIL_CustomSettingsFacade.setDataImportSettings(dataImportSettings); - Callable_API callableApi = new Callable_API(); AdvancedMappingEnablementServiceMock mappingServiceMock = new AdvancedMappingEnablementServiceMock(); + mappingServiceMock.setEnabled(); + callableApi.advancedMappingEnablementService = stubFor(mappingServiceMock); Test.startTest(); @@ -156,6 +154,7 @@ private with sharing class Callable_API_TEST { private static void shouldCallEnableGiftEntryOnAction() { Callable_API callableApi = new Callable_API(); GiftEntryEnablementServiceMock giftEntryEnablementServiceMock = new GiftEntryEnablementServiceMock(); + callableApi.giftEntryEnablementService = stubFor(giftEntryEnablementServiceMock); Test.startTest(); @@ -166,6 +165,22 @@ private with sharing class Callable_API_TEST { 'should be called.'); } + @IsTest + private static void shouldNotCallEnableGiftEntryIfAlreadyEnabled() { + GiftEntryEnablementServiceMock giftEntryEnablementServiceMock = new GiftEntryEnablementServiceMock(); + giftEntryEnablementServiceMock.setEnabled(); + + Callable_API callableApi = new Callable_API(); + callableApi.giftEntryEnablementService = stubFor(giftEntryEnablementServiceMock); + + Test.startTest(); + callableApi.call(ADVANCED_MAPPING_ACTION, null); + Test.stopTest(); + + System.assert(!giftEntryEnablementServiceMock.enableGiftEntryCalled, 'The enable gift entry service ' + + 'method should not be called.'); + } + /** * @description Verifies if Enhanced Recurring Donations are enabled */ @@ -254,7 +269,7 @@ private with sharing class Callable_API_TEST { Boolean enableGiftEntryCalled = false; Boolean isEnabled = false; - private void setEnabled() { + public void setEnabled() { isEnabled = true; } @@ -271,7 +286,7 @@ private with sharing class Callable_API_TEST { enableGiftEntryCalled = true; } when 'isEnabled' { - return UTIL_CustomSettingsFacade.getGiftEntrySettings().Enable_Gift_Entry__c; + return isEnabled; } } return null; @@ -280,6 +295,11 @@ private with sharing class Callable_API_TEST { private class AdvancedMappingEnablementServiceMock implements StubProvider { Boolean enableAdvancedMappingCalled = false; + Boolean isEnabled = false; + + public void setEnabled() { + isEnabled = true; + } public Object handleMethodCall( Object stubbedObject, @@ -294,10 +314,7 @@ private with sharing class Callable_API_TEST { enableAdvancedMappingCalled = true; } when 'isEnabled' { - Data_Import_Settings__c dataImportSettings = UTIL_CustomSettingsFacade.getDataImportSettings(); - - return dataImportSettings.Field_Mapping_Method__c == - BDI_MigrationMappingUtility.DATA_IMPORT_FIELD_MAPPING; + return isEnabled; } } return null; From 2ab48933d4ff247ea00d0a9f3c39e9ae676d95d3 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 2 Feb 2022 12:51:54 -0500 Subject: [PATCH 15/21] add new custom label for gift entry enablement exception --- .../main/default/classes/GiftEntryEnablementService.cls | 3 +-- .../main/default/labels/CustomLabels.labels-meta.xml | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/force-app/main/default/classes/GiftEntryEnablementService.cls b/force-app/main/default/classes/GiftEntryEnablementService.cls index 4d702b0cec..7f7792dc96 100644 --- a/force-app/main/default/classes/GiftEntryEnablementService.cls +++ b/force-app/main/default/classes/GiftEntryEnablementService.cls @@ -50,8 +50,7 @@ public with sharing class GiftEntryEnablementService { public void enable() { if (!advancedMappingEnablementService.isEnabled()) { - throw new GiftEntryEnablementException('Advanced mapping is not enabled. First enable advanced mapping ' + - 'before gift entry can be enabled.'); + throw new GiftEntryEnablementException(System.Label.geServiceLevelErrorAdvancedMapping); } Gift_Entry_Settings__c giftEntrySettings = UTIL_CustomSettingsFacade.getGiftEntrySettings(); diff --git a/force-app/main/default/labels/CustomLabels.labels-meta.xml b/force-app/main/default/labels/CustomLabels.labels-meta.xml index cd5558859c..e504e29d4e 100644 --- a/force-app/main/default/labels/CustomLabels.labels-meta.xml +++ b/force-app/main/default/labels/CustomLabels.labels-meta.xml @@ -8802,6 +8802,15 @@ If preferred, you can disable Gift Entry and instead use older Batch Gift Entry Page-level error message body when Advanced Mapping and Gift Entry are off This feature requires both Advanced Mapping and Gift Entry. Please enable them in NPSP Settings. + + geServiceLevelErrorAdvancedMapping + Gift Entry + en_US + true + Service-level error when the Gift Entry Enablement Service is called to + enable Gift Entry without first enabling Advanced Mapping + Advanced mapping is not enabled. First enable advanced mapping before gift entry can be enabled. + geErrorPageLevelAdvancedMappingHeader Gift Entry From 08ca82750f83115e2e09ebec14f72f566253ba45 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 2 Feb 2022 12:58:35 -0500 Subject: [PATCH 16/21] move advanced mapping service mock out into its own class since it will be used in multiple test classes --- .../AdvancedMappingEnablementServiceMock.cls | 63 +++++++++++++++++++ ...dMappingEnablementServiceMock.cls-meta.xml | 5 ++ .../default/classes/Callable_API_TEST.cls | 28 --------- 3 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls create mode 100644 force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls-meta.xml diff --git a/force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls b/force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls new file mode 100644 index 0000000000..87c61911e4 --- /dev/null +++ b/force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls @@ -0,0 +1,63 @@ +/* + * + * Copyright (c) 2022, Salesforce.org + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Salesforce.org nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * / + */ +/** +* @author Salesforce.org +* @date 2022 +* @description StubProvider mock for tests +*/ +public with sharing class AdvancedMappingEnablementServiceMock implements StubProvider { + public Boolean enableAdvancedMappingCalled = false; + public Boolean isEnabled = false; + + public void setEnabled() { + isEnabled = true; + } + + public Object handleMethodCall( + Object stubbedObject, + String stubbedMethodName, + Type returnType, + List listOfParamTypes, + List listOfParamNames, + List listOfArgs) { + + switch on (stubbedMethodName) { + when 'enable' { + enableAdvancedMappingCalled = true; + } + when 'isEnabled' { + return isEnabled; + } + } + return null; + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls-meta.xml b/force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls-meta.xml new file mode 100644 index 0000000000..f928c8e56b --- /dev/null +++ b/force-app/main/default/classes/AdvancedMappingEnablementServiceMock.cls-meta.xml @@ -0,0 +1,5 @@ + + + 53.0 + Active + diff --git a/force-app/main/default/classes/Callable_API_TEST.cls b/force-app/main/default/classes/Callable_API_TEST.cls index 1c6fbb9632..113fec396e 100644 --- a/force-app/main/default/classes/Callable_API_TEST.cls +++ b/force-app/main/default/classes/Callable_API_TEST.cls @@ -292,32 +292,4 @@ private with sharing class Callable_API_TEST { return null; } } - - private class AdvancedMappingEnablementServiceMock implements StubProvider { - Boolean enableAdvancedMappingCalled = false; - Boolean isEnabled = false; - - public void setEnabled() { - isEnabled = true; - } - - public Object handleMethodCall( - Object stubbedObject, - String stubbedMethodName, - Type returnType, - List listOfParamTypes, - List listOfParamNames, - List listOfArgs) { - - switch on (stubbedMethodName) { - when 'enable' { - enableAdvancedMappingCalled = true; - } - when 'isEnabled' { - return isEnabled; - } - } - return null; - } - } } From e14ab8c4904872fa6f190ae06a9ce47e20401f1f Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 2 Feb 2022 14:29:05 -0500 Subject: [PATCH 17/21] add custom label for gift entry enablement exception --- force-app/main/default/labels/CustomLabels.labels-meta.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/force-app/main/default/labels/CustomLabels.labels-meta.xml b/force-app/main/default/labels/CustomLabels.labels-meta.xml index e504e29d4e..b6b506c86e 100644 --- a/force-app/main/default/labels/CustomLabels.labels-meta.xml +++ b/force-app/main/default/labels/CustomLabels.labels-meta.xml @@ -8807,8 +8807,7 @@ If preferred, you can disable Gift Entry and instead use older Batch Gift Entry Gift Entry en_US true - Service-level error when the Gift Entry Enablement Service is called to - enable Gift Entry without first enabling Advanced Mapping + Service-level error message when advanced mapping is not enabled. Advanced mapping is not enabled. First enable advanced mapping before gift entry can be enabled. From c3fc415c5a0eae86c148c1cc343931514229fd00 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 2 Feb 2022 14:29:25 -0500 Subject: [PATCH 18/21] add exception for when advanced mapping is not enabled --- .../classes/GiftEntryEnablementService.cls | 2 +- .../classes/GiftEntryEnablement_TEST.cls | 36 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/force-app/main/default/classes/GiftEntryEnablementService.cls b/force-app/main/default/classes/GiftEntryEnablementService.cls index 7f7792dc96..93e3f051ee 100644 --- a/force-app/main/default/classes/GiftEntryEnablementService.cls +++ b/force-app/main/default/classes/GiftEntryEnablementService.cls @@ -59,5 +59,5 @@ public with sharing class GiftEntryEnablementService { upsert giftEntrySettings; } - private class GiftEntryEnablementException extends Exception {} + public class GiftEntryEnablementException extends Exception {} } \ No newline at end of file diff --git a/force-app/main/default/classes/GiftEntryEnablement_TEST.cls b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls index 5ced4a5992..74f035a9d9 100644 --- a/force-app/main/default/classes/GiftEntryEnablement_TEST.cls +++ b/force-app/main/default/classes/GiftEntryEnablement_TEST.cls @@ -32,11 +32,41 @@ private class GiftEntryEnablement_TEST { @IsTest private static void enableShouldUpdateCustomSetting() { - GiftEntryEnablementService enablementService = new GiftEntryEnablementService(); + GiftEntryEnablementService giftEntryEnablementService = new GiftEntryEnablementService(); + AdvancedMappingEnablementServiceMock advancedMappingEnablementServiceMock = new + AdvancedMappingEnablementServiceMock(); + advancedMappingEnablementServiceMock.setEnabled(); + + giftEntryEnablementService.advancedMappingEnablementService = (AdvancedMappingEnablementService)Test.createStub( + AdvancedMappingEnablementService.class, advancedMappingEnablementServiceMock); + + Test.startTest(); + giftEntryEnablementService.enable(); + Test.stopTest(); + + System.assert(giftEntryEnablementService.isEnabled(), 'Gift entry should be enabled'); + } + + @IsTest + private static void enableThrowsExceptionWhenMappingIsNotEnabled() { + GiftEntryEnablementService giftEntryEnablementService = new GiftEntryEnablementService(); + AdvancedMappingEnablementServiceMock advancedMappingEnablementServiceMock = new + AdvancedMappingEnablementServiceMock(); + + giftEntryEnablementService.advancedMappingEnablementService = (AdvancedMappingEnablementService)Test.createStub( + AdvancedMappingEnablementService.class, advancedMappingEnablementServiceMock); + + GiftEntryEnablementService.GiftEntryEnablementException enablementException; + Test.startTest(); - enablementService.enable(); + try { + giftEntryEnablementService.enable(); + } catch(GiftEntryEnablementService.GiftEntryEnablementException ex) { + enablementException = ex; + } Test.stopTest(); - System.assert(enablementService.isEnabled(), 'Gift entry should be enabled'); + System.assert(enablementException != null, 'An exception should be thrown when advanced mapping is not ' + + 'enabled.'); } } \ No newline at end of file From 1a229483c3c49af02d99a7717febe283b3420d13 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Wed, 2 Feb 2022 14:32:23 -0500 Subject: [PATCH 19/21] remove managed versions of the flows since namespace is automatically injected in managed contexts --- cumulusci.yml | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/cumulusci.yml b/cumulusci.yml index d2666c1218..8de7e28ca3 100644 --- a/cumulusci.yml +++ b/cumulusci.yml @@ -938,23 +938,6 @@ flows: 2: task: update_admin_profile - enable_gift_entry_managed: - description: Enable the Gift Entry feature (managed package only) - group: NPSP - steps: - 1: - flow: enable_advanced_mapping_managed - 2: - task: execute_anon - options: - managed: true - unmanaged: false - apex: > - String namespace = ('%%%NAMESPACE%%%').replace('__',''); - Type t = Type.forName(namespace, 'Callable_Api'); - Callable apiClass = (Callable)t.newInstance(); - apiClass.call('settings.enablegiftentry', null); - enable_gift_entry: description: Enable the Gift Entry feature (unmanaged code only). group: NPSP @@ -970,20 +953,6 @@ flows: Callable apiClass = (Callable)t.newInstance(); apiClass.call('settings.enablegiftentry', null); - enable_advanced_mapping_managed: - description: Enable the BDI Advanced Mapping feature (managed package only) - group: NPSP - steps: - 1: - flow: enable_advanced_mapping - options: - execute_anon: - managed: true - unmanaged: false - custom_settings_value_wait: - managed: true - unmanaged: false - enable_advanced_mapping: description: Enable the BDI Advanced Mapping feature (unmanaged code only). group: NPSP From badf110165d1f8451926d3a0290acbfbb11a0b7c Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Thu, 3 Feb 2022 11:46:34 -0500 Subject: [PATCH 20/21] update descriptions --- cumulusci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulusci.yml b/cumulusci.yml index 8de7e28ca3..c043ab44ed 100644 --- a/cumulusci.yml +++ b/cumulusci.yml @@ -939,7 +939,7 @@ flows: task: update_admin_profile enable_gift_entry: - description: Enable the Gift Entry feature (unmanaged code only). + description: Enable the Gift Entry feature. group: NPSP steps: 1: @@ -954,7 +954,7 @@ flows: apiClass.call('settings.enablegiftentry', null); enable_advanced_mapping: - description: Enable the BDI Advanced Mapping feature (unmanaged code only). + description: Enable the BDI Advanced Mapping feature. group: NPSP steps: 1: From da20a239466b75582d8fa1a1a9844717badeb106 Mon Sep 17 00:00:00 2001 From: Daniel Fuller Date: Thu, 3 Feb 2022 14:21:25 -0500 Subject: [PATCH 21/21] update custom label --- force-app/main/default/labels/CustomLabels.labels-meta.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/force-app/main/default/labels/CustomLabels.labels-meta.xml b/force-app/main/default/labels/CustomLabels.labels-meta.xml index b6b506c86e..cfa90af94d 100644 --- a/force-app/main/default/labels/CustomLabels.labels-meta.xml +++ b/force-app/main/default/labels/CustomLabels.labels-meta.xml @@ -8808,7 +8808,7 @@ If preferred, you can disable Gift Entry and instead use older Batch Gift Entry en_US true Service-level error message when advanced mapping is not enabled. - Advanced mapping is not enabled. First enable advanced mapping before gift entry can be enabled. + You must enable Advanced Mapping before you can enable Gift Entry. geErrorPageLevelAdvancedMappingHeader