1

I have written a test class for the apex class.I am not able to cover the following portion .can you help me out. thanks in advance

Apex Class:

//Generated by wsdl2apex

public class miarchitectureGecmcGeComFileutilses1 {
    public class wmMessagesType {
        public String wmstatus;
        public String wmmessage;
        private String[] wmstatus_type_info = new String[]{'wmstatus','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] wmmessage_type_info = new String[]{'wmmessage','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'wmstatus','wmmessage'};
    }
    public class wsOpFileGetResponse {
        public miarchitectureGecmcGeComFileutilses1.FileRetrieveResponse FileRetrieveResponse;
        private String[] FileRetrieveResponse_type_info = new String[]{'FileRetrieveResponse','http://miarchitecture.gecmc.ge.com/FileUtilsEs','FileRetrieveResponse','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'FileRetrieveResponse'};
    }
    public class wsOpFilePersistResponse {
        public miarchitectureGecmcGeComFileutilses1.FilePersistResponse FilePersistResponse;
        private String[] FilePersistResponse_type_info = new String[]{'FilePersistResponse','http://miarchitecture.gecmc.ge.com/FileUtilsEs','FilePersistResponse','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'FilePersistResponse'};
    }
    public class wsOpFileGet {
        public miarchitectureGecmcGeComFileutilses1.FileRetrieveRequest FileRetrieveRequest;
        private String[] FileRetrieveRequest_type_info = new String[]{'FileRetrieveRequest','http://miarchitecture.gecmc.ge.com/FileUtilsEs','FileRetrieveRequest','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'FileRetrieveRequest'};
    }
    public class FileRetrieveRequest {
        public miarchitectureGecmcGeComFileutilses1.metaType MetaType;
        public miarchitectureGecmcGeComFileutilses1.fileSchemaType FileObject;
        public String SESSION_ID;
        public String ENTERPRISE_URL;
        private String[] MetaType_type_info = new String[]{'MetaType','http://miarchitecture.gecmc.ge.com/FileUtilsEs','metaType','1','1','true'};
        private String[] FileObject_type_info = new String[]{'FileObject','http://miarchitecture.gecmc.ge.com/FileUtilsEs','fileSchemaType','1','1','true'};
        private String[] SESSION_ID_type_info = new String[]{'SESSION_ID','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ENTERPRISE_URL_type_info = new String[]{'ENTERPRISE_URL','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'MetaType','FileObject','SESSION_ID','ENTERPRISE_URL'};
    }
    public class GNWFileUtilsES_Services_FileUtilSvcBA_Port {
        ///public String endpoint_x = 'https://dev-usmi.genworth.com/ws/GNWFileUtilsES.Services.FileUtilSvcBA/GNWFileUtilsES_Services_FileUtilSvcBA_Port';
        public String endpoint_x = Label.Webservice_Doument_Endpoint;        
        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://miarchitecture.gecmc.ge.com/FileUtilsEs', 'miarchitectureGecmcGeComFileutilses1'};
        public miarchitectureGecmcGeComFileutilses1.FilePersistResponse wsOpFilePersist(miarchitectureGecmcGeComFileutilses1.FilePersistRequest FilePersistRequest) {
            miarchitectureGecmcGeComFileutilses1.wsOpFilePersist request_x = new miarchitectureGecmcGeComFileutilses1.wsOpFilePersist();
            miarchitectureGecmcGeComFileutilses1.wsOpFilePersistResponse response_x;
            request_x.FilePersistRequest = FilePersistRequest;
            Map<String, miarchitectureGecmcGeComFileutilses1.wsOpFilePersistResponse> response_map_x = new Map<String, miarchitectureGecmcGeComFileutilses1.wsOpFilePersistResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'GNWFileUtilsES_Services_FileUtilSvcBA_Binder_wsOpFilePersist',
              'http://miarchitecture.gecmc.ge.com/FileUtilsEs',
              'wsOpFilePersist',
              'http://miarchitecture.gecmc.ge.com/FileUtilsEs',
              'wsOpFilePersistResponse',
              'miarchitectureGecmcGeComFileutilses1.wsOpFilePersistResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.FilePersistResponse;
        }
        public miarchitectureGecmcGeComFileutilses1.FileRetrieveResponse wsOpFileGet(miarchitectureGecmcGeComFileutilses1.FileRetrieveRequest FileRetrieveRequest) {
            miarchitectureGecmcGeComFileutilses1.wsOpFileGet request_x = new miarchitectureGecmcGeComFileutilses1.wsOpFileGet();
            miarchitectureGecmcGeComFileutilses1.wsOpFileGetResponse response_x;
            request_x.FileRetrieveRequest = FileRetrieveRequest;
            Map<String, miarchitectureGecmcGeComFileutilses1.wsOpFileGetResponse> response_map_x = new Map<String, miarchitectureGecmcGeComFileutilses1.wsOpFileGetResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'GNWFileUtilsES_Services_FileUtilSvcBA_Binder_wsOpFileGet',
              'http://miarchitecture.gecmc.ge.com/FileUtilsEs',
              'wsOpFileGet',
              'http://miarchitecture.gecmc.ge.com/FileUtilsEs',
              'wsOpFileGetResponse',
              'miarchitectureGecmcGeComFileutilses1.wsOpFileGetResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.FileRetrieveResponse;
        }
    }
    public class wsOpFilePersist {
        public miarchitectureGecmcGeComFileutilses1.FilePersistRequest FilePersistRequest;
        private String[] FilePersistRequest_type_info = new String[]{'FilePersistRequest','http://miarchitecture.gecmc.ge.com/FileUtilsEs','FilePersistRequest','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'FilePersistRequest'};
    }
    public class FilePersistResponse {
        public String URL;
        public miarchitectureGecmcGeComFileutilses1.wmMessagesType WmMessages;
        private String[] URL_type_info = new String[]{'URL','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] WmMessages_type_info = new String[]{'WmMessages','http://miarchitecture.gecmc.ge.com/FileUtilsEs','wmMessagesType','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'URL','WmMessages'};
    }
    public class FileRetrieveResponse {
        public String FilePayload;
        public miarchitectureGecmcGeComFileutilses1.wmMessagesType WmMessages;
        private String[] FilePayload_type_info = new String[]{'FilePayload','http://www.w3.org/2001/XMLSchema','base64Binary','0','1','false'};
        private String[] WmMessages_type_info = new String[]{'WmMessages','http://miarchitecture.gecmc.ge.com/FileUtilsEs','wmMessagesType','1','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'FilePayload','WmMessages'};
    }
    public class FilePersistRequest {
        public miarchitectureGecmcGeComFileutilses1.metaType MetaType;
        public miarchitectureGecmcGeComFileutilses1.fileSchemaType FileObject;
        public String SESSION_ID;
        public String ENTERPRISE_URL;
        private String[] MetaType_type_info = new String[]{'MetaType','http://miarchitecture.gecmc.ge.com/FileUtilsEs','metaType','1','1','true'};
        private String[] FileObject_type_info = new String[]{'FileObject','http://miarchitecture.gecmc.ge.com/FileUtilsEs','fileSchemaType','1','1','true'};
        private String[] SESSION_ID_type_info = new String[]{'SESSION_ID','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] ENTERPRISE_URL_type_info = new String[]{'ENTERPRISE_URL','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'MetaType','FileObject','SESSION_ID','ENTERPRISE_URL'};
    }
    public class metaType {
        public String Operation_Type;
        public String Operation_Source;
        public String Async;
        public String CertNbr;
        public String OldCertNbr;
        public String XRefCertNbr;
        public String LenderLoanNbr;
        public String UniqueID;
        public String ProcessID;
        public String Version;
        public String MasterPolicy;
        private String[] Operation_Type_type_info = new String[]{'Operation_Type','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] Operation_Source_type_info = new String[]{'Operation_Source','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] Async_type_info = new String[]{'Async','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] CertNbr_type_info = new String[]{'CertNbr','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] OldCertNbr_type_info = new String[]{'OldCertNbr','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] XRefCertNbr_type_info = new String[]{'XRefCertNbr','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] LenderLoanNbr_type_info = new String[]{'LenderLoanNbr','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] UniqueID_type_info = new String[]{'UniqueID','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] ProcessID_type_info = new String[]{'ProcessID','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] Version_type_info = new String[]{'Version','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] MasterPolicy_type_info = new String[]{'MasterPolicy','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'Operation_Type','Operation_Source','Async','CertNbr','OldCertNbr','XRefCertNbr','LenderLoanNbr','UniqueID','ProcessID','Version','MasterPolicy'};
    }
    public class fileSchemaType {
        public String FileName;
        public String FileSchema;
        public String Payload;
        private String[] FileName_type_info = new String[]{'FileName','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] FileSchema_type_info = new String[]{'FileSchema','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] Payload_type_info = new String[]{'Payload','http://www.w3.org/2001/XMLSchema','base64Binary','0','1','true'};
        private String[] apex_schema_type_info = new String[]{'http://miarchitecture.gecmc.ge.com/FileUtilsEs','false','false'};
        private String[] field_order_type_info = new String[]{'FileName','FileSchema','Payload'};
    }
}

Test Class:

[@IsTest
private with sharing class Test_miarchitectureGecmcGeComFile
{
        public String\[\] caseIds;
         public String pdfName;
    private static testMethod void coverTypes()
    {

        new miarchitectureGecmcGeComFileutilses1.wmMessagesType()[![enter image description here][1]][1];
        new miarchitectureGecmcGeComFileutilses1.wsOpFileGetResponse();
        new miarchitectureGecmcGeComFileutilses1.wsOpFilePersistResponse();
        new miarchitectureGecmcGeComFileutilses1.wsOpFileGet();
        new miarchitectureGecmcGeComFileutilses1.FileRetrieveRequest();
        new miarchitectureGecmcGeComFileutilses1.GNWFileUtilsES_Services_FileUtilSvcBA_Port();
        new miarchitectureGecmcGeComFileutilses1.wsOpFilePersist();
        new miarchitectureGecmcGeComFileutilses1.FilePersistResponse();
        new miarchitectureGecmcGeComFileutilses1.FileRetrieveResponse();
        new miarchitectureGecmcGeComFileutilses1.FilePersistRequest();
        new miarchitectureGecmcGeComFileutilses1.metaType();
        new miarchitectureGecmcGeComFileutilses1.fileSchemaType();
                    // new miarchitectureGecmcGeComFileutilses1.addPDF(caseIds,pdfName);
                        //new miarchitectureGecmcGeComFileutilses1.DebuggingInfo_element();


    }

}

code coverage: enter image description here

0

You are close.

But just instantiating a class will not actually execute the code in a method, or consider any of its properties/attributes to be read. You need to actually perform a read on each of the properties...and ideally, assert the value you expect. So for example here you call the constructor for one of your inner classes:

new miarchitectureGecmcGeComFileutilses1.wmMessagesType()

But this doesn't actually read any of the attributes you defined for wmMessageTypes class.

First, you have some private members. To make those accessible to the test framework you'll need to annotate them with @TestVisible. For example:

@TestVisible private String[] wmstatus_type_info = 
       new String[]{'wmstatus','http://www.w3.org/2001/XMLSchema','string','0','1','true'};

This will make it so that in normal runtime, wmstatus_type_info remains inaccessible outside of its class, but accessible to the testing context.

You then need to perform reads on each line of code, ideally asserting the expected value, so like this:

miarchitectureGecmcGeComFileutilses1.wmMessagesType wmMsgType = 
                                 new miarchitectureGecmcGeComFileutilses1.wmMessagesType();

System.assertEquals('wmstatus',
                     wmMsgType.wmstatus_type_info[0],
                    'the first element of wmstatus_type_info was incorrect');

If you're being thorough, and not just going for code coverage, perhaps you repeat this for every element of every array...remember, code coverage is not the same as writing a test.

I know it is tedious, but by doing so, you make your code more robust.

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.