1

I'm using Partner WSDL in my org and generated an APEX class (WSDL2Apex) to connect my org with another salesforce environment.

Have anyone done such earlier and if written the test class for its code coverage and help me with that here.

//Generated by wsdl2apex

public class vPartnerSoapSforceCom {
    public class InvalidateSessionsResult {
        public vPartnerSoapSforceCom.Error[] errors;
        public Boolean success;
        private String[] errors_type_info = new String[]{'errors','urn:partner.soap.sforce.com',null,'0','-1','false'};
        private String[] success_type_info = new String[]{'success','urn:partner.soap.sforce.com',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:partner.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'errors','success'};
    }
    public class describePrimaryCompactLayoutsResponse_element {
        public vPartnerSoapSforceCom.DescribeCompactLayout[] result;
        private String[] result_type_info = new String[]{'result','urn:partner.soap.sforce.com',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:partner.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'result'};
    }
    public class DescribeAppMenuResult {
        public vPartnerSoapSforceCom.DescribeAppMenuItem[] appMenuItems;
        private String[] appMenuItems_type_info = new String[]{'appMenuItems','urn:partner.soap.sforce.com',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:partner.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'appMenuItems'};
    }
    public class DescribeColor {
        public String color;
        public String context;
  • This is just a few lines of around 4000 lines of APEX code generated.

As the Partner WSDL is not tightly bound to the organisation and will remain same for anyone for a particular release. Here I'm looking for someone who has done the same and can share his test class as that will definitely work for me.

..

Additionally I'm aware of mockups and if no one has already worked on such test class earlier I'll write my own and share the code with the community so someone will get benefited in future.

1

Use mock callouts by either implementing an interface or using static resources. Mock callouts allow you to specify the response to return in the test instead of actually calling the web service.The Test.setMock method informs the runtime that mock callouts are used in the test method. For examples please refer trailhead badge Apex Integration Services:Apex REST Callouts. Here is the link : https://trailhead.salesforce.com/apex_integration_services/apex_integration_rest_callouts

  • Hi, Pragati! Thank You for the response. I'm aware of the mockup creation and I'm here looking for any test class implemented by someone already on salesforce partner WSDL. – Nishant Singh Panwar Jan 20 '17 at 7:44
3

I made a alternative version of WSDL2Apex that can also generate the test classes for coverage and the Mock. You can get it via the FuseIT SFDC Explorer for free (Disclaimer: This is from my current employer)

See also Dreamforce 2014 Presentation - Improved Apex support for SOAP based web services

2

You will have to use a Mock class. You can find the documentation about it here.

You can write a mock method for each method included in your wsdl.

  • Hi, Martin! Thank You for the response. I'm aware of the mockup creation and I'm here looking for any test class implemented by someone already on salesforce partner WSDL. – Nishant Singh Panwar Jan 20 '17 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.