diff --git a/dlrs/main/classes/RollupController.cls b/dlrs/main/classes/RollupController.cls index ca05a24f..2eebad87 100644 --- a/dlrs/main/classes/RollupController.cls +++ b/dlrs/main/classes/RollupController.cls @@ -28,7 +28,8 @@ * Handles the Manage Trigger and Calculate Custom Buttons **/ public with sharing class RollupController { - public static String DEF_API_VERSION = '58.0'; + @TestVisible + private static String FALLBACK_COMPONENT_API_VERSION = '58.0'; public String ZipData { get; set; } @@ -59,10 +60,12 @@ public with sharing class RollupController { public ApexClass RollupParentTriggerTest { get; private set; } public Integer deployCount; - public String apiVersion; public Boolean MetadataConnectionError { get; set; } + @TestVisible + private String componentApiVersion; + public RollupController(ApexPages.StandardController standardController) { // Query Lookup Rollup Summary record this( @@ -101,7 +104,7 @@ public with sharing class RollupController { return '' + '' + '' + - apiVersion + + componentApiVersion + '' + ''; else @@ -135,7 +138,7 @@ public with sharing class RollupController { '') : '') + '' + - apiVersion + + componentApiVersion + '' + ''; } @@ -170,7 +173,7 @@ public with sharing class RollupController { '') : '') + '' + - apiVersion + + componentApiVersion + '' + ''; } @@ -183,7 +186,7 @@ public with sharing class RollupController { return '' + '' + '' + - apiVersion + + componentApiVersion + '' + 'Active' + ''; @@ -228,7 +231,7 @@ public with sharing class RollupController { return '' + '' + '' + - apiVersion + + componentApiVersion + '' + 'Active' + ''; @@ -269,7 +272,7 @@ public with sharing class RollupController { return '' + '' + '' + - apiVersion + + componentApiVersion + '' + 'Active' + ''; @@ -316,7 +319,7 @@ public with sharing class RollupController { return '' + '' + '' + - apiVersion + + componentApiVersion + '' + 'Active' + ''; @@ -493,7 +496,7 @@ public with sharing class RollupController { ); return; } - apiVersion = getNewestApiVersion(); + componentApiVersion = getNewestApiVersion(); // Already deployed? Set triggerNames = new Set{ RollupTriggerName }; @@ -602,11 +605,11 @@ public with sharing class RollupController { Http http = new Http(); HTTPResponse res = http.send(req); if (res.getStatusCode() != 200) { - return DEF_API_VERSION; + return FALLBACK_COMPONENT_API_VERSION; } String body = res.getBody(); List data = (List) JSON.deserializeUntyped(body); - Decimal maxVersion = Decimal.valueOf(DEF_API_VERSION); + Decimal maxVersion = Decimal.valueOf(FALLBACK_COMPONENT_API_VERSION); for (Object obj : data) { Map apiV = (Map) obj; Decimal newV = Decimal.valueOf((String) apiV.get('version')); @@ -616,7 +619,8 @@ public with sharing class RollupController { } return String.valueOf(maxVersion); } catch (Exception e) { - return DEF_API_VERSION; + System.debug(e); + return FALLBACK_COMPONENT_API_VERSION; } } diff --git a/dlrs/main/classes/RollupControllerTest.cls b/dlrs/main/classes/RollupControllerTest.cls index 56235f7e..d22f553b 100644 --- a/dlrs/main/classes/RollupControllerTest.cls +++ b/dlrs/main/classes/RollupControllerTest.cls @@ -95,7 +95,7 @@ private class RollupControllerTest { '' + '' + '' + - controller.apiVersion + + controller.componentApiVersion + '' + '', controller.getPackageXml() @@ -116,7 +116,7 @@ private class RollupControllerTest { 'ApexClass' + '' + '' + - controller.apiVersion + + controller.componentApiVersion + '' + '', controller.getDestructiveChangesXml() @@ -125,7 +125,7 @@ private class RollupControllerTest { '' + '' + '' + - controller.apiVersion + + controller.componentApiVersion + '' + 'Active' + '', @@ -135,7 +135,7 @@ private class RollupControllerTest { '' + '' + '' + - controller.apiVersion + + controller.componentApiVersion + '' + 'Active' + '', @@ -262,7 +262,7 @@ private class RollupControllerTest { 'ApexClass' + '' + '' + - controller.apiVersion + + controller.componentApiVersion + '' + '', controller.getPackageXml() @@ -271,7 +271,7 @@ private class RollupControllerTest { '' + '' + '' + - controller.apiVersion + + controller.componentApiVersion + '' + 'Active' + '', @@ -281,7 +281,7 @@ private class RollupControllerTest { '' + '' + '' + - controller.apiVersion + + controller.componentApiVersion + '' + 'Active' + '', @@ -460,7 +460,7 @@ private class RollupControllerTest { new RollupSummary(rollupSummary) ); Test.stopTest(); - Assert.areEqual('97.0', controller.apiVersion); + Assert.areEqual('97.0', controller.componentApiVersion); } } @@ -492,7 +492,10 @@ private class RollupControllerTest { new RollupSummary(rollupSummary) ); Test.stopTest(); - Assert.areEqual(RollupController.DEF_API_VERSION, controller.apiVersion); + Assert.areEqual( + RollupController.FALLBACK_COMPONENT_API_VERSION, + controller.componentApiVersion + ); } } @@ -524,7 +527,10 @@ private class RollupControllerTest { new RollupSummary(rollupSummary) ); Test.stopTest(); - Assert.areEqual(RollupController.DEF_API_VERSION, controller.apiVersion); + Assert.areEqual( + RollupController.FALLBACK_COMPONENT_API_VERSION, + controller.componentApiVersion + ); } }