Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #258 and issue #278 - Space/Tab tokens and multiple BR/token su… #279

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions rolluptool/src/classes/LREngine.cls
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ public class LREngine {
return masterRecordsMap.values();
}

private final static Map<Pattern, String> delimiterTokens = new Map<Pattern, String> {
Pattern.compile('BR\\(\\)') => '\n'
, Pattern.compile('SP\\(\\)') => ' '
, Pattern.compile('TB\\(\\)') => '\t'
};

/**
* Concatenates strings (removes duplicates)
**/
Expand All @@ -319,8 +325,12 @@ public class LREngine {

public Concatenator(Boolean distinct, String delimiter) {
this.distinct = distinct;
if(delimiter!=null)
this.delimiter = delimiter.equals('BR()') ? '\n' : delimiter;
if(delimiter!=null) {
for (Pattern p : delimiterTokens.keySet()) {
delimiter = p.matcher(delimiter).replaceAll((String)delimiterTokens.get(p));
}
this.delimiter = delimiter;
}
setOfStrings = new Set<String>();
listOfString = new List<String>();
}
Expand Down
112 changes: 111 additions & 1 deletion rolluptool/src/classes/TestLREngine.cls
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,117 @@ private class TestLREngine {
LREngine.RollupOperation.Concatenate, 'BR()'),
'test\ntest\ntest',
'Lost\nWon\nWon');
}
}

static testMethod void testRollupConcatenateMultipleBR() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, 'BR()BR()BR()'),
'test\n\n\ntest\n\n\ntest',
'Lost\n\n\nWon\n\n\nWon');
}

static testMethod void testRollupConcatenateCommaBR() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, ',BR()'),
'test,\ntest,\ntest',
'Lost,\nWon,\nWon');
}

static testMethod void testRollupConcatenateSP() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, 'SP()'),
'test test test',
'Lost Won Won');
}

static testMethod void testRollupConcatenateMultipleSP() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, 'SP()SP()SP()'),
'test test test',
'Lost Won Won');
}

static testMethod void testRollupConcatenateCommaSP() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, ',SP()'),
'test, test, test',
'Lost, Won, Won');
}

static testMethod void testRollupConcatenateTB() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, 'TB()'),
'test\ttest\ttest',
'Lost\tWon\tWon');
}

static testMethod void testRollupConcatenateMultipleTB() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, 'TB()TB()TB()'),
'test\t\t\ttest\t\t\ttest',
'Lost\t\t\tWon\t\t\tWon');
}

static testMethod void testRollupConcatenateCommaTB() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, ',TB()'),
'test,\ttest,\ttest',
'Lost,\tWon,\tWon');
}

static testMethod void testRollupConcatenateAllTokens() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, 'TB()BR()SP()'),
'test\t\n test\t\n test',
'Lost\t\n Won\t\n Won');
}

static testMethod void testRollupConcatenateCommaAllTokens() {
testRollup(
Schema.SObjectType.Opportunity.fields.StageName.getName(),
new LREngine.RollupSummaryField(
Schema.SObjectType.Account.fields.Description,
Schema.SObjectType.Opportunity.fields.StageName,
LREngine.RollupOperation.Concatenate, ',TB()BR()SP()'),
'test,\t\n test,\t\n test',
'Lost,\t\n Won,\t\n Won');
}

static testMethod void testRollupConcatenateOrderBy() {
testRollup(
Expand Down