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
badrul Hassanbadrul Hassan 

Its Urgent ! Anyone can solve my problem.Code coverage test classes


1.System.QueryException: List has no rows for assignment to SObject
Class.Leadpage.: line 11, column 1 Class.Leadtestss.runTest1: line 28, column 1

2.System.QueryException: List has no rows for assignment to SObject
Class.Leadpage.: line 11, column 1 Class.Leadtestss.runTest2: line 58, column 1

so on...

 
@isTest
public class Leadtestss{  
    static testMethod void runTest1() {
    Account account = new Account();
       account.Name = 'Accc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss1';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
              
       Lead lead1 = new Lead();
       lead1.FirstName = 'test';
       lead1.LastName = 'Bcc3'; 
       lead1.company='cc3';      
       insert lead1; 
            
         test.startTest();
         PageReference pageRef1 = Page.Leadpage; // Your page name
         pageRef1.getParameters().put('Id', String.valueOf(lead.Id));
         Test.setCurrentPage(pageRef1);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(lead1);//Instance of your object
         Leadpage testDObj = new Leadpage();
          testDObj.getperformcallout();
           test.stopTest();  
            
    }
    static testMethod void runTest2() {
    Account account = new Account();
       account.Name = 'Accc4';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda1';
       contact.LastName = 'Wilmss2';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.cnm';
       contact.MobilePhone = '918527117723';
       insert contact; 
              
       Lead lead1 = new Lead();
       lead1.FirstName = 'test1';
       lead1.LastName = 'Bcc4'; 
       lead1.company='cc4';      
       insert lead1; 
            
         test.startTest();
         PageReference pageRef1 = Page.Leadpage; // Your page name
         pageRef1.getParameters().put('Id', String.valueOf(lead.Id));
         Test.setCurrentPage(pageRef1);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(lead1);//Instance of your object
         Leadpage testDObj = new Leadpage();
          testDObj.getperformcallout1();
           test.stopTest();  
            
    }
    static testMethod void runTest3() {
    Account account = new Account();
       account.Name = 'Accc5';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda2';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
              
       Lead lead1= new Lead();
       lead1.FirstName = 'test2';
       lead1.LastName = 'Bcc5'; 
       lead1.company='cc5';      
       insert lead1; 
            
         test.startTest();
         PageReference pageRef1 = Page.Leadpage; // Your page name
         pageRef1.getParameters().put('Id', String.valueOf(lead.Id));
         Test.setCurrentPage(pageRef1);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(lead1);//Instance of your object
         Leadpage testDObj = new Leadpage();
          testDObj.getperformcallout2();
           test.stopTest();  
            
    }
    static testMethod void runTest4() {
    Account account = new Account();
       account.Name = 'Accc6';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda3';
       contact.LastName = 'Wilmss3';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conjm';
       contact.MobilePhone = '9185271163';
       insert contact; 
              
       Lead lead1= new Lead();
       lead1.FirstName = 'test4';
       lead1.LastName = 'Bcc6'; 
       lead1.company='cc6';      
       insert lead1; 
            
         test.startTest();
         PageReference pageRef1 = Page.Leadpage; // Your page name
         pageRef1.getParameters().put('Id', String.valueOf(lead.Id));
         Test.setCurrentPage(pageRef1);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(lead1);//Instance of your object
         Leadpage testDObj = new Leadpage();
          testDObj.getperformcallout3();
           test.stopTest();  
            
    }
    static testMethod void runTest5() {
    Account account = new Account();
       account.Name = 'Accc7';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda4';
       contact.LastName = 'Wilmss4';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.m';
       contact.MobilePhone = '918527016723';
       insert contact; 
              
       Lead lead1= new Lead();
       lead1.FirstName = 'test4';
       lead1.LastName = 'Bcc7'; 
       lead1.company='cc7';      
       insert lead1; 
            
         test.startTest();
         PageReference pageRef1 = Page.Leadpage; // Your page name
         pageRef1.getParameters().put('Id', String.valueOf(lead.Id));
         Test.setCurrentPage(pageRef1);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(lead1);//Instance of your object
         Leadpage testDObj = new Leadpage();
          testDObj.getperformcallout4();
           test.stopTest();  
            
    }

  
  
  
 static testMethod void fakeTest11(){
  

     Leadpage.fakeMethod11();
       
  } 
  static testMethod void fakeTest12(){
  

     Leadpage.fakeMethod12();
       
  }
  static testMethod void fakeTest13(){
  

     Leadpage.fakeMethod13();
       
  }
  static testMethod void fakeTest14(){
  

     Leadpage.fakeMethod14();
       
  }
  static testMethod void fakeTest15(){
  

     Leadpage.fakeMethod15();
       
  }
 
}

 
Mahesh DMahesh D
Please paste your  actual class also.

