diff --git a/force-app/main/default/classes/RLLP_OppRollup_TEST2.cls b/force-app/main/default/classes/RLLP_OppRollup_TEST2.cls index 5903297951..c0db7dea76 100644 --- a/force-app/main/default/classes/RLLP_OppRollup_TEST2.cls +++ b/force-app/main/default/classes/RLLP_OppRollup_TEST2.cls @@ -405,6 +405,7 @@ public with sharing class RLLP_OppRollup_TEST2 { npe01__Enable_Opportunity_Contact_Role_Trigger__c = true, npe01__Opportunity_Contact_Role_Default_role__c = CAO_Constants.OCR_DONOR_ROLE )); + //exercise internal multicurrency helper methods, check currency conversion decimal d = UTIL_CurrencyConversion.convertFromCorporateUsingStandardRates('USD', 55.00); d = UTIL_CurrencyConversion.convertAmountUsingStandardRates('USD', 'USD', 55.00); @@ -439,6 +440,29 @@ public with sharing class RLLP_OppRollup_TEST2 { // UNDONE: THERE ARE NO ASSERTS!!!! } + + /********************************************************************************************************* + * @description For new Falcon instances, an aggregate query that returns no results is not returning an empty + * list but is returning a single record where the properties are null. This tests that scenario. + */ + @IsTest + static void getISOCodeWithNullRollupFieldSetDoesNotThrowException() { + if (!UTIL_Currency.getInstance().isMultiCurrencyOrganization()) { + return; + } + + List opportunitiesWithRollupFieldSets = [SELECT MAX(npo02__CombinedRollupFieldset__c) RollupFieldSet + FROM Opportunity + WHERE Id != NULL]; + Exception findCurrencyISOException; + try { + RLLP_OppRollup_UTIL.rcfFindCurrency(opportunitiesWithRollupFieldSets); + } catch (Exception ex) { + findCurrencyISOException = ex; + } + System.assertEquals(null, findCurrencyISOException, 'Retrieving the ISO codes for opportunities with define ' + + 'rollup field sets populated should not throw an exception when the rollup field set is null.'); + } /********************************************************************************************************* * @description Runs testRollupAlls test method for the One to One account processor. */ diff --git a/force-app/main/default/classes/RLLP_OppRollup_UTIL.cls b/force-app/main/default/classes/RLLP_OppRollup_UTIL.cls index 5a72b1b5b7..2102a86fbe 100644 --- a/force-app/main/default/classes/RLLP_OppRollup_UTIL.cls +++ b/force-app/main/default/classes/RLLP_OppRollup_UTIL.cls @@ -364,9 +364,10 @@ public without sharing class RLLP_OppRollup_UTIL { //iterate over objects provided to us for (sobject r : objectList){ //pull Id from rollup field and add to set - string[] rcf = ((string)(r.get('RollupFieldset'))).split(';\\|;',-4); - if(rcf.size() > 1 && rcf[1] != '') - opptysForCurrency.add((Id)rcf[4]); + List rollupFieldSet = ((String)(r.get('RollupFieldset')))?.split(';\\|;',-4); + if (rollupFieldSet?.size() > 1 && rollupFieldSet?.get(1) != '') { + opptysForCurrency.add((Id)rollupFieldSet[4]); + } } if (!objectlist.isEmpty()){