-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 295de0a into feature/248__localization
- Loading branch information
Showing
3 changed files
with
79 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,24 +5,53 @@ private with sharing class PotentialDuplicates_TEST { | |
private static void shouldReturnNullWhenNoDuplicatesAreFound() { | ||
Id recordId = UTIL_UnitTestData_TEST.mockId(Contact.getSObjectType()); | ||
Map<String, Object> data = PotentialDuplicates.getDuplicates(recordId); | ||
System.assertEquals('', data.get('setOfMatches'), | ||
'There should be no duplicates'); | ||
String setOfMatches = (String) data.get('setOfMatches'); | ||
|
||
List<DuplicateRule> activeContactRules = [ | ||
SELECT Id | ||
from DuplicateRule | ||
WHERE SObjectType = 'Contact' | ||
AND isActive = TRUE | ||
]; | ||
|
||
if (activeContactRules.isEmpty()) { | ||
System.assertEquals(null, setOfMatches, | ||
'PotentialDuplicates.getDuplicates() should return null if there are no active Duplicate Rules for Contact'); | ||
} else { | ||
System.assertEquals('', setOfMatches, 'There should be no duplicates'); | ||
} | ||
} | ||
|
||
@IsTest | ||
private static void shouldReturnIdsWhenDuplicatesAreFound() { | ||
List<Contact> contactList = UTIL_UnitTestData_TEST.getContacts(3); | ||
for(Contact c : contactList) { | ||
for (Contact c : contactList) { | ||
c.FirstName = 'Test'; | ||
c.LastName = 'LastName'; | ||
c.Email = '[email protected]'; | ||
} | ||
insert contactList; | ||
|
||
List<DuplicateRule> activeContactRules = [ | ||
SELECT Id | ||
from DuplicateRule | ||
WHERE SObjectType = 'Contact' | ||
AND isActive = TRUE | ||
]; | ||
|
||
Map<String, Object> data = PotentialDuplicates.getDuplicates(contactList[0].Id); | ||
String setOfMatches = (String)data.get('setOfMatches'); | ||
System.assertNotEquals('', setOfMatches, 'Duplicate Ids should be returned'); | ||
Integer numberOfMatches = setOfMatches.split(',').size(); | ||
System.assertEquals(2, numberOfMatches, 'There should be 2 duplicates returned'); | ||
String setOfMatches = (String) data.get('setOfMatches'); | ||
|
||
if (activeContactRules.isEmpty()) { | ||
System.assertEquals(null, setOfMatches, | ||
'PotentialDuplicates.getDuplicates() should return null if there are no active Duplicate Rules for Contact'); | ||
} else if (sObjectType.Contact.fields.Name.isEncrypted()) { | ||
// Duplicates will not be found if encryption is enabled / standard rules deactivated | ||
System.assertEquals('', setOfMatches, 'No duplicate Ids should be returned if encryption is enabled'); | ||
} else { | ||
Integer numberOfMatches = setOfMatches.split(',').size(); | ||
System.assertNotEquals('', setOfMatches, 'Duplicate Ids should be returned'); | ||
System.assertEquals(2, numberOfMatches, 'There should be 2 duplicates returned'); | ||
} | ||
} | ||
} |