• #66016
    Salesforce | Deepak Deepak #4
    Forcetalks

    Can we write a wrapper class in test class to create a json string?

    Can we write a wrapper class in test class to create a json string?

    #66025
    Salesforce | Nikita Nikita #2
    Forcetalks

    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 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?