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

Update BDI_DataImportService_TEST to fix the issues with Platform Encryption enabled users #7276

Merged
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 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
Loading