Add domain method to map the record Id to a grand-grand-...-parent record Id
This commit is contained in:
@@ -238,6 +238,34 @@ private class fflib_ArrayUtilsTest
|
||||
System.assertEquals(8, result, 'Did not return the last value in the list of objects');
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldReplaceValueInTheMap()
|
||||
{
|
||||
Id accountIdA = fflib_IDGenerator.generate(Schema.Account.SObjectType);
|
||||
Id accountIdB = fflib_IDGenerator.generate(Schema.Account.SObjectType);
|
||||
Id accountIdC = fflib_IDGenerator.generate(Schema.Account.SObjectType);
|
||||
Id contactIdA = fflib_IDGenerator.generate(Schema.Contact.SObjectType);
|
||||
Id contactIdB = fflib_IDGenerator.generate(Schema.Contact.SObjectType);
|
||||
Map<Id, Id> source = new Map<Id, Id>
|
||||
{
|
||||
accountIdA => contactIdA,
|
||||
accountIdB => contactIdB,
|
||||
accountIdC => fflib_IDGenerator.generate(Schema.Contact.SObjectType)
|
||||
};
|
||||
Map<Id, Id> replacement = new Map<Id, Id>
|
||||
{
|
||||
contactIdA => accountIdB,
|
||||
contactIdB => accountIdA
|
||||
};
|
||||
|
||||
Map<Id, Id> result = fflib_ArrayUtils.replaceValue(source, replacement);
|
||||
|
||||
System.assertEquals(3, result.size());
|
||||
System.assertEquals(accountIdB, result.get(accountIdA));
|
||||
System.assertEquals(accountIdA, result.get(accountIdB));
|
||||
System.assertEquals(null, result.get(accountIdC));
|
||||
}
|
||||
|
||||
@IsTest
|
||||
static void itShouldReturnAllValuesForTheGivenIds()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user