Skip to content

Commit

Permalink
DLRS v2.1 - v2.3 - Lookup Rollup Calculate Jobs not Case-sensitive
Browse files Browse the repository at this point in the history
#3
47
  • Loading branch information
Andrew Fawcett authored and Andrew Fawcett committed Jan 4, 2017
1 parent a15fb4f commit b6b1913
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
20 changes: 14 additions & 6 deletions rolluptool/src/classes/RollupService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,7 @@ global with sharing class RollupService
RollupSummary lookup = lookups[0];

// Already running?
try {
// This object has a unique constraint over LookupRollupSummaryId__c
insert new LookupRollupCalculateJob__c(LookupRollupSummaryId__c = lookupId);
} catch (Exception e) {
throw RollupServiceException.jobAlreadyRunning(lookup.Name);
}
checkJobAlreadyRunning(lookupId, lookup.Name);

// Already active?
if((lookup.Active==null || lookup.Active==false) && lookup.CalculationMode=='Realtime' )
Expand Down Expand Up @@ -564,6 +559,19 @@ global with sharing class RollupService
CustomMetadataService.deleteMetadata(LookupRollupSummary2__mdt.getSObjectType(), rollupSummaryIds);
}

/**
* Throws RollupServiceException if the Calculate Job is already running for the given lookup
**/
@TestVisible
private static void checkJobAlreadyRunning(String lookupId, String lookupName) {
try {
// This object has a unique constraint over LookupRollupSummaryId__c
insert new LookupRollupCalculateJob__c(LookupRollupSummaryId__c = (String) ((Id)lookupId));
} catch (Exception e) {
throw RollupServiceException.jobAlreadyRunning(lookupName);
}
}

/**
* Validates records (currenyly only Custom Metadata based ones)
**/
Expand Down
13 changes: 12 additions & 1 deletion rolluptool/src/classes/RollupServiceTest3.cls
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ private with sharing class RollupServiceTest3
ACCOUNT_SLA_EXPIRATION_DATE = describe.getField('SLAExpirationDate__c');
ACCOUNT_NUMBER_OF_LOCATIONS = describe.getField('NumberOfLocations__c');
}


/**
* https://github.com/afawcett/declarative-lookup-rollup-summaries/issues/347
**/
private testmethod static void testCalculateJobWithRollupIdsVaryingOnlyByCase()
{
String rollupA = LookupRollupSummary__c.SObjectType.getDescribe().getKeyPrefix() + 'A00000000000';
String rollupB = LookupRollupSummary__c.SObjectType.getDescribe().getKeyPrefix() + 'a00000000000';
RollupService.checkJobAlreadyRunning(rollupA, 'Rollup A');
RollupService.checkJobAlreadyRunning(rollupB, 'Rollup B');
}

private testmethod static void testCalculateJob()
{
// Test supported?
Expand Down

0 comments on commit b6b1913

Please sign in to comment.