Skip to content

Commit

Permalink
Code review feedback from @jongpie
Browse files Browse the repository at this point in the history
  • Loading branch information
jamessimone committed Nov 1, 2024
1 parent a367835 commit 0577d6e
Show file tree
Hide file tree
Showing 33 changed files with 292 additions and 291 deletions.
2 changes: 1 addition & 1 deletion extra-tests/classes/RollupCalcItemSorterTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private class RollupCalcItemSorterTests {
new Opportunity(StageName = 'One')
};

itemsToSort.sort(new RollupCalcItemSorter(new List<String>{ Opportunity.Name.getDescribe().getName(), Opportunity.StageName.getDescribe().getName() }));
itemsToSort.sort(new RollupCalcItemSorter(new List<String>{ Opportunity.Name.toString(), Opportunity.StageName.toString() }));

System.assertEquals(null, itemsToSort.get(0).StageName);
System.assertEquals('One', itemsToSort.get(1).StageName);
Expand Down
2 changes: 1 addition & 1 deletion extra-tests/classes/RollupCurrencyInfoTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private class RollupCurrencyInfoTests {
);
List<OpportunityLineItem> olis = new List<OpportunityLineItem>{ oliToUpdate };

RollupCurrencyInfo.overrideDatedMultiCurrency(olis.getSObjectType().getDescribe().getName(), new List<String>{ 'Opportunity', 'CloseDate' });
RollupCurrencyInfo.overrideDatedMultiCurrency(olis.getSObjectType().toString(), new List<String>{ 'Opportunity', 'CloseDate' });
RollupCurrencyInfo.transform(olis, OpportunityLineItem.TotalPrice, eurPeriodOne.IsoCode, new List<RollupOrderBy__mdt>());

