Skip to content

Commit a397ef6

Browse files
Merge c5fb4eb into feature/performance-tests
2 parents c67fdf8 + c5fb4eb commit a397ef6

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

force-app/main/default/classes/BDI_DataImportCTRL_TEST.cls

+12-2
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,18 @@ private with sharing class BDI_DataImportCTRL_TEST {
300300
// should have matched
301301
System.assertEquals(null,testDIResultA.FailureInformation__c);
302302
System.assertEquals(BDI_DataImport_API.bdiDryRunValidated,testDIResultA.Status__c);
303-
System.assertNotEquals(null,testDIResultA.Contact1Imported__c);
304-
System.assertEquals(System.label.bdiDryRunMatched,testDIResultA.Contact1ImportStatus__c);
303+
// Contact matching will not return an imported contact if contact name is encrypted
304+
if (sObjectType.Contact.fields.Name.isEncrypted()) {
305+
System.assertEquals(null,testDIResultA.Contact1Imported__c);
306+
} else {
307+
System.assertNotEquals(null,testDIResultA.Contact1Imported__c);
308+
}
309+
// Contact matching status will be 'no match' if contact name is encrypted
310+
if (sObjectType.Contact.fields.Name.isEncrypted()) {
311+
System.assertEquals(System.label.bdiDryRunNoMatch,testDIResultA.Contact1ImportStatus__c);
312+
} else {
313+
System.assertEquals(System.label.bdiDryRunMatched,testDIResultA.Contact1ImportStatus__c);
314+
}
305315
System.assertEquals(null,testDIResultA.DonationImported__c);
306316
System.assertEquals(null,testDIResultA.DonationImportStatus__c);
307317

force-app/main/default/classes/BDI_DataImportService_TEST.cls

+17-6
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ private with sharing class BDI_DataImportService_TEST {
321321
accounts.add(acc);
322322
}
323323
insert accounts;
324+
325+
// Store Account IDs for assertion
326+
Set<Id> createdAccountIds = new Set<Id>();
327+
for (Account acc : accounts) {
328+
createdAccountIds.add(acc.Id);
329+
}
324330

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

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

373-
// Add assertions to verify the Account and Contact records were created/updated as expected
374-
List<Account> accounts1 = [SELECT Id, Name, Phone FROM Account WHERE Name LIKE 'Test Account%'];
375-
System.assert(accounts1.size() > 0, 'Accounts should be created');
376-
377-
List<Contact> contactList = [SELECT Id, FirstName, LastName, Email FROM Contact WHERE LastName LIKE 'LastName%'];
378-
System.assert(contactList.size() > 0, 'Contacts should be created');
384+
// Assertions using IDs
385+
List<Account> fetchedAccounts = [SELECT Id, Name FROM Account WHERE Id IN :createdAccountIds];
386+
System.assertEquals(createdAccountIds.size(), fetchedAccounts.size(), 'Accounts should be created and fetched using Ids');
387+
388+
List<Contact> fetchedContacts = [SELECT Id, FirstName, LastName, Email FROM Contact WHERE Id IN :createdContactIds];
389+
System.assertEquals(createdContactIds.size(), fetchedContacts.size(), 'Contacts should be created and fetched using Ids');
379390
}
380391

381392
// Helpers

0 commit comments

Comments
 (0)