Apex: customer360CommunicationsHelperTest

PHOTO EMBED

Tue Jan 16 2024 10:36:50 GMT+0000 (Coordinated Universal Time)

Saved by @FloLiman

@isTest
public class customer360CommunicationsHelperTest {
    @isTest
    static void getCaseAccountContactTest(){
        
        //Creating a test Account
        Account testAccount = new Account(
            Name = 'Test Account'
        );
        insert testAccount;
        
        //Creating a test Individual 
        Individual testIndividual = new Individual (
        	FirstName = 'Test',
            LastName = 'Individual',
            HasOptedOutSolicit = false
        );
        insert testIndividual;
        
        //Creating a test Contact and assigning the Individual to the Contact
        Contact testContact = new Contact(
            FirstName = 'Test',
            LastName = 'Contact',
            Email = 'TestEmail@hotmail.com',
            AlternativeBillingName__c = 'Test Billing Name',
            ContactPreferences__c = 'Email',
            PreferredCommunicationFormat__c = 'Standard',
            IndividualId = testIndividual.Id
        );
        insert testContact;
        
        //Associating the test Case to the Account and Contact
        Case testCase = new Case(
            Subject = 'Test Case',
            AccountId = testAccount.Id,
            ContactId = testContact.Id
        );
        insert testCase;
        
        List<Id> caseId = new List<Id>{testCase.Id};
        
        Test.startTest();
        List<Map<String, String>> result = customer360CommunicationsHelper.getCaseAccountContact(caseId);
        Test.stopTest();
        
        Map<String, String> resultMap = result[0];
        
        System.assertEquals('Test Account', resultMap.get('AccountName'));
        System.assertEquals(testAccount.Id, resultMap.get('AccountId'));
        System.assertEquals(testContact.Id, resultMap.get('ContactId'));
    }

}
content_copyCOPY