OpportunityLineItem oli = (OpportunityLineItem) RollupCurrencyInfo.getCalcItem(oliToUpdate, eurPeriodOne.IsoCode);
Expand Down
2 changes: 1 addition & 1 deletion extra-tests/classes/RollupEvaluatorTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ private class RollupEvaluatorTests {

@IsTest
static void pascalCaseForFieldNamesIsNotRequired() {
String poorlyCasedFieldName = Opportunity.IsClosed.getDescribe().getName().toLowerCase();
String poorlyCasedFieldName = Opportunity.IsClosed.toString().toLowerCase();

Opportunity isClosedFalse = (Opportunity) JSON.deserialize('{ "IsClosed": false }', Opportunity.class);
OpportunityLineItem target = new OpportunityLineItem(Opportunity = isClosedFalse);
Expand Down
4 changes: 2 additions & 2 deletions extra-tests/classes/RollupFlowFullRecalcTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ private class RollupFlowFullRecalcTests {
List<Rollup.FlowInput> flowInputs = RollupTestUtils.prepareFlowTest(apps, 'REFRESH', 'SUM');
flowInputs[0].ultimateParentLookup = 'ParentId';
flowInputs[0].rollupToUltimateParent = true;
flowInputs[0].lookupFieldOnCalcItem = Application__c.ParentApplication__c.getDescribe().getName();
flowInputs[0].rollupFieldOnCalcItem = Application__c.Engagement_Score__c.getDescribe().getName();
flowInputs[0].lookupFieldOnCalcItem = Application__c.ParentApplication__c.toString();
flowInputs[0].rollupFieldOnCalcItem = Application__c.Engagement_Score__c.toString();
flowInputs[0].grandparentRelationshipFieldPath = RollupTestUtils.getRelationshipPath(
new List<Schema.SObjectField>{ Application__c.ParentApplication__c, ParentApplication__c.Account__c, Account.AnnualRevenue }
);
Expand Down
26 changes: 13 additions & 13 deletions extra-tests/classes/RollupFullRecalcTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ private class RollupFullRecalcTests {

List<Rollup__mdt> metadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = Application__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
CalcItem__c = Application__c.SObjectType.toString(),
LookupObject__c = 'Account',
RollupToUltimateParent__c = true,
LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.toString(),
UltimateParentLookup__c = 'ParentId',
RollupOperation__c = 'SUM',
RollupFieldOnLookupObject__c = 'AnnualRevenue',
RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.getDescribe().getName(),
RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.toString(),
LookupFieldOnLookupObject__c = 'Id',
GrandparentRelationshipFieldPath__c = RollupTestUtils.getRelationshipPath(
new List<Schema.SObjectField>{ Application__c.ParentApplication__c, ParentApplication__c.Account__c, Account.AnnualRevenue }
Expand Down Expand Up @@ -168,12 +168,12 @@ private class RollupFullRecalcTests {

List<Rollup__mdt> metadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = Application__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
CalcItem__c = Application__c.SObjectType.toString(),
LookupObject__c = 'Individual',
LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = Application__c.ParentApplication__c.toString(),
RollupOperation__c = 'SUM',
RollupFieldOnLookupObject__c = 'ConsumerCreditScore',
RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.getDescribe().getName(),
RollupFieldOnCalcItem__c = Application__c.Engagement_Score__c.toString(),
LookupFieldOnLookupObject__c = 'Id',
GrandparentRelationshipFieldPath__c = String.valueOf(Application__c.ParentApplication__c).replace('__r', '__c') +
'.' +
Expand Down Expand Up @@ -939,7 +939,7 @@ private class RollupFullRecalcTests {
System.assertEquals(
'Completed',
[
SELECT Status, ApexClass.Name
SELECT Status
FROM AsyncApexJob
WHERE JobType = 'Queueable' AND ApexClass.Name = :getNamespaceSafeClassName(RollupFullBatchRecalculator.class)
LIMIT 1
Expand Down Expand Up @@ -1207,12 +1207,12 @@ private class RollupFullRecalcTests {

List<Rollup__mdt> metas = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = RollupChild__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
RollupFieldOnCalcItem__c = RollupChild__c.NumberField__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = RollupChild__c.RollupParent__c.getDescribe().getName(),
LookupObject__c = RollupGrandparent__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
LookupFieldOnLookupObject__c = RollupGrandparent__c.Id.getDescribe().getName(),
RollupFieldOnLookupObject__c = RollupGrandparent__c.AmountFromChildren__c.getDescribe().getName(),
CalcItem__c = RollupChild__c.SObjectType.toString(),
RollupFieldOnCalcItem__c = RollupChild__c.NumberField__c.toString(),
LookupFieldOnCalcItem__c = RollupChild__c.RollupParent__c.toString(),
LookupObject__c = RollupGrandparent__c.SObjectType.toString(),
LookupFieldOnLookupObject__c = RollupGrandparent__c.Id.toString(),
RollupFieldOnLookupObject__c = RollupGrandparent__c.AmountFromChildren__c.toString(),
RollupOperation__c = 'SUM',
CalcItemWhereClause__c = ' ||| ' +
RollupTestUtils.getRelationshipPath(
Expand Down
68 changes: 32 additions & 36 deletions extra-tests/classes/RollupIntegrationTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ private class RollupIntegrationTests {
new Rollup__mdt(
RollupFieldOnCalcItem__c = 'Amount',
LookupObject__c = 'Account',
LookupFieldOnCalcItem__c = Opportunity.AccountIdText__c.getDescribe().getName(),
LookupFieldOnLookupObject__c = Account.AccountIdText__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = Opportunity.AccountIdText__c.toString(),
LookupFieldOnLookupObject__c = Account.AccountIdText__c.toString(),
RollupFieldOnLookupObject__c = 'AnnualRevenue',
RollupOperation__c = 'MAX',
CalcItem__c = 'Opportunity'
Expand Down Expand Up @@ -68,7 +68,7 @@ private class RollupIntegrationTests {

Rollup.rollupMetadata = new List<Rollup__mdt>{
new Rollup__mdt(
RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.getDescribe().getName(),
RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.toString(),
LookupObject__c = 'Account',
LookupFieldOnCalcItem__c = 'AccountId',
LookupFieldOnLookupObject__c = 'Id',
Expand Down Expand Up @@ -150,19 +150,15 @@ private class RollupIntegrationTests {
Rollup.records = applications;

Rollup.FlowInput input = new Rollup.FlowInput();
input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.getDescribe().getName();
input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.toString();
input.lookupFieldOnOpObject = 'Id';
input.recordsToRollup = applications;
input.rollupContext = 'INSERT';
input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.getDescribe().getName();
input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.getDescribe().getName();
input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.toString();
input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.toString();
input.rollupOperation = 'AVERAGE';
input.rollupSObjectName = ParentApplication__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName();
input.calcItemWhereClause =
Application__c.Something_With_Underscores__c.getDescribe().getName() +
' != \'' +
applications[0].Something_With_Underscores__c +
'\'';
input.rollupSObjectName = ParentApplication__c.SObjectType.toString();
input.calcItemWhereClause = Application__c.Something_With_Underscores__c.toString() + ' != \'' + applications[0].Something_With_Underscores__c + '\'';

Test.startTest();
Rollup.performRollup(new List<Rollup.FlowInput>{ input });
Expand All @@ -188,16 +184,16 @@ private class RollupIntegrationTests {
insert apps;

Rollup.FlowInput input = new Rollup.FlowInput();
input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.getDescribe().getName();
input.lookupFieldOnCalcItem = Application__c.ParentApplication__c.toString();
input.lookupFieldOnOpObject = 'Id';
input.recordsToRollup = new List<ParentApplication__c>{ parentApp };
input.rollupContext = 'INSERT';
input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.getDescribe().getName();
input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.getDescribe().getName();
input.rollupFieldOnCalcItem = Application__c.Engagement_Score__c.toString();
input.rollupFieldOnOpObject = ParentApplication__c.Engagement_Rollup__c.toString();
input.rollupOperation = 'SUM';
input.rollupSObjectName = ParentApplication__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName();
input.rollupSObjectName = ParentApplication__c.SObjectType.toString();
input.isRollupStartedFromParent = true;
input.calcItemTypeWhenRollupStartedFromParent = Application__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName();
input.calcItemTypeWhenRollupStartedFromParent = Application__c.SObjectType.toString();

Test.startTest();
Rollup.performRollup(new List<Rollup.FlowInput>{ input });
Expand Down Expand Up @@ -283,9 +279,9 @@ private class RollupIntegrationTests {
Rollup.records = appLogs;
Rollup.rollupMetadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
RollupFieldOnCalcItem__c = ApplicationLog__c.Object__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(),
CalcItem__c = ApplicationLog__c.SObjectType.toString(),
RollupFieldOnCalcItem__c = ApplicationLog__c.Object__c.toString(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(),
LookupObject__c = 'Account',
LookupFieldOnLookupObject__c = 'Id',
RollupFieldOnLookupObject__c = 'Name',
Expand Down Expand Up @@ -411,9 +407,9 @@ private class RollupIntegrationTests {
Rollup.shouldFlattenAsyncProcesses = true;
Rollup.rollupMetadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
CalcItem__c = ApplicationLog__c.SObjectType.toString(),
RollupFieldOnCalcItem__c = 'Name',
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(),
LookupObject__c = 'Account',
LookupFieldOnLookupObject__c = 'Id',
RollupFieldOnLookupObject__c = 'Name',
Expand Down Expand Up @@ -464,9 +460,9 @@ private class RollupIntegrationTests {
Rollup.shouldFlattenAsyncProcesses = true;
Rollup.rollupMetadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
CalcItem__c = ApplicationLog__c.SObjectType.toString(),
RollupFieldOnCalcItem__c = 'Name',
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(),
LookupObject__c = 'Account',
LookupFieldOnLookupObject__c = 'Id',
RollupFieldOnLookupObject__c = 'Name',
Expand Down Expand Up @@ -534,9 +530,9 @@ private class RollupIntegrationTests {

Rollup.rollupMetadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
CalcItem__c = ApplicationLog__c.SObjectType.toString(),
RollupFieldOnCalcItem__c = 'Name',
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(),
LookupObject__c = 'Account',
LookupFieldOnLookupObject__c = 'Id',
RollupFieldOnLookupObject__c = 'Name',
Expand Down Expand Up @@ -584,9 +580,9 @@ private class RollupIntegrationTests {
Rollup.shouldRun = true;
Rollup.FlowInput input = new Rollup.FlowInput();
input.recordsToRollup = parentApps;
input.calcItemTypeWhenRollupStartedFromParent = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName();
input.rollupFieldOnCalcItem = ApplicationLog__c.Name.getDescribe().getName();
input.lookupFieldOnCalcItem = ApplicationLog__c.Application__c.getDescribe().getName();
input.calcItemTypeWhenRollupStartedFromParent = ApplicationLog__c.SObjectType.toString();
input.rollupFieldOnCalcItem = ApplicationLog__c.Name.toString();
input.lookupFieldOnCalcItem = ApplicationLog__c.Application__c.toString();
input.rollupSObjectName = 'Account';
input.lookupFieldOnOpObject = 'Id';
input.rollupFieldOnOpObject = 'Name';
Expand Down Expand Up @@ -638,9 +634,9 @@ private class RollupIntegrationTests {
Rollup.records = appLogs;
Rollup.rollupMetadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = ApplicationLog__c.getSObjectType().getDescribe().getName(),
RollupFieldOnCalcItem__c = ApplicationLog__c.Name.getDescribe().getName(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(),
CalcItem__c = ApplicationLog__c.getSObjectType().toString(),
RollupFieldOnCalcItem__c = ApplicationLog__c.Name.toString(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(),
LookupObject__c = 'Account',
LookupFieldOnLookupObject__c = 'Id',
RollupFieldOnLookupObject__c = 'Name',
Expand Down Expand Up @@ -683,9 +679,9 @@ private class RollupIntegrationTests {
Rollup.shouldFlattenAsyncProcesses = true;
Rollup.rollupMetadata = new List<Rollup__mdt>{
new Rollup__mdt(
CalcItem__c = ApplicationLog__c.SObjectType.getDescribe(SObjectDescribeOptions.DEFERRED).getName(),
CalcItem__c = ApplicationLog__c.SObjectType.toString(),
RollupFieldOnCalcItem__c = 'Name',
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.getDescribe().getName(),
LookupFieldOnCalcItem__c = ApplicationLog__c.Application__c.toString(),
LookupObject__c = 'Account',
LookupFieldOnLookupObject__c = 'Id',
RollupFieldOnLookupObject__c = 'AnnualRevenue',
Expand Down Expand Up @@ -925,7 +921,7 @@ private class RollupIntegrationTests {
null,
new Rollup__mdt(
RollupOperation__c = Rollup.Op.UPDATE_CONCAT_DISTINCT.name(),
RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.getDescribe().getName(),
RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.toString(),
LookupFieldOnCalcItem__c = 'AccountId'
),
new Map<Id, SObject>(),
Expand All @@ -940,7 +936,7 @@ private class RollupIntegrationTests {
null,
new Rollup__mdt(
RollupOperation__c = Rollup.Op.UPDATE_CONCAT_DISTINCT.name(),
RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.getDescribe().getName(),
RollupFieldOnCalcItem__c = Opportunity.AmountFormula__c.toString(),
LookupFieldOnCalcItem__c = 'AccountId'
),
new Map<Id, SObject>(),
Expand Down
8 changes: 4 additions & 4 deletions extra-tests/classes/RollupQueryBuilderTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private class RollupQueryBuilderTests {
String queryString = RollupQueryBuilder.Current.getQuery(
Event.SObjectType,
new List<String>{ 'Subject', 'WhatId' },
Event.WhatId.getDescribe().getName(),
Event.WhatId.toString(),
'!=',
'(((What.Type = \'Account\') AND What.Owner.Id = :recordIds))'
);
Expand All @@ -81,7 +81,7 @@ private class RollupQueryBuilderTests {
String queryString = RollupQueryBuilder.Current.getQuery(
Event.SObjectType,
new List<String>{ 'Subject', 'WhatId' },
Event.WhatId.getDescribe().getName(),
Event.WhatId.toString(),
'!=',
'(((What.Type = \'Account\') OR What.Owner.Id = :recordIds))'
);
Expand All @@ -98,7 +98,7 @@ private class RollupQueryBuilderTests {
String queryString = RollupQueryBuilder.Current.getQuery(
Opportunity.SObjectType,
new List<String>{ 'Amount' },
Opportunity.AccountId.getDescribe().getName(),
Opportunity.AccountId.toString(),
'=',
'Amount > 0 OR CloseDate = YESTERDAY'
);
Expand All @@ -108,7 +108,7 @@ private class RollupQueryBuilderTests {
@IsTest
static void correctlyPutsAllRowsAtEnd() {
String queryString =
RollupQueryBuilder.Current.getQuery(Event.SObjectType, new List<String>{ 'Subject', 'WhatId' }, Event.WhatId.getDescribe().getName(), '!=') + '\nLIMIT 1';
RollupQueryBuilder.Current.getQuery(Event.SObjectType, new List<String>{ 'Subject', 'WhatId' }, Event.WhatId.toString(), '!=') + '\nLIMIT 1';
System.assertEquals(true, queryString.contains(RollupQueryBuilder.ALL_ROWS), 'Needs to have all rows in order to be valid');

queryString = RollupQueryBuilder.Current.getAllRowSafeQuery(Event.SObjectType, queryString);
Expand Down
Loading

0 comments on commit 0577d6e

Please sign in to comment.