Activity Forums Salesforce® Discussions How can we write a wrapper class in test class to create a json string in Salesforce?

  • Nikita

    Member
    December 5, 2019 at 6:06 am

    Hi,

    Here is an example that will explain how to write a unit tests for a wrapper class.

    wrapper:

    public class submitPsOSimpleServiceDetailWrapper{
    public string providerId{get;set;}
    public string patientId{get;set;}
    public string productId{get;set;}
    public PsOSimpleWrapper.PaitentInformationWrapper patientDetails{get;set;}

    }

    public class PsOSimpleWrapper{
    public class PaitentInformationWrapper{
    public string PatientfirstName {get;set;}
    public string PatientMI {get;set;}
    public string PatientlastName {get;set;}

    }
    }

    test class code:

    public static testmethod void Test_1(){

    string psosimplejson='{"providerId":"","patientId":"","productId":"","patientDetails":[patientDetails: {"PatientfirstName":"","PatientMI":"","PatientlastName":"","PatientdateOfBirth":""}]}';

    string str= PsOSimpleServiceController.savePaitentInformation(psosimplejson);
    //have covered all the wrappers in test class

    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos