function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brad007Brad007 

Test class for Apex class generated from WSDL.

Hi, I have a WSDL generated Apex class which i am using to perform apex callouts. I did not realize it requires a test class When i am trying to deploy my code to production my code percentage was screwed due to this WSDL Apex class which is huge. It has code which is out of my understanding as it is automatically generated by salesfroce. How would i able to write the test class, is there a way to by pass this. Any suggestions would be greatly appreciative. Thank you,
Aravind SriramAravind Sriram

Writing test class for Class generated from WSDL doesn't required much understanding of the class logic. You just create a instance for the inner class and call the methods of the class. That's it.

BijayBijay

Hi Aravind Srivam,

 

Could you please be more specific.:

 

Here is my WSDL@APEX Class:

 

//Generated by wsdl2apex

public class invokeCustomerManagement {
          public class AuditReq {
        public String callingApplication;
        public String callingArea;
        public String userId;
        private String[] callingApplication_type_info = new String[]{'callingApplication','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] callingArea_type_info = new String[]{'callingArea','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] userId_type_info = new String[]{'userId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'callingApplication','callingArea','userId'};
    }
         public class CreateRelationshipRequest {
        public String customerId1;
        public String customerId2;
        public String relationshipNature;
        public invokeCustomerManagement.Audit audit;
        private String[] customerId1_type_info = new String[]{'customerId1','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] customerId2_type_info = new String[]{'customerId2','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] relationshipNature_type_info = new String[]{'relationshipNature','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] audit_type_info = new String[]{'audit','http://managementservices.profile.custmgmt.crm.crom.sf/','Audit','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customerId1','customerId2','relationshipNature','audit'};
    }
           public class createAgentRelationshipRes {
        public invokeCustomerManagement.CreateAgentRelationshipResponse customer;
        private String[] customer_type_info = new String[]{'customer','http://managementservices.profile.custmgmt.crm.crom.sf/','CreateAgentRelationshipResponse','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customer'};
    }
    public class createCustomerRes {
        public invokeCustomerManagement.CreateCustomerResponse customer;
        private String[] customer_type_info = new String[]{'customer','http://managementservices.profile.custmgmt.crm.crom.sf/','CreateCustomerResponse','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customer'};
    }
    public class CustomerManagementPort {
        public String endpoint_x = 'http://localhost:9043/CustomerManagementV2.1';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/', 'invokeCustomerManagement'};
        public invokeCustomerManagement.CreateCustomerResponse createCustomer(invokeCustomerManagement.CreateCustomerRequest customer) {
            invokeCustomerManagement.createCustomer request_x = new invokeCustomerManagement.createCustomer();
            invokeCustomerManagement.createCustomerRes response_x;
            request_x.customer = customer;
            Map<String, invokeCustomerManagement.createCustomerRes> response_map_x = new Map<String, invokeCustomerManagement.createCustomerRes>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'createCustomer',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'createCustomerRes',
              'invokeCustomerManagement.createCustomerRes'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.customer;
        }
        public invokeCustomerManagement.CreateRelationshipResponse createRelationship(invokeCustomerManagement.CreateRelationshipRequest customer) {
            invokeCustomerManagement.createRelationship request_x = new invokeCustomerManagement.createRelationship();
            invokeCustomerManagement.createRelationshipRes response_x;
            request_x.customer = customer;
            Map<String, invokeCustomerManagement.createRelationshipRes> response_map_x = new Map<String, invokeCustomerManagement.createRelationshipRes>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'createRelationship',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'createRelationshipRes',
              'invokeCustomerManagement.createRelationshipRes'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.customer;
        }
        public invokeCustomerManagement.UpdateCustomerResponse updateCustomer(invokeCustomerManagement.UpdateCustomerRequest customer) {
            invokeCustomerManagement.updateCustomer request_x = new invokeCustomerManagement.updateCustomer();
            invokeCustomerManagement.updateCustomerRes response_x;
            request_x.customer = customer;
            Map<String, invokeCustomerManagement.updateCustomerRes> response_map_x = new Map<String, invokeCustomerManagement.updateCustomerRes>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'updateCustomer',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'updateCustomerRes',
              'invokeCustomerManagement.updateCustomerRes'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.customer;
        }
        public invokeCustomerManagement.CreateAgentRelationshipResponse createAgentRelationship(invokeCustomerManagement.CreateAgentRelationshipRequest customer) {
            invokeCustomerManagement.createAgentRelationship request_x = new invokeCustomerManagement.createAgentRelationship();
            invokeCustomerManagement.createAgentRelationshipRes response_x;
            request_x.customer = customer;
            Map<String, invokeCustomerManagement.createAgentRelationshipRes> response_map_x = new Map<String, invokeCustomerManagement.createAgentRelationshipRes>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'createAgentRelationship',
              'http://managementservices.profile.custmgmt.crm.crom.sf/',
              'createAgentRelationshipRes',
              'invokeCustomerManagement.createAgentRelationshipRes'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.customer;
        }
    }
    public class UnexpectedServiceExcption {
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class Agent {
        public String associateID;
        private String[] associateID_type_info = new String[]{'associateID','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'associateID'};
    }
    public class updateCustomer {
        public invokeCustomerManagement.UpdateCustomerRequest customer;
        private String[] customer_type_info = new String[]{'customer','http://managementservices.profile.custmgmt.crm.crom.sf/','UpdateCustomerRequest','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customer'};
    }
    public class CreateRelationshipResponse {
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class NameReq {
        public String prefix;
        public String firstName;
        public String preferredFirst;
        public String middleName;
        public String lastName;
        public String suffix;
        public String designation;
        private String[] prefix_type_info = new String[]{'prefix','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] firstName_type_info = new String[]{'firstName','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] preferredFirst_type_info = new String[]{'preferredFirst','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] middleName_type_info = new String[]{'middleName','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] lastName_type_info = new String[]{'lastName','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] suffix_type_info = new String[]{'suffix','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] designation_type_info = new String[]{'designation','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'prefix','firstName','preferredFirst','middleName','lastName','suffix','designation'};
    }
    public class CreateAgentRelationshipRequest {
        public String customerId;
        public String customerType;
        public invokeCustomerManagement.Agent agent;
        public invokeCustomerManagement.Audit audit;
        private String[] customerId_type_info = new String[]{'customerId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] customerType_type_info = new String[]{'customerType','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] agent_type_info = new String[]{'agent','http://managementservices.profile.custmgmt.crm.crom.sf/','Agent','1','1','false'};
        private String[] audit_type_info = new String[]{'audit','http://managementservices.profile.custmgmt.crm.crom.sf/','Audit','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customerId','customerType','agent','audit'};
    }
    public class Audit {
        public String userId;
        public String callingApplication;
        public String callingArea;
        private String[] userId_type_info = new String[]{'userId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] callingApplication_type_info = new String[]{'callingApplication','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] callingArea_type_info = new String[]{'callingArea','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'userId','callingApplication','callingArea'};
    }
    public class createRelationship {
        public invokeCustomerManagement.CreateRelationshipRequest customer;
        private String[] customer_type_info = new String[]{'customer','http://managementservices.profile.custmgmt.crm.crom.sf/','CreateRelationshipRequest','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customer'};
    }
    public class CreateCustomerResponse {
        public String customerId;
        public String nameId;
        public String addressId;
        public String careOfAddressId;
        private String[] customerId_type_info = new String[]{'customerId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] nameId_type_info = new String[]{'nameId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] addressId_type_info = new String[]{'addressId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] careOfAddressId_type_info = new String[]{'careOfAddressId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customerId','nameId','addressId','careOfAddressId'};
    }
    public class createRelationshipRes {
        public invokeCustomerManagement.CreateRelationshipResponse customer;
        private String[] customer_type_info = new String[]{'customer','http://managementservices.profile.custmgmt.crm.crom.sf/','CreateRelationshipResponse','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://managementservices.profile.custmgmt.crm.crom.sf/','false','false'};
        private String[] field_order_type_info = new String[]{'customer'};
    }
      }

 

How to make it hundred percent  coverage.