+ Start a Discussion
iyappan kandasamy 4iyappan kandasamy 4 

test class- need urgent

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 as it is urgent. Thanks in advance.