+ Start a Discussion
Raghu PedabbaRaghu Pedabba 

Collection Store Exception putting ... WebService Mock

Hi All,

I am trying to create a test class for my Web Service and I am getting the following Error

FATAL_ERROR System.TypeException:Collection store exception putting
 pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results into Map<String,pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>


Please Help. ...

Class Generated From WSDL
//Generated by wsdl2apex


public class pca_Email_validation {
    public class EmailValidation_Batch_Validate_v1_20_Results {
        public String Status;
        public String EmailAddress;
        public String Account;
        public String Domain;
        public Boolean IsDisposible;
        public Boolean IsSystemMailbox;
        private String[] Status_type_info = new String[]{'Status','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] EmailAddress_type_info = new String[]{'EmailAddress','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Account_type_info = new String[]{'Account','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Domain_type_info = new String[]{'Domain','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] IsDisposible_type_info = new String[]{'IsDisposible','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] IsSystemMailbox_type_info = new String[]{'IsSystemMailbox','http://services.postcodeanywhere.co.uk/',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Status','EmailAddress','Account','Domain','IsDisposible','IsSystemMailbox'};
    }
    public class EmailValidation_Batch_Validate_v1_20_element {
        public String Key;
        public String Emails;
        private String[] Key_type_info = new String[]{'Key','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] Emails_type_info = new String[]{'Emails','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'Key','Emails'};
    }
    public class EmailValidation_Batch_Validate_v1_20_Response_element {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20_Result;
        private String[] EmailValidation_Batch_Validate_v1_20_Result_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result','http://services.postcodeanywhere.co.uk/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Result'};
    }
    public class EmailValidation_Batch_Validate_v1_20_ArrayOfResults {
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results[] EmailValidation_Batch_Validate_v1_20_Results;
        private String[] EmailValidation_Batch_Validate_v1_20_Results_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results','http://services.postcodeanywhere.co.uk/',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://services.postcodeanywhere.co.uk/','true','false'};
        private String[] field_order_type_info = new String[]{'EmailValidation_Batch_Validate_v1_20_Results'};
    }
    public class PostcodeAnywhere_Soap {
        public String endpoint_x = 'https://services.postcodeanywhere.co.uk/EmailValidation/Batch/Validate/v1.20/soapnew.ws';
        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://services.postcodeanywhere.co.uk/', 'pca_Email_validation'};
        public pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults EmailValidation_Batch_Validate_v1_20(String Key,String Emails) {
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element request_x = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_element();
            request_x.Key = Key;
            request_x.Emails = Emails;
            pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element response_x;
            Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element> response_map_x = new Map<String, pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://services.postcodeanywhere.co.uk/EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20',
              'http://services.postcodeanywhere.co.uk/',
              'EmailValidation_Batch_Validate_v1_20_Response',
              'pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Response_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.EmailValidation_Batch_Validate_v1_20_Result;
        }
    }
}
web Service Mock Impl Class

@isTest
global class WebServiceMockImpl implements WebServiceMock {
    
    global void doInvoke(
         Object stub,
         Object request,
         Map<string, object> response,
         string endpoint,
         string soapAction,
         string requestName,
         string responseNS,
         string responseName,
         string responseType){
             
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results   respElement = new pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
        respElement.Status = 'Invalid';
        response.put('response_x', respElement);
       }
}

@isTest
public class DispatcherLeadNewTest {
 static testMethod void pcavalidation(){

        Test.setMock(WebServiceMock.class, new WebServiceMockImpl());
        Test.startTest();
        String Key = 'XXXX-XXXX-XXXX-XXXX';
        String Mail = 'test@test.com';
        pca_Email_validation.PostcodeAnywhere_Soap stub = new  pca_Email_validation.PostcodeAnywhere_Soap();
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results stub2 = new           pca_Email_validation.EmailValidation_Batch_Validate_v1_20_Results();
        pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults stub1 = new               pca_Email_validation.EmailValidation_Batch_Validate_v1_20_ArrayOfResults();
           
            stub1 = stub.EmailValidation_Batch_Validate_v1_20(Key,mail);
            String valid = stub1.EmailValidation_Batch_Validate_v1_20_Results[0].status;
            
            system.assertEquals('Invalid',valid);
           Test.stopTest();
       
    }
Raghu PedabbaRaghu Pedabba
Guys any pointers please ??