Activity Forums Salesforce Questions and Answers How can we write a wrapper class in test class to create a json string in Salesforce?

  • How can we write a wrapper class in test class to create a json string in Salesforce?

  • Deepak

    Member
    December 4, 2019 at 2:17 pm

    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

    }

Viewing 1 - 2 of 2 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

How does Salesforce Field Service Platform increase servicing revenue for your company

Video in

CRM Salesforce, along with its Field Service Lightning App, is drastically improving the field-force productivity in the industry. Built on the Salesforce Service Cloud, it…