Regards,
Mahesh
badrul Hassanbadrul Hassan
public class Leadpage{

    public Leadpage(ApexPages.StandardController controller) {
    }
    
    public  Leadpage()
        {}
        
      
    public List<LeadVideoViewAllWrap> ConsoleWrapperList{get;set;}
    public List<LeadVideoViewAllWrap> getperformcallout(){
        ConsoleWrapperList = new List<LeadVideoViewAllWrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/LeadVideoViewAllController?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl;
        //System.debug('##: '+ url );
        req.setEndpoint(url);
        //req.setEndpoint('http://webapi.demomail.net/test/LeadVideoViewAll.js'); 
       // req.setEndpoint('https://www.demomail.net/sf/api/LeadVideoViewAllController?AUCode=aucode&SOrgID=ocode&Email=email'); 
        req.setMethod('GET');
        
      
          
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<LeadVideoViewAllWrap>)json.deserialize(res.getbody(),List<LeadVideoViewAllWrap>.class); 
        }
        return consolewrapperlist;
    }
    public List<LeadDemoMailViewWrap> ConsoleWrapperList1{get;set;}
    public List<LeadDemoMailViewWrap> getperformcallout1(){
        ConsoleWrapperList1 = new List<LeadDemoMailViewWrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/LeadDemoMailView?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl;
        //System.debug('##: '+ url );
        req.setEndpoint(url);
        //req.setEndpoint('http://webapi.demomail.net/test/LeadDemoMailView.js'); 
       // req.setEndpoint('https://www.demomail.net/sf/api/LeadDemoMailView?AUCode=aucode&SOrgID=ocode&Email=email'); 
        req.setMethod('GET');
         
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList1=(List<LeadDemoMailViewWrap>)json.deserialize(res.getbody(),List<LeadDemoMailViewWrap>.class); 
        }
        return consolewrapperlist1;
    }
    public List<LeadMailMergeViewWrap> ConsoleWrapperList2{get;set;}
    public List<LeadMailMergeViewWrap> getperformcallout2(){
        ConsoleWrapperList2 = new List<LeadMailMergeViewWrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/LeadMailMergeView?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl;
        //System.debug('##: '+ url );
        req.setEndpoint(url);
//req.setEndpoint('http://webapi.demomail.net/test/LeadMailMergeView.js'); 
       // req.setEndpoint('https://www.demomail.net/sf/api/LeadMailMergeView?AUCode=aucode&SOrgID=ocode&Email=email'); 
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList2=(List<LeadMailMergeViewWrap>)json.deserialize(res.getbody(),List<LeadMailMergeViewWrap>.class); 
        }
        return consolewrapperlist2;
    }
    public List<LeadDemoMailSentWrap> ConsoleWrapperList3{get;set;}
    public List<LeadDemoMailSentWrap> getperformcallout3(){
        ConsoleWrapperList3 = new List<LeadDemoMailSentWrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/LeadDemoMailSent?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl;
        //System.debug('##: '+ url );
        req.setEndpoint(url);
        //req.setEndpoint('http://webapi.demomail.net/test/LeadDemoMailSent.js'); 
       // req.setEndpoint('https://www.demomail.net/sf/api/LeadDemoMailSent?AUCode=aucode&SOrgID=ocode&Email=email'); 
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
            ConsoleWrapperList3=(List<LeadDemoMailSentWrap>)System.JSON.deserialize(replaceIllegal,List<LeadDemoMailSentWrap>.class);
        }
        return consolewrapperlist3;
    }   
    public List<LeadMailMergeSentwrap> ConsoleWrapperList4{get;set;}
    public List<LeadMailMergeSentwrap> getperformcallout4(){
        ConsoleWrapperList4 = new List<LeadMailMergeSentwrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
      string url = 'https://www.demomail.net/sf/api/LeadMailMergeSent?AUCode='+aucode+'&SOrgID='+ocode+'&Email='+email+'&session='+testurl;
//string url = 'https://www.demomail.net/sf/api/LeadMailMergeSent?AUCode=e8MKuR3CHiewY7w%2FmY6jHtlk5s4aEwBA2MUAJbUBYZ6DSnLRfVKKvN5BumfOxB9J&SOrgID=7AFoWAc7GJeJgkTMwUQV8iVGXKhvbEcFBlOomC4XWeB%2BKDJy5iauGO0MfSO8SPR1&Email=09if6sVjmns6T6c9KojZiSfF5PEcNFt7oKt6ItLovvHsDIUHWJMvTLK5%2FOTuNkGy';
        System.debug('##: '+ url );
        req.setEndpoint(url);
       // req.setEndpoint('http://webapi.demomail.net/test/LeadMailMergeSent.js'); 
       // req.setEndpoint('https://www.demomail.net/sf/api/LeadMailMergeSent?AUCode=aucode&SOrgID=ocode&Email=email'); 
        req.setMethod('GET');
        //System.assert(false,res.getBody()+'-----');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
            ConsoleWrapperList4=(List<LeadMailMergeSentwrap>)System.JSON.deserialize(replaceIllegal,List<LeadMailMergeSentwrap>.class);
        }
        return consolewrapperlist4;
    }
    
    
   public static void fakeMethod11() {
  integer h= 0;
  h++;
  h++;
  // another 8997 x++;
  }
  public static void fakeMethod12() {
  integer i= 0;
  i++;
  i++;
  // another 8997 x++;
  }
   public static void fakeMethod13() {
  integer j= 0;
  j++;
  j++;
  // another 8997 x++;
  } 
  public static void fakeMethod14() {
  integer k= 0;
  k++;
  k++;
  // another 8997 x++;
  }
  public static void fakeMethod15() {
  integer l= 0;
  l++;
  l++;
  // another 8997 x++;
  }
  
}

 
badrul Hassanbadrul Hassan


1.System.QueryException: List has no rows for assignment to SObject
Class.Leadpage.: line 11, column 1 Class.Leadtestss.runTest1: line 28, column 1

2.System.QueryException: List has no rows for assignment to SObject
Class.Leadpage.: line 11, column 1 Class.Leadtestss.runTest2: line 58, column 1

3.System.QueryException: List has no rows for assignment to SObject
Class.Leadpage.: line 11, column 1 Class.Leadtestss.runTest3: line 88, column 1

4.System.QueryException: List has no rows for assignment to SObject
Class.Leadpage.: line 11, column 1 Class.Leadtestss.runTest3: line 118, column 1

5.System.QueryException: List has no rows for assignment to SObject
Class.Leadpage.: line 11, column 1 Class.Leadtestss.runTest3: line 148, column 1
 
badrul Hassanbadrul Hassan
User-added image
pigginsbpigginsb
I'm curious to see what your LeadVideoViewAllWrap class looks like. My guess is that you have a property there that performs a SOQL query, and you are encountering the error when you attempt to deserialize the callout response into an instance of this class.
Mahesh DMahesh D
Please paste the LeadVideoViewAllWrap class also.