+ Start a Discussion
iyappan kandasamy 4iyappan kandasamy 4 

Testing Apex class

Actually this is the controller class and the help I need is how to write the test class for the below code.

Orginal Apex controller code:
--------------------------------------
private String addressValidation(Contact con, boolean showApexErroMsg){
            boolean errorExist = false;
            String addrs_Error_Message = '';
            String errorMsgFullString = '';
   
            if (!AddressService.isValidationResultValid(con.Other_Address_Validation_Status__c, con.Other_Address_Validation_Timestamp__c))
            {
                addrs_Error_Message += ' Ship To Address, ';
                errorExist = true;
            }

        if (!AddressService.isValidationResultValid(con.Mailing_Address_Validation_Status__c, con.Mailing_Address_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Sold To Address, ';
            errorExist = true;
        }

        if (!AddressService.isValidationResultValid(con.Other_Address2_Validation_Status__c, con.Other_Address2_Validation_Timestamp__c))
        {
            addrs_Error_Message += ' Bill To Address ';
            errorExist = true;
        }

        if(String.isNotBlank(addrs_Error_Message)){
            errorMsgFullString = con.name+' has an non-validated '+addrs_Error_Message+'. Please go to the Contact page for '+con.name +' and validate the address.';
            if(showApexErroMsg)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,errorMsgFullString));

        }
        system.debug('----addressValidation Result ----'+errorExist);
        return errorMsgFullString;
    }

Need test class for the above code.
Please do the needful. Thanks in advance
DheerajKumar@SalesforceDheerajKumar@Salesforce
Hi,

Could you provide below details to complete the test class.

1. AddressService.isValidationResultValid method implementation.
2. Field type for below field.
    a. Mailing_Address_Validation_Status__c, Mailing_Address_Validation_Timestamp__c
    b. Other_Address2_Validation_Status__c, Other_Address2_Validation_Timestamp__c
    c. Other_Address_Validation_Status__c, Other_Address_Validation_Timestamp__c

Thanks
Dheeraj Kumar