Skip to content

Commit

Permalink
Merge pull request #7276 from SalesforceFoundation/feature/256__W-175…
Browse files Browse the repository at this point in the history
…50754-Update-BDI_DataImportService_TEST

Update BDI_DataImportService_TEST to fix the issues with Platform Encryption enabled users
  • Loading branch information
daniel-fuller authored Jan 8, 2025
2 parents a8a24c7 + c162ceb commit c5fb4eb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
14 changes: 12 additions & 2 deletions force-app/main/default/classes/BDI_DataImportCTRL_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,18 @@ private with sharing class BDI_DataImportCTRL_TEST {
// should have matched
System.assertEquals(null,testDIResultA.FailureInformation__c);
System.assertEquals(BDI_DataImport_API.bdiDryRunValidated,testDIResultA.Status__c);
System.assertNotEquals(null,testDIResultA.Contact1Imported__c);
System.assertEquals(System.label.bdiDryRunMatched,testDIResultA.Contact1ImportStatus__c);
// Contact matching will not return an imported contact if contact name is encrypted
if (sObjectType.Contact.fields.Name.isEncrypted()) {
System.assertEquals(null,testDIResultA.Contact1Imported__c);
} else {
System.assertNotEquals(null,testDIResultA.Contact1Imported__c);
}
// Contact matching status will be 'no match' if contact name is encrypted
if (sObjectType.Contact.fields.Name.isEncrypted()) {
System.assertEquals(System.label.bdiDryRunNoMatch,testDIResultA.Contact1ImportStatus__c);
} else {
System.assertEquals(System.label.bdiDryRunMatched,testDIResultA.Contact1ImportStatus__c);
}
System.assertEquals(null,testDIResultA.DonationImported__c);
System.assertEquals(null,testDIResultA.DonationImportStatus__c);

Expand Down
23 changes: 17 additions & 6 deletions force-app/main/default/classes/BDI_DataImportService_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ private with sharing class BDI_DataImportService_TEST {
accounts.add(acc);
}
insert accounts;

// Store Account IDs for assertion
Set<Id> createdAccountIds = new Set<Id>();
for (Account acc : accounts) {
createdAccountIds.add(acc.Id);
}

// Create Contacts to ensure matching
List<Contact> contacts = new List<Contact>();
Expand All @@ -342,6 +348,11 @@ private with sharing class BDI_DataImportService_TEST {
}
insert contacts;

// Store Contact IDs for assertion
Set<Id> createdContactIds = new Set<Id>();
for (Contact con : contacts) {
createdContactIds.add(con.Id);
}
// Assign created contact IDs to the data import records
for (Integer i = 0; i < 5; i++) {
testDataImportss[i].Contact1Imported__c = contacts[i*2].Id;
Expand Down Expand Up @@ -370,12 +381,12 @@ private with sharing class BDI_DataImportService_TEST {
service.importAccounts();
Test.stopTest();

// Add assertions to verify the Account and Contact records were created/updated as expected
List<Account> accounts1 = [SELECT Id, Name, Phone FROM Account WHERE Name LIKE 'Test Account%'];
System.assert(accounts1.size() > 0, 'Accounts should be created');
List<Contact> contactList = [SELECT Id, FirstName, LastName, Email FROM Contact WHERE LastName LIKE 'LastName%'];
System.assert(contactList.size() > 0, 'Contacts should be created');
// Assertions using IDs
List<Account> fetchedAccounts = [SELECT Id, Name FROM Account WHERE Id IN :createdAccountIds];
System.assertEquals(createdAccountIds.size(), fetchedAccounts.size(), 'Accounts should be created and fetched using Ids');

List<Contact> fetchedContacts = [SELECT Id, FirstName, LastName, Email FROM Contact WHERE Id IN :createdContactIds];
System.assertEquals(createdContactIds.size(), fetchedContacts.size(), 'Contacts should be created and fetched using Ids');
}

// Helpers
Expand Down

0 comments on commit c5fb4eb

Please sign in to comment.