diff --git a/force-app/main/default/classes/BDI_DataImportCTRL_TEST.cls b/force-app/main/default/classes/BDI_DataImportCTRL_TEST.cls index 3c6477404b..b2ee7a5519 100644 --- a/force-app/main/default/classes/BDI_DataImportCTRL_TEST.cls +++ b/force-app/main/default/classes/BDI_DataImportCTRL_TEST.cls @@ -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); diff --git a/force-app/main/default/classes/BDI_DataImportService_TEST.cls b/force-app/main/default/classes/BDI_DataImportService_TEST.cls index 7936a983da..de284a0fbc 100644 --- a/force-app/main/default/classes/BDI_DataImportService_TEST.cls +++ b/force-app/main/default/classes/BDI_DataImportService_TEST.cls @@ -321,6 +321,12 @@ private with sharing class BDI_DataImportService_TEST { accounts.add(acc); } insert accounts; + + // Store Account IDs for assertion + Set createdAccountIds = new Set(); + for (Account acc : accounts) { + createdAccountIds.add(acc.Id); + } // Create Contacts to ensure matching List contacts = new List(); @@ -342,6 +348,11 @@ private with sharing class BDI_DataImportService_TEST { } insert contacts; + // Store Contact IDs for assertion + Set createdContactIds = new Set(); + 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; @@ -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 accounts1 = [SELECT Id, Name, Phone FROM Account WHERE Name LIKE 'Test Account%']; - System.assert(accounts1.size() > 0, 'Accounts should be created'); - - List 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 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 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