• rupesh ranjan
  • NEWBIE
  • 70 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 104
    Questions
  • 72
    Replies
How to retrive data REST API(GET) and bind through Jquery in Page block table?

 
I don't have any idea about Jquery how to use and I need to bind data with Jquery Pls someone help its urgent
<apex:page Controller="DemomailReporttab"  sidebar="false" showheader="false" readOnly="true">
  <apex:form >
    <apex:pageblock >
            <c:PageBlockTableEnhancerADV targetPbTableIds="pbt"  pageSizeOptions="5,10,15,30" defaultPageSize="15" enableExport="false"/>           
               <apex:pageBlockTable value="{!performcallout}" var="wrap" width="100%"  id="pbt"  styleClass="tablesorter" headerClass="header">
                  <apex:column headerValue="Source" value="{!wrap.TrafficSource}"/>
                  <apex:column headerValue="Unique Viewers" value="{!wrap.UniqueViewer}"/>
                  <apex:column headerValue="Average Duration" value="{!wrap.AvgDuration}"/>
                  <apex:column headerValue="Total Duration" value="{!wrap.TotalDuration}"/>
                  <apex:column headerValue="Total Views">
                 <apex:commandLink value="{!wrap.TotalViews}" />
                  </apex:column>
               </apex:pageBlockTable>
               </apex:pageblock>  
    </apex:form>
</apex:page>
 
public  class DemomailReporttab{
    public DemomailReporttab(ApexPages.StandardController controller) {
    }
    public  DemomailReporttab()
    {}  
    public   String startdate{get; set;}
    public   String enddate{get; set;}
    public   String Acode= Userinfo.getuserid();
    public   String Oid = UserInfo.getOrganizationId();
    public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    public Transient List<DemoMailDetailReport> DemomailReportValue{get;set;}
    public List<DemoMailDetailReport> getperformcallout(){
        DemomailReportValue = new List<DemoMailDetailReport>();
        HttpRequest req = new HttpRequest(); 
        HttpResponse res = new HttpResponse();
        Http http = new Http(); 
        string url = 'https://www.demomail.net/sf/api/DashBoard?AUCode='+aucode+'&SOrgID='+ocode; 
        req.setEndpoint(url);
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null)
        { 
            String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
            DemomailReportValue =(List<DemoMailDetailReport>)System.JSON.deserialize(replaceIllegal,List<DemoMailDetailReport>.class);
        }
        return DemomailReportValue; 
    }
}

 
How to set authentication for other SMTP in this mail code
 
public pageReference send(){
	Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();  
	List<String> ccAddresses =new List<String>();  
	if (AddRecep != '' && AddRecep != null) 
	{
		ccAddresses  = AddRecep.split(';');
		email.setTargetObjectId(conId);
		email.setCcAddresses(ccAddresses);
		email.setSubject(subject);
		email.setHtmlBody(body);   	
	    for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress])
		{
			if(owa.DisplayName.contains('System Admin'))
			{
				email.setOrgWideEmailAddressId(owa.id);
			}
		}
		Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});  
		for ( Messaging.sendEmailResult result : res ) {
			if ( !res[0].isSuccess () ) {
				System.debug ( result  );
			}          
		}       
	}  
	return null;        
}

 
<apex:page controller="videolistclasss" readOnly="true">
<apex:form >
 <script>
   function myJavaMethod(){
      myactionfun();
  }
  </script>
  <apex:actionFunction name="myactionfun"  action="{!getperformcalloutpageReference}" reRender="false"/>
 <apex:pageBlock >
 <apex:pageblockSection >
<apex:selectList size="1" value="{!ContentCategoryId}" id="ContentCategoryId" onchange="{!myJavaMethod}">    
      <apex:selectOptions value="{!items}" /> 
       <apex:actionSupport event="onchange">
    </apex:actionSupport>   
     </apex:selectList>
     </apex:pageblockSection>
 </apex:pageBlock>
 <apex:pageblock >   
<c:PageBlockTableEnhancerADV targetPbTableIds="a"  pageSizeOptions="5,10,15,30,40,50,60,70" defaultPageSize="50" enableExport="false"/> 
<apex:pageBlockTable id="a" value="{!performcallout}" var="wrap" width="100%"  rendered="{!normalList}">
<apex:column headerValue="Title" value="{!wrap.Title}"/>
<apex:column >
<apex:inputCheckbox value="{!wrap.selected}" > 
</apex:inputCheckbox>
</apex:column>
</apex:pageBlockTable> 
</apex:pageBlock>  
</apex:form>
</apex:page>
 
Public  class videolistclasss{
public String ContentCategoryId {get;set;}
public String PartnerId{get;set;}
public String parentcompany_id{get;set;}
PUBLIC List<selectOption> Items;
    public String toAddresses {get; set;}
     public   String MySessionID = UserInfo.getSessionID();
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
    // public   String Acode= Userinfo.getuserid();
      public   String Acode= '00528000001ktnpAAA';
     public   String Oid = '00D280000018TjaEAE';
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;} 
   public List<videolist> ConsoleWrapperList5{get;set;}
    public string productName{get;set;}
    public videolistclasss() {
        getperformcallout5();
       
        normalList = true;
        selectedList = false;
    }
 
    public List<videolist> getperformcallout5(){ 
        ConsoleWrapperList5 = new List<videolist>(); 
        HttpRequest req = new HttpRequest();
         HttpResponse res = new HttpResponse();
          Http http = new Http();
            System.debug('Calling method now' );
          string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+0;
            req.setEndpoint(url);
              System.debug('&&: '+ url );
            req.setMethod('GET');
             res = http.send(req);
              if(res.getstatusCode() == 200 && res.getbody() != null)
              {
               ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class);
               }
                return consolewrapperlist5; 
                }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(videolist crRec : ConsoleWrapperList5){
            options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName));
            System.debug('##: '+ crRec.ContentCategoryId);
        }   
        return options;
    }
    public List<consolewrap> ConsoleWrapperList{get;set;}
   public  List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
     string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0+'&PartnerId='+0;
       System.debug('**: '+ url);
      req.setEndpoint(url);
        //System.debug('!!!'+ SessionId);
        req.setMethod('GET');
         //system.debug('???'+aucode);
           //system.debug('***'+ocode);
        res = http.send(req);
       // System.assert(false,res.getBody()+'-----');
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
     return ConsoleWrapperList;
    } 
public pageReference getperformcalloutpageReference ()
{
  getperformcallout(); 
  return null; 
}   
}

 
can any body tell me how can i call api for the picklist dependet value without page load?

Some example plss
i need to paas parameter on selection of pick list
VF page  

<apex:pageblockSection >
    <apex:selectList size="1" value="{!productName}" id="ContentCategoryId">   
     <apex:selectOptions value="{!items}"/>   
  <apex:actionSupport event="onchange" action="{!getperformcallout}" rerender="normalList">
      <apex:param name="ContentCategoryId" assignto="{!ContentCategoryId}" value="{!ContentCategoryId}"/>
    </apex:actionSupport>   
     </apex:selectList>
     </apex:pageblockSection>
 </apex:pageBlock>
 <apex:pageblock >
Public  class videolistclass{
public String ContentCategoryId{get;set;}
PUBLIC List<selectOption> Items;
    public String toAddresses {get; set;}
     public   String MySessionID = UserInfo.getSessionID();
   
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     
     public   String Oid = '00D280000018TjaEAE';
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
  
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
 
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);

    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
 
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
   
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;}  
   public List<videolist> ConsoleWrapperList5{get;set;}
    public string productName{get;set;}
    
    public videolistclass() {
        getperformcallout5();
        normalList = true;
        selectedList = false;
    }
     
    public List<videolist> getperformcallout5(){ 
        ConsoleWrapperList5 = new List<videolist>(); 
        HttpRequest req = new HttpRequest();
         HttpResponse res = new HttpResponse();
          Http http = new Http();
          string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId;
            req.setEndpoint(url);
              System.debug('&&: '+ url );
            req.setMethod('GET');
             res = http.send(req);
              if(res.getstatusCode() == 200 && res.getbody() != null)
              {
               ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class);
               }
                return consolewrapperlist5; 
                }
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(videolist crRec : ConsoleWrapperList5){
            options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName));
        
        }   
        return options;
    }
    public List<consolewrap> ConsoleWrapperList{get;set;}
    public List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0;
        req.setEndpoint(url);        
		req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
        return consolewrapperlist;
    }   
}



 
 write Batch Class for this code? 
more thn 50001 record..
Public  class  selectcontact{ 
    public String to{get; set;}
    public String AddRecep{get; set;}
    public String subject {get; set;}
    public String body {get; set;}
public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public selectcontact(){
        body = apexpages.currentpage().getparameters().get('att');
     
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        
       
        body = '';         
      
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    }   
}

 
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailexample.processSelected: line 26, column 1
Class.sendmailexample1test.runTest1: line 37, column 1
 
@isTest
public class sendmailexample1test{  
static testMethod void runTest1(){
  Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
       
        ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact);
        apexpages.currentpage().getparameters().put('ID',contact.id);
        String  conId = ApexPages.currentPage().getParameters().get('Id');
        String  EmailCon =[Select email from Contact where Id=:conId ].email;
        sendmailexample testDObj1 = new sendmailexample(sc2);
        testDObj1.AddRecep='twilms@verisign.conm';
        testDObj1.to ='twilms@verisign.conm';
        testDObj1.EmailCon ='twilms@verisign.conm'; 
        testDObj1.Email ='twilms@verisign.conm';
        testDObj1.body='abc';
         testDObj1.subject='abc'; 
         
            
test.StartTest();
PageReference pageRef = page.sendmail;
Test.setCurrentPage(pageRef);
ApexPages.StandardController sc = new ApexPages.standardController(Contact);
apexpages.currentpage().getparameters().put('Id',contact.id);
sendmailexample testDObj = new sendmailexample(sc);
testDObj.EmailCon ='twilms@verisign.conm'; 

testDObj.processSelected(); 
test.StopTest();
}
  
}
 
Public  class sendmailexample1{ 
    public String to{get; set;}
    public String AddRecep{get; set;}
    public String subject {get; set;}
    public String body {get; set;}
public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public sendmailexample1(){
        body = apexpages.currentpage().getparameters().get('att');
     
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        
       
        body = '';         
      
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    }   
}

 
I want to write test  class for below code

code is for selected contact which is stored in wrapper class(wrapContact )
 
Public  class sendmailexample{ 
public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public sendmailexample(){
        body = apexpages.currentpage().getparameters().get('att');
     
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        
       
        body = '';         
       to = EmailCon; 
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    }   
}

 
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailexample.sendpost: line 62, column 1
Class.sendcontacttest.runTest1: line 34, column 1
                                      &
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sendmailexample.<init>: line 10, column 1
Class.sendcontacttest.runTest5: line 67, column 1
@isTest
public class sendcontacttest{  
    static testMethod void runTest1() {
       Account account = new Account();
       account.Name = 'Acc3';
       insert account;         
       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact;
              
        ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact);
        apexpages.currentpage().getparameters().put('ID',contact.id);
        String  conId = ApexPages.currentPage().getParameters().get('Id');
        String  EmailCon =[Select email from Contact where Id=:conId ].email;
        sendmailexample testDObj1 = new sendmailexample(sc2);
        testDObj1.AddRecep='twilms@verisign.conm';
        testDObj1.to ='twilms@verisign.conm';
        testDObj1.EmailCon ='twilms@verisign.conm'; 
        testDObj1.Email ='twilms@verisign.conm';
        testDObj1.body='abc';
        testDObj1.subject='abc';
           
         test.startTest();
         PageReference pageRef = Page.sendmail; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailexample testDObj = new sendmailexample(sc1);
          testDObj.sendpost();        
           test.stopTest();  
            
    }   
    static testMethod void runTest5(){
  Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
       
        ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact);
        apexpages.currentpage().getparameters().put('ID',contact.id);
        String  conId = ApexPages.currentPage().getParameters().get('Id');
      String  EmailCon =[Select email from Contact where Id=:conId ].email;
      sendmailexample testDObj1 = new sendmailexample(sc2);
        testDObj1.AddRecep='twilms@verisign.conm';
        testDObj1.to ='twilms@verisign.conm';
        testDObj1.EmailCon ='twilms@verisign.conm'; 
        testDObj1.Email ='twilms@verisign.conm';
        testDObj1.body='abc';
         testDObj1.subject='abc';     
            
test.StartTest();
PageReference pageRef = page.sendmail;
Test.setCurrentPage(pageRef);
ApexPages.StandardController sc = new ApexPages.standardController(Contact);
sendmailexample testDObj = new sendmailexample(sc);
testDObj.EmailCon ='twilms@verisign.conm'; 
testDObj.processSelected(); 
test.StopTest();
}
  
}
 
Public  class sendmailexample{

    public String to{get; set;}
    public String AddRecep{get; set;}
    public String subject {get; set;}
    public String body {get; set;}
    public String table3{get; set;}
     public   String MySessionID = UserInfo.getSessionID();
     public String  conId = ApexPages.currentPage().getParameters().get('Id');
     public  String  EmailCon =[Select email from Contact where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
    public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);

    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
 
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
 
    public sendmailexample(ApexPages.StandardController controller) {
    AddRecep = '';
    body=apexpages.currentpage().getparameters().get('att');   
           
    }
    
   public void sendpost(){
    String MySessionID = UserInfo.getSessionID();
      String  conId = ApexPages.currentPage().getParameters().get('Id');
      String  EmailCon =[Select email from Contact where Id=:conId ].email;
        String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
        string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
        String Acode= Userinfo.getuserid();
        String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
   Blob data6 = Blob.valueOf(to);
   Blob data7 = Blob.valueOf(AddRecep);
  Blob data8 = Blob.valueOf(subject);
   Blob data9 = Blob.valueOf(body);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
   Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 );
    Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 );
    Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 );
   Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 );
        String b64Data = EncodingUtil.base64Encode(encryptedData);
        String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
        String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
        String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
        String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
        String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
       String b64Data6 = EncodingUtil.base64Encode(encryptedData6);
       String b64Data7 = EncodingUtil.base64Encode(encryptedData7);
        String b64Data8 = EncodingUtil.base64Encode(encryptedData8);
       String b64Data9 = EncodingUtil.base64Encode(encryptedData9);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
     String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
     String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
     String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');
     String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8');
     String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8');
    String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8');
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost');
        
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); 
system.debug('???'+aucode);
        try {
                res = http.send(req);
                if (res.getBody() != null) {
                    System.debug('#Success!');
                } else {
                    System.debug('HTTP error: ' + res.getStatusCode());
                }
                System.debug(res.getBody());
            } 
        catch(System.CalloutException e) 
            {
                System.debug('Callout error: '+ e);
            }
   }
        
    public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public sendmailexample(){
        body = apexpages.currentpage().getparameters().get('att');
     
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        
       
        body = '';         
       to = EmailCon; 
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    }   
}

 
How to insert simple VF field  in test class some sample code plsss

Need to write test class for insertion not for standard object 

i have used simple controller like 
<apex:page controller="abc" > 
Main controller
Variable intialised like this

Public  class abc{

    public String to{get; set;}
    public String AddRecep{get; set;}

 
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailp.sendpost: line 65, column 1
Class.sendmailcontacttest.runTest1: line 25, column 1  
                      &
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailp.callapi2: line 1164, column 1
Class.sendmailcontacttest.runTest3: line 49, column 1
 
Test Class

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

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
            
         test.startTest();
         PageReference pageRef = Page.sendmail; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.sendpost();
           test.stopTest();  
            
    }   
    static testMethod void runTest3() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
            
         test.startTest();
         PageReference pageRef = Page.Leadpage; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.callapi2();
           test.stopTest();  
            
    }
    static testMethod void runTest4() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         
       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
	   test.startTest();
         PageReference pageRef = Page.Leadpage; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.getperformcallout();
           test.stopTest();              
    }  
}
 
Mock Class

@IsTest(seeAllData = false)
global class sendmailcontactmock implements HttpCalloutMock 
{   
    global HTTPResponse respond(HTTPRequest req) {        
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"foo":"bar"}]');
        res.setStatusCode(200);        
        return res;
    }   
}
 
Main Class

Public  class sendmailp{

    public String to{get; set;}
    public String AddRecep{get; set;}
    public String subject {get; set;}
    public String body {get; set;}
    public String table3{get; set;}
     public String toAddresses {get; set;}
     public   String MySessionID = UserInfo.getSessionID();
     public String  conId = ApexPages.currentPage().getParameters().get('Id');
     public  String  EmailCon =[Select email from Contact where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );

    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
 
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');

    public sendmailp(ApexPages.StandardController controller) {
    AddRecep = '';
    body=apexpages.currentpage().getparameters().get('att');   
           
    }
    
   public void sendpost(){
    String MySessionID = UserInfo.getSessionID();
      String  conId = ApexPages.currentPage().getParameters().get('Id');
      String  EmailCon =[Select email from Contact where Id=:conId ].email;
        String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
        string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
        String Acode= Userinfo.getuserid();
        String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
   Blob data6 = Blob.valueOf(to);
   Blob data7 = Blob.valueOf(AddRecep);
  Blob data8 = Blob.valueOf(subject);
   Blob data9 = Blob.valueOf(body);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
   Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 );
    Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 );
    Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 );
   Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 );
        String b64Data = EncodingUtil.base64Encode(encryptedData);
        String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
        String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
        String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
        String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
        String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
       String b64Data6 = EncodingUtil.base64Encode(encryptedData6);
       String b64Data7 = EncodingUtil.base64Encode(encryptedData7);
        String b64Data8 = EncodingUtil.base64Encode(encryptedData8);
       String b64Data9 = EncodingUtil.base64Encode(encryptedData9);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
     String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
     String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
     String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');
     String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8');
     String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8');
    String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8');
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost');
        
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');        req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); 
system.debug('???'+aucode);
        try {
                res = http.send(req);
                if (res.getBody() != null) {
                    System.debug('#Success!');
                } else {
                    System.debug('HTTP error: ' + res.getStatusCode());
                }
                System.debug(res.getBody());
            } 
        catch(System.CalloutException e) 
            {
                System.debug('Callout error: '+ e);
            }
   }
        
    public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public sendmailp(){
        body = apexpages.currentpage().getparameters().get('att');
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        normalList = true;
        selectedList = false;
        body = ''; 
       to = EmailCon; 
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    } 
    
    public List<video> ConsoleWrapperList1{get;set;}
    public String consolewrap{get;set;}
    public String  SessionId = '';
    public void callapi2(){
    String  SessionId = '';
    string testSessionId = '';
    for( consolewrap cwt : ConsoleWrapperList){
        testSessionId += cwt.sid;
        if(cwt.selected){
            if(SessionId == ''){
                SessionId += cwt.SessionId;
            }else{
                SessionId += ','+ cwt.SessionId;
            }
        }
    } 
    system.debug('testSessionId+++'+testSessionId);
    List<video> ConsoleWrapperList1 = new List<video>();
    HttpRequest req = new HttpRequest(); 
    HttpResponse res = new HttpResponse();
    Http http = new Http(); 
    system.debug('SessionId+++'+SessionId);
   string url = 'https://www.demomail.net/sf/api/SendVideoContactPreview?AUCode='+aucode+'&SOrgID='+ocode+'&SessionIds='+SessionId;
      req.setEndpoint(url); 
    req.setMethod('GET');
    res = http.send(req);
    if(res.getstatusCode() == 200 && res.getbody() != null){ 
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
        ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class);
        system.debug('ConsoleWrapperList1+++'+ConsoleWrapperList1);
        body = ConsoleWrapperList1.get(0).bodyT;
    }
}
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;} 
    public List<consolewrap> ConsoleWrapperList{get;set;}
    public List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
     string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&id='+SessionId;
        System.debug('##: '+ SessionId);
      req.setEndpoint(url);
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
        return consolewrapperlist;
    }
    
}

 
Any one pls remove this error from test class
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
TEST Class

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

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
              
       Lead lead = new Lead();
       lead.FirstName = 'test';
       lead.LastName = 'foo'; 
       lead.company='Acc3';      
       insert lead; 
            
        test.startTest();
        PageReference pageRef = Page.Leadpage;
        pageRef.getParameters().put('Id', String.valueOf(lead.Id));
        Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
        ApexPages.StandardController sc1 = new ApexPages.StandardController(Lead);//Instance of your object
        Leadpage testDObj = new Leadpage();
        testDObj.getperformcallout();
        test.stopTest();  
            
    }    
}
 
Page MOCK Class

@IsTest(seeAllData = false)
global class Leadpagemock implements HttpCalloutMock 
{    
    global HTTPResponse respond(HTTPRequest req) {        
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"foo":"bar"}]');
        res.setStatusCode(200);        
        return res;
    }   
}
 
Main Class

public class Leadpage{
    public Leadpage(ApexPages.StandardController controller) {
    }    
    public  Leadpage()
        {}        
     public   String MySessionID = UserInfo.getSessionID();
     public   String conId = ApexPages.currentPage().getParameters().get('Id');
     public   String EmailCon=[Select email from Lead where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode='00530000000rLMxAAM';
     public   String Oid = UserInfo.getOrganizationId();  
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);   
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');   
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode (b64Data5,  'UTF-8');
  
    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;
        req.setEndpoint(url);
        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;
    }  
}

 
Error Message    System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Stack Trace    Class.homeReport.getperformcallout: line 55, column 1
Class.homeReportTests.Myunittest1: line 33, column 1
@isTest(seeAllData = false)
public class homeReportTests
{
    public List<homeReportwrap> ConsoleWrapperList{get;set;}
  static testmethod void Myunittest1()
    {
      User a = new User();
       a.FirstName = 'rup';
       a.LastName  = 'ran';
       a.Email     = 'rup.ran@gmail.com';
       a.Username  = 'rup1.ran1@gmail.com';
       a.Alias     = 'rupran';
       a.ProfileId = '00e30000000mm8h';
       // Don't worry about these
       a.TimeZoneSidKey    = 'America/Denver';
       a.LocaleSidKey      = 'en_US';
       a.EmailEncodingKey  = 'UTF-8';
       a.LanguageLocaleKey = 'en_US';
       insert a;
       Account account = new Account();
       account.Name = 'Accc';
       insert account;   
       Contact contact = new Contact();
       contact.FirstName = 'rup';
       contact.LastName = 'ran';
       contact.AccountID = account.Id;
       contact.Email = 'rup.ran@gmail.com';
       contact.MobilePhone = '918527116725';
       insert contact;  
       homeReport cp = new homeReport(new ApexPages.StandardController(contact));
       Test.setMock(HttpCalloutMock.class, new homepagemock());
       homeReport testAObj = new homeReport();
       testAObj.getperformcallout();
      HttpResponse res = new HttpResponse();
  
    //String contentType = res.setHeader('Content-Type');
   // System.assert(contentType == 'application/json');
      String actualValue = res.getBody();
     String expectedValue = '{"foo":"bar"}';
     System.assertEquals(actualValue, expectedValue);
       System.assertEquals(200, res.getStatusCode());
       cp.getperformcallout(); 
        
    }
    
   
   
/*  static testMethod void fakeTest(){
  

     homeReport.fakeMethod();
   

     //repeat the same for the rest of classes.
  } */
  
 /*  static testMethod void fakeTest1(){
   
  } */
  
  
}

 
Main Test Class

@isTest(seeAllData = false)
public class homeReportTests
{
   
  static testmethod void Myunittest1()
    {
       Account account = new Account();
       account.Name = 'Accc';
       insert account;   
       Contact contact = new Contact();
       contact.FirstName = 'rup';
       contact.LastName = 'ran';
       contact.AccountID = account.Id;
       contact.Email = 'rup.ran@gmail.com';
       contact.MobilePhone = '918527116725';
       insert contact;
       homeReport cp = new homeReport(new ApexPages.StandardController(contact));
      Test.startTest();
       Test.setMock(HttpCalloutMock.class, new homepagemock());     
       homeReport testAObj = new homeReport();
       testAObj.getperformcallout();
      HttpResponse res = new HttpResponse();
      String actualValue = res.getBody();
        String expectedValue = '{"foo":"bar"}';
     System.assertEquals(actualValue, expectedValue);
       System.assertEquals(200, res.getStatusCode());
        cp.getperformcallout(); 
        Test.stopTest(); 
    } 
  
}
 
Mock Class

@IsTest(seeAllData = false)
global class homepagemock implements HttpCalloutMock 
{
    global HTTPResponse respond(HTTPRequest req) {   
       System.assertEquals('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=00530000000rLMxAAM&SOrgID=00Dn00000008gwlEAA', req.getEndpoint());
       System.assertEquals('GET', req.getMethod());       
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('{"foo":"bar"}');
        res.setStatusCode(200);       
        return res;
    }  
}
 
Main Class 

public  class homeReport{

private ApexPages.StandardController c;
public homeReport(ApexPages.StandardController stdController) {
        c = stdController;
        }
        public  homeReport()
        {
        }
    String MySessionID = UserInfo.getSessionID();
     String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();
    public   string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(d);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    
  Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
 
public     string b64Data = EncodingUtil.base64Encode(encryptedData);
 public       String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8');    
      
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');


  public List<homeReportwrap> ConsoleWrapperList{get;set;}
  
       public List<homeReportwrap> getperformcallout(){
      ConsoleWrapperList = new List<homeReportwrap>();
       HttpRequest req = new HttpRequest(); 
       HttpResponse res = new HttpResponse();
        Http http = new Http(); 
        string url = 'https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode='+aucode+'&SOrgID='+ocode+'&session='+testurl;     
      req.setEndpoint(url);
       req.setMethod('GET');
        res = http.send(req);
         if(res.getstatusCode() == 200 && res.getbody() != null)
          { 
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
        ConsoleWrapperList=(List<homeReportwrap>)System.JSON.deserialize(replaceIllegal,List<homeReportwrap>.class);
          }
            return consolewrapperlist; 
             
          } 
 }

 
Error Message	System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
Stack Trace	Class.homeReport.getperformcallout: 



@isTest(seeAllData = false)
public class homeReportTests
{
   
  static testmethod void Myunittest1()
    {
       Account account = new Account();
       account.Name = 'Accc';
       insert account;   
       Contact contact = new Contact();
       contact.FirstName = 'rup';
       contact.LastName = 'ran';
       contact.AccountID = account.Id;
       contact.Email = 'rup.ran@gmail.com';
       contact.MobilePhone = '918527116725';
       insert contact;
       homeReport cp = new homeReport(new ApexPages.StandardController(contact));
      Test.startTest();
       Test.setMock(HttpCalloutMock.class, new homepagemock());     
       homeReport testAObj = new homeReport();
       testAObj.getperformcallout();
      HttpResponse res = new HttpResponse();
      String actualValue = res.getBody();
        String expectedValue = '{"foo":"bar"}';
     System.assertEquals(actualValue, expectedValue);
       System.assertEquals(200, res.getStatusCode());
        cp.getperformcallout(); 
        Test.stopTest(); 
    } 
  
}

 
I have Written Mocktest but have an error in TEST Class  (Method does not exist or incorrect signature: homeReport.getperformcallout() )
@isTest
public class homeReportTest
{
    static testmethod void Myunittest1()
    {
        // Your Standard object instance
        User a = new User();
        insert a;
        homeReport cp = new homeReport(new ApexPages.StandardController(a));
        Test.setMock(HttpCalloutMock.class, new homepageTestmock());
        HttpResponse res = homeReport.getperformcallout();
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"foo":"bar"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
        cp.getperformcallout();
        res = http.send(req);
    
    }

}
Mock Class  Mock Class
@IsTest 
global class homepageTestmock implements HttpCalloutMock 
{
    global HTTPResponse respond(HTTPRequest req) {
        
            string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
      String Acode= Userinfo.getuserid();
        String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(d);
   
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
 
       String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
       String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
     
     String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
   
        System.assertEquals('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode='+aucode+'&SOrgID='+ocode, req.getEndpoint());
        System.assertEquals('GET', req.getMethod());
        
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('{"foo":"bar"}');
        res.setStatusCode(200);
        return res;
    }
}

Class
public with sharing class homeReport{
private ApexPages.StandardController c;
public homeReport(ApexPages.StandardController stdController) {
        c = stdController;
        }
    public   string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(d);
   
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
 
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    //String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
      
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');


  public List<homeReportwrap> ConsoleWrapperList{get;set;}
  
       public List<homeReportwrap> getperformcallout(){
      ConsoleWrapperList = new List<homeReportwrap>();
       HttpRequest req = new HttpRequest(); 
       HttpResponse res = new HttpResponse();
        Http http = new Http(); 
        string url = 'https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode='+aucode+'&SOrgID='+ocode;
        //System.debug('##: '+ url );
      req.setEndpoint(url);
      //s req.setEndpoint('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=aucode&SOrgID=ocode'); 
 //req.setEndpoint('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=04uZru9MNwFgaEdddAUOHL0Y%2FtNoWSrhDMQpMyLHbVMBBENHjxc%2B7XO1Tl4T5rA4&SOrgID=IievdI%2Fz5GQAPQEWAzN7cc45a4rUCoRqbEad1KON7DSUK%2F1pxBNzk3%2FB1JcpahR2');
        req.setMethod('GET');
        system.debug('###'+d);
         system.debug('???'+Acode);
           system.debug('***'+Oid );
         
        
        //req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
        res = http.send(req);
         //System.assert(false,res.getBody()+'******');
       
         if(res.getstatusCode() == 200 && res.getbody() != null)
          { 
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
        ConsoleWrapperList=(List<homeReportwrap>)System.JSON.deserialize(replaceIllegal,List<homeReportwrap>.class);
        //ConsoleWrapperList1 = ConsoleWrapperList.replaceall('\r\n','');
          //System.debug('Response Checking Engine: '+ res.getBody());
          }
            return consolewrapperlist; 
             
          }
               
 
 }

 
public with sharing class homeReport{
private ApexPages.StandardController c;
public homeReport(ApexPages.StandardController stdController) {
        c = stdController;
        }
    public   string d='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(d);
   
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
 
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    //String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
      
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');


  public List<homeReportwrap> ConsoleWrapperList{get;set;}
  
       public List<homeReportwrap> getperformcallout(){
      ConsoleWrapperList = new List<homeReportwrap>();
       HttpRequest req = new HttpRequest(); 
       HttpResponse res = new HttpResponse();
        Http http = new Http(); 
        req.setEndpoint('https://www.demomail.net/sf/api/HomeVideoViewReport?AUCode=aucode&SOrgID=ocode'); 
        req.setMethod('GET');
        system.debug('###'+d);
         system.debug('???'+Acode);
           system.debug('***'+Oid );
         
        
        //req.setHeader('Authorization', 'OAuth '+UserInfo.getSessionId());
        res = http.send(req);
         //System.assert(false,res.getBody()+'******');
       
         if(res.getstatusCode() == 200 && res.getbody() != null)
          { 
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
        ConsoleWrapperList=(List<homeReportwrap>)System.JSON.deserialize(replaceIllegal,List<homeReportwrap>.class);
        //ConsoleWrapperList1 = ConsoleWrapperList.replaceall('\r\n','');
          //System.debug('Response Checking Engine: '+ res.getBody());
          }
            return consolewrapperlist; 
             
          }
 }

 
Encryption are not working plss Help its urgent

 
public String to{get; set;}
    Blob data6 = Blob.valueOf(to);
   Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 );
   public    String b64Data6 = EncodingUtil.base64Encode(encryptedData6);
   public String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');

 
expecting right curly bracket, found 'if'
 
<select id="MySelectMenu">
<option value="f">Demos On Demand Report</option>
<option value="s">Pointmarketing Report</option>
</select>
 
public   String MySelectMenu { get; set; }
    public   String SelectMenu { get; set; }
    if(MySelectMenu == 'Demos On Demand Report' ){
    SelectMenu = 'DemosOnDemandReport';
    }
    else(MySelectMenu == 'Pointmarketing Report' ){
    SelectMenu = 'PointmarketingReport';
      }




 
public pageReference send(){
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();  
    List<String> ccAddresses =new List<String>();  
  if (AddRecep != '' && AddRecep != null) {
     ccAddresses  = AddRecep.split(';');
    email.setTargetObjectId(conId);
    email.setCcAddresses(ccAddresses);
    email.setSubject(subject);
    email.setHtmlBody(body);    
  Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});  
  for ( Messaging.sendEmailResult result : res ) {
           if ( !res[0].isSuccess () ) {
               System.debug ( result  );
           }          
       }       
 }  
return null;        
}
                             Contract Object
I need to generate a report that can show elapsed number of days between;
-Site Survey Scheduled (date field) and Site Survey Complete (date field).

So what are the steps?
i need to paas parameter on selection of pick list
VF page  

<apex:pageblockSection >
    <apex:selectList size="1" value="{!productName}" id="ContentCategoryId">   
     <apex:selectOptions value="{!items}"/>   
  <apex:actionSupport event="onchange" action="{!getperformcallout}" rerender="normalList">
      <apex:param name="ContentCategoryId" assignto="{!ContentCategoryId}" value="{!ContentCategoryId}"/>
    </apex:actionSupport>   
     </apex:selectList>
     </apex:pageblockSection>
 </apex:pageBlock>
 <apex:pageblock >
Public  class videolistclass{
public String ContentCategoryId{get;set;}
PUBLIC List<selectOption> Items;
    public String toAddresses {get; set;}
     public   String MySessionID = UserInfo.getSessionID();
   
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     
     public   String Oid = '00D280000018TjaEAE';
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
  
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
 
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);

    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
 
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
   
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;}  
   public List<videolist> ConsoleWrapperList5{get;set;}
    public string productName{get;set;}
    
    public videolistclass() {
        getperformcallout5();
        normalList = true;
        selectedList = false;
    }
     
    public List<videolist> getperformcallout5(){ 
        ConsoleWrapperList5 = new List<videolist>(); 
        HttpRequest req = new HttpRequest();
         HttpResponse res = new HttpResponse();
          Http http = new Http();
          string url = 'https://www.demomail.net/sf/api/ContactCategoryList?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId;
            req.setEndpoint(url);
              System.debug('&&: '+ url );
            req.setMethod('GET');
             res = http.send(req);
              if(res.getstatusCode() == 200 && res.getbody() != null)
              {
               ConsoleWrapperList5=(List<videolist>)json.deserialize(res.getbody(),List<videolist>.class);
               }
                return consolewrapperlist5; 
                }
    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        for(videolist crRec : ConsoleWrapperList5){
            options.add(new SelectOption(crRec.ContentCategoryId, crRec.CategoryName));
        
        }   
        return options;
    }
    public List<consolewrap> ConsoleWrapperList{get;set;}
    public List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&CategoryId='+ContentCategoryId+'&LanguageId='+0;
        req.setEndpoint(url);        
		req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
        return consolewrapperlist;
    }   
}



 
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailexample.sendpost: line 62, column 1
Class.sendcontacttest.runTest1: line 34, column 1
                                      &
Error MessageSystem.QueryException: List has no rows for assignment to SObject
Stack TraceClass.sendmailexample.<init>: line 10, column 1
Class.sendcontacttest.runTest5: line 67, column 1
@isTest
public class sendcontacttest{  
    static testMethod void runTest1() {
       Account account = new Account();
       account.Name = 'Acc3';
       insert account;         
       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact;
              
        ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact);
        apexpages.currentpage().getparameters().put('ID',contact.id);
        String  conId = ApexPages.currentPage().getParameters().get('Id');
        String  EmailCon =[Select email from Contact where Id=:conId ].email;
        sendmailexample testDObj1 = new sendmailexample(sc2);
        testDObj1.AddRecep='twilms@verisign.conm';
        testDObj1.to ='twilms@verisign.conm';
        testDObj1.EmailCon ='twilms@verisign.conm'; 
        testDObj1.Email ='twilms@verisign.conm';
        testDObj1.body='abc';
        testDObj1.subject='abc';
           
         test.startTest();
         PageReference pageRef = Page.sendmail; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailexample testDObj = new sendmailexample(sc1);
          testDObj.sendpost();        
           test.stopTest();  
            
    }   
    static testMethod void runTest5(){
  Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
       
        ApexPages.StandardController sc2 = new ApexPages.StandardController(Contact);
        apexpages.currentpage().getparameters().put('ID',contact.id);
        String  conId = ApexPages.currentPage().getParameters().get('Id');
      String  EmailCon =[Select email from Contact where Id=:conId ].email;
      sendmailexample testDObj1 = new sendmailexample(sc2);
        testDObj1.AddRecep='twilms@verisign.conm';
        testDObj1.to ='twilms@verisign.conm';
        testDObj1.EmailCon ='twilms@verisign.conm'; 
        testDObj1.Email ='twilms@verisign.conm';
        testDObj1.body='abc';
         testDObj1.subject='abc';     
            
test.StartTest();
PageReference pageRef = page.sendmail;
Test.setCurrentPage(pageRef);
ApexPages.StandardController sc = new ApexPages.standardController(Contact);
sendmailexample testDObj = new sendmailexample(sc);
testDObj.EmailCon ='twilms@verisign.conm'; 
testDObj.processSelected(); 
test.StopTest();
}
  
}
 
Public  class sendmailexample{

    public String to{get; set;}
    public String AddRecep{get; set;}
    public String subject {get; set;}
    public String body {get; set;}
    public String table3{get; set;}
     public   String MySessionID = UserInfo.getSessionID();
     public String  conId = ApexPages.currentPage().getParameters().get('Id');
     public  String  EmailCon =[Select email from Contact where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
    public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);

    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
 
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
 
    public sendmailexample(ApexPages.StandardController controller) {
    AddRecep = '';
    body=apexpages.currentpage().getparameters().get('att');   
           
    }
    
   public void sendpost(){
    String MySessionID = UserInfo.getSessionID();
      String  conId = ApexPages.currentPage().getParameters().get('Id');
      String  EmailCon =[Select email from Contact where Id=:conId ].email;
        String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
        string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
        String Acode= Userinfo.getuserid();
        String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
   Blob data6 = Blob.valueOf(to);
   Blob data7 = Blob.valueOf(AddRecep);
  Blob data8 = Blob.valueOf(subject);
   Blob data9 = Blob.valueOf(body);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
   Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 );
    Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 );
    Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 );
   Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 );
        String b64Data = EncodingUtil.base64Encode(encryptedData);
        String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
        String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
        String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
        String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
        String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
       String b64Data6 = EncodingUtil.base64Encode(encryptedData6);
       String b64Data7 = EncodingUtil.base64Encode(encryptedData7);
        String b64Data8 = EncodingUtil.base64Encode(encryptedData8);
       String b64Data9 = EncodingUtil.base64Encode(encryptedData9);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
     String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
     String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
     String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');
     String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8');
     String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8');
    String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8');
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost');
        
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
        req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); 
system.debug('???'+aucode);
        try {
                res = http.send(req);
                if (res.getBody() != null) {
                    System.debug('#Success!');
                } else {
                    System.debug('HTTP error: ' + res.getStatusCode());
                }
                System.debug(res.getBody());
            } 
        catch(System.CalloutException e) 
            {
                System.debug('Callout error: '+ e);
            }
   }
        
    public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public sendmailexample(){
        body = apexpages.currentpage().getparameters().get('att');
     
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        
       
        body = '';         
       to = EmailCon; 
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    }   
}

 
Error MessageSystem.NullPointerException: Argument cannot be null.
Stack TraceClass.sendmailp.sendpost: line 65, column 1
Class.sendmailcontacttest.runTest1: line 25, column 1  
                      &
Error MessageSystem.NullPointerException: Attempt to de-reference a null object
Stack TraceClass.sendmailp.callapi2: line 1164, column 1
Class.sendmailcontacttest.runTest3: line 49, column 1
 
Test Class

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

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
            
         test.startTest();
         PageReference pageRef = Page.sendmail; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.sendpost();
           test.stopTest();  
            
    }   
    static testMethod void runTest3() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
            
         test.startTest();
         PageReference pageRef = Page.Leadpage; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.callapi2();
           test.stopTest();  
            
    }
    static testMethod void runTest4() {
    Account account = new Account();
       account.Name = 'Acc3';
       insert account;         
       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
	   test.startTest();
         PageReference pageRef = Page.Leadpage; // Your page name
         pageRef.getParameters().put('Id', String.valueOf(Contact.Id));
         Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new sendmailcontactmock());
          ApexPages.StandardController sc1 = new ApexPages.StandardController(Contact);//Instance of your object
         sendmailp testDObj = new sendmailp();
          testDObj.getperformcallout();
           test.stopTest();              
    }  
}
 
Mock Class

@IsTest(seeAllData = false)
global class sendmailcontactmock implements HttpCalloutMock 
{   
    global HTTPResponse respond(HTTPRequest req) {        
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"foo":"bar"}]');
        res.setStatusCode(200);        
        return res;
    }   
}
 
Main Class

Public  class sendmailp{

    public String to{get; set;}
    public String AddRecep{get; set;}
    public String subject {get; set;}
    public String body {get; set;}
    public String table3{get; set;}
     public String toAddresses {get; set;}
     public   String MySessionID = UserInfo.getSessionID();
     public String  conId = ApexPages.currentPage().getParameters().get('Id');
     public  String  EmailCon =[Select email from Contact where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode= Userinfo.getuserid();
     public   String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );

    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
 
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');

    public sendmailp(ApexPages.StandardController controller) {
    AddRecep = '';
    body=apexpages.currentpage().getparameters().get('att');   
           
    }
    
   public void sendpost(){
    String MySessionID = UserInfo.getSessionID();
      String  conId = ApexPages.currentPage().getParameters().get('Id');
      String  EmailCon =[Select email from Contact where Id=:conId ].email;
        String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
        string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
        String Acode= Userinfo.getuserid();
        String Oid = UserInfo.getOrganizationId();
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);
   Blob data6 = Blob.valueOf(to);
   Blob data7 = Blob.valueOf(AddRecep);
  Blob data8 = Blob.valueOf(subject);
   Blob data9 = Blob.valueOf(body);
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );
   Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 );
    Blob encryptedData7 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data7 );
    Blob encryptedData8 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data8 );
   Blob encryptedData9 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data9 );
        String b64Data = EncodingUtil.base64Encode(encryptedData);
        String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
        String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
        String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
        String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
        String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
       String b64Data6 = EncodingUtil.base64Encode(encryptedData6);
       String b64Data7 = EncodingUtil.base64Encode(encryptedData7);
        String b64Data8 = EncodingUtil.base64Encode(encryptedData8);
       String b64Data9 = EncodingUtil.base64Encode(encryptedData9);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');
     String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
     String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
     String ocode= EncodingUtil.urlEncode(b64Data5, 'UTF-8');
    String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');
     String cccc= EncodingUtil.urlEncode(b64Data7, 'UTF-8');
     String sbj= EncodingUtil.urlEncode(b64Data8, 'UTF-8');
    String bdy= EncodingUtil.urlEncode(b64Data9, 'UTF-8');
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        req.setEndpoint('https://www.demomail.net/sf/api/SaveDemoMailPost');
        
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/x-www-form-urlencoded');        req.setBody('AUCode='+aucode+'&SOrgID='+ocode+'&Subject='+sbj+'&Body='+bdy+'&To='+too+'&CC='+cccc+'&Bcc='); 
system.debug('???'+aucode);
        try {
                res = http.send(req);
                if (res.getBody() != null) {
                    System.debug('#Success!');
                } else {
                    System.debug('HTTP error: ' + res.getStatusCode());
                }
                System.debug(res.getBody());
            } 
        catch(System.CalloutException e) 
            {
                System.debug('Callout error: '+ e);
            }
   }
        
    public List<wrapContact> wrapContactList {get; set;}
    public List<Contact> selectedContacts{get;set;}
    Public String selectId {get;set;}
    public sendmailp(){
        body = apexpages.currentpage().getparameters().get('att');
            if(wrapContactList == null) {
            wrapContactList= new List<wrapContact>();
            for(Contact a: [SELECT  Name,FirstName,LastName,Email,Title FROM Contact ORDER by Name ASC]) {
                wrapContactList.add(new wrapContact(a));
           }
        }
        normalList = true;
        selectedList = false;
        body = ''; 
       to = EmailCon; 
    }         
    public void processSelected() {
        AddRecep = '';
        selectedContacts = new List<Contact>();
        for(wrapContact wrapContactObj : wrapContactList) {
            if(wrapContactObj.selected == true) {
                selectedContacts.add(wrapContactObj.acc);
                if (AddRecep == '') {
                    AddRecep = wrapContactObj.acc.Email;
                } else {
                    AddRecep += ';' + wrapContactObj.acc.Email ;
                }
            }
        }
    }
    public class wrapContact {
        public Contact acc {get; set;}
        public Boolean selected {get; set;}
        public wrapContact (Contact a) {
            acc = a;
            selected = false;
        }
    } 
    
    public List<video> ConsoleWrapperList1{get;set;}
    public String consolewrap{get;set;}
    public String  SessionId = '';
    public void callapi2(){
    String  SessionId = '';
    string testSessionId = '';
    for( consolewrap cwt : ConsoleWrapperList){
        testSessionId += cwt.sid;
        if(cwt.selected){
            if(SessionId == ''){
                SessionId += cwt.SessionId;
            }else{
                SessionId += ','+ cwt.SessionId;
            }
        }
    } 
    system.debug('testSessionId+++'+testSessionId);
    List<video> ConsoleWrapperList1 = new List<video>();
    HttpRequest req = new HttpRequest(); 
    HttpResponse res = new HttpResponse();
    Http http = new Http(); 
    system.debug('SessionId+++'+SessionId);
   string url = 'https://www.demomail.net/sf/api/SendVideoContactPreview?AUCode='+aucode+'&SOrgID='+ocode+'&SessionIds='+SessionId;
      req.setEndpoint(url); 
    req.setMethod('GET');
    res = http.send(req);
    if(res.getstatusCode() == 200 && res.getbody() != null){ 
        String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
        ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class);
        system.debug('ConsoleWrapperList1+++'+ConsoleWrapperList1);
        body = ConsoleWrapperList1.get(0).bodyT;
    }
}
    public String ssnid{get;set;}
    public boolean normalList{get;set;}
    public boolean selectedList{get;set;}
    public String Title{get;set;} 
    public Boolean selected {get; set;} 
    public List<consolewrap> ConsoleWrapperList{get;set;}
    public List<consolewrap> getperformcallout(){
        ConsoleWrapperList = new List<consolewrap>();
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
     string url = 'https://www.demomail.net/sf/api/SendVideoContact?AUCode='+aucode+'&SOrgID='+ocode+'&id='+SessionId;
        System.debug('##: '+ SessionId);
      req.setEndpoint(url);
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){
            ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class); 
            System.debug('value: '+ ConsoleWrapperList );
        }
        return consolewrapperlist;
    }
    
}

 
Any one pls remove this error from test class
System.NullPointerException: Argument cannot be null.
Class.Leadpage.<init>: line 19, column 1
Class.Leadtestsss.runTest1: line 31, column 1
TEST Class

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

       Contact contact = new Contact();
       contact.FirstName = 'Todda';
       contact.LastName = 'Wilmss';
       contact.AccountID = account.Id;
       contact.Email = 'twilms@verisign.conm';
       contact.MobilePhone = '918527116723';
       insert contact; 
              
       Lead lead = new Lead();
       lead.FirstName = 'test';
       lead.LastName = 'foo'; 
       lead.company='Acc3';      
       insert lead; 
            
        test.startTest();
        PageReference pageRef = Page.Leadpage;
        pageRef.getParameters().put('Id', String.valueOf(lead.Id));
        Test.setCurrentPage(pageRef);
        Test.setMock(HttpCalloutMock.class, new Leadpagemock());
        ApexPages.StandardController sc1 = new ApexPages.StandardController(Lead);//Instance of your object
        Leadpage testDObj = new Leadpage();
        testDObj.getperformcallout();
        test.stopTest();  
            
    }    
}
 
Page MOCK Class

@IsTest(seeAllData = false)
global class Leadpagemock implements HttpCalloutMock 
{    
    global HTTPResponse respond(HTTPRequest req) {        
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type', 'application/json');
        res.setBody('[{"foo":"bar"}]');
        res.setStatusCode(200);        
        return res;
    }   
}
 
Main Class

public class Leadpage{
    public Leadpage(ApexPages.StandardController controller) {
    }    
    public  Leadpage()
        {}        
     public   String MySessionID = UserInfo.getSessionID();
     public   String conId = ApexPages.currentPage().getParameters().get('Id');
     public   String EmailCon=[Select email from Lead where Id=:conId ].email;
     public   String myurl= URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/c/10.0/' + UserInfo.getOrganizationId();    
     public   string c='eU9WzoFgU4n8Apu5PYxcNGRZswRDZJWDEMdbQVU85gw=';
     public   String Acode='00530000000rLMxAAM';
     public   String Oid = UserInfo.getOrganizationId();  
    Blob cryptoKey= EncodingUtil.base64Decode(c);
    Blob data = Blob.valueOf(MySessionID );
    Blob data1 = Blob.valueOf(myurl);
    Blob data2 = Blob.valueOf(conId);
    Blob data3 = Blob.valueOf(EmailCon);
    Blob data4 = Blob.valueOf(Acode);
    Blob data5 = Blob.valueOf(Oid);   
    Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
    Blob encryptedData1 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data1);
    Blob encryptedData2 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data2);
    Blob encryptedData3 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data3 );
    Blob encryptedData4 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data4 );
    Blob encryptedData5 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data5 );  
    public    String b64Data = EncodingUtil.base64Encode(encryptedData);
    public    String b64Data1 = EncodingUtil.base64Encode(encryptedData1);
    public    String b64Data2 = EncodingUtil.base64Encode(encryptedData2);
    public    String b64Data3 = EncodingUtil.base64Encode(encryptedData3);
    public    String b64Data4 = EncodingUtil.base64Encode(encryptedData4);
    public    String b64Data5 = EncodingUtil.base64Encode(encryptedData5);
    String testurl='sessionID='+EncodingUtil.urlEncode(b64Data, 'UTF-8')+'&serverUrl='+EncodingUtil.urlEncode(b64Data1, 'UTF-8')+'&contactID='+EncodingUtil.urlEncode(b64Data2, 'UTF-8')+'&email='+EncodingUtil.urlEncode(b64Data3, 'UTF-8');   
    public String email = EncodingUtil.urlEncode(b64Data3, 'UTF-8');    
    public String aucode= EncodingUtil.urlEncode(b64Data4, 'UTF-8');
    public String ocode= EncodingUtil.urlEncode (b64Data5,  'UTF-8');
  
    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;
        req.setEndpoint(url);
        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;
    }  
}

 
Encryption are not working plss Help its urgent

 
public String to{get; set;}
    Blob data6 = Blob.valueOf(to);
   Blob encryptedData6 = Crypto.encryptWithManagedIV('AES256', cryptoKey, data6 );
   public    String b64Data6 = EncodingUtil.base64Encode(encryptedData6);
   public String too= EncodingUtil.urlEncode(b64Data6, 'UTF-8');

 
<apex:pageBlockTable value="{!performcallout4}" var="wrap" width="100%">

<apex:column headerValue="Subject" value="{!wrap.Subject}"/>

<apex:column headerValue="Video Title" value="{!wrap.SessionTitle}"/>
<apex:column headerValue="Sent Date" value="{!wrap.SentDate}"/>
<apex:column headerValue="Subject" value="{!wrap.Subject}"/>
<apex:column headerValue="Sent Date" value="{!wrap.SentDate}"/>

<apex:column headerValue="Recipients" value="{!wrap.NoOfContacts}"/>
<apex:column headerValue="Opens" value="{!wrap.OpenTimes}"/>
<apex:column headerValue="View Count" value="{!wrap.ViewedTimes}"/>
<apex:column headerValue="Part of mail merge?" value="{!wrap.SenderEmail}"/>
</apex:pageBlockTable>


Visualforce Error
Help for this Page
System.AssertException: Assertion Failed: <html><head><title>Object moved</title></head><body> <h2>Object moved to <a href="https://www.demomail.net/sf/">here</a>.</h2> </body></html> 

 
public class Contactpage1{
 public Contactpage1(ApexPages.StandardController controller) {
    }
    
public List<contactDemoMailSentwrap> ConsoleWrapperList4{get;set;}
public List<contactDemoMailSentwrap> getperformcallout4(){

ConsoleWrapperList4 = new List<contactDemoMailSentwrap>();

HttpRequest req = new HttpRequest();

HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('https://www.demomail.net/sf/api/ContactDemoMailSent?Email=twilms@verisign.con&NameSpace=Demos%20On%20Demand%20Report'); 
req.setTimeout(10000);
req.setMethod('GET');

res = http.send(req);
//System.assert(false,res.getBody());
if(res.getstatusCode() == 200){
String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
ConsoleWrapperList4= (List<contactDemoMailSentwrap>)System.JSON.deserialize(replaceIllegal,List<contactDemoMailSentwrap>.class);
System.debug('***********: '+ ConsoleWrapperList4 );
}
return consolewrapperlist4;
}
}

 
I want to write Test class for belowclass
public class Contactpage{
 public Contactpage(ApexPages.StandardController controller) {
    }
public List<contactDemoMailSentwrap> ConsoleWrapperList4{get;set;}
public List<contactDemoMailSentwrap> getperformcallout4(){
ConsoleWrapperList4 = new List<contactDemoMailSentwrap>();

HttpRequest req = new HttpRequest();

HttpResponse res = new HttpResponse();

Http http = new Http();
req.setEndpoint('https://www.demomail.net/sf/api/ContactDemoMailSent?Email=twilms@verisign.con&NameSpace=Demos%20On%20Demand%20Report'); 

req.setMethod('GET');
req.setTimeout(10000);
res = http.send(req);
//System.assert(false,res.getBody()+'-----');
if(res.getstatusCode() == 200 && res.getbody() != null){
String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','');
ConsoleWrapperList4=(List<contactDemoMailSentwrap>)System.JSON.deserialize(replaceIllegal,List<contactDemoMailSentwrap>.class);

}

return consolewrapperlist4;
}
}

 
I want to display value like this. (highlighted with Cross cancel)

User-added image

 
public pageReference send(){
    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();  
    List<String> ccAddresses =new List<String>();  
  if (AddRecep != '' && AddRecep != null) {
     ccAddresses  = AddRecep.split(';');
    email.setTargetObjectId(conId);
    email.setCcAddresses(ccAddresses);
    email.setSubject(subject);
    email.setHtmlBody(body);    
  Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});  
  for ( Messaging.sendEmailResult result : res ) {
           if ( !res[0].isSuccess () ) {
               System.debug ( result  );
           }          
       }       
 }  
return null;        
}
Not getting any Value in CK editor on Parent Page . Value is coming through action button of child page
How to reRender the Parent page
//////////////////////Parent Page////////////////////////////////
<apex:page StandardController="Contact"  extensions="AccountSelectClassController" > 
<script>
var newWin=null;
        function check(){
            var url='/apex/selectvideo2';
            newWin=window.open(url, 'Popup','height=500,width=700,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        }

        function closePopup(){
            if (null!=newWin){
                newWin.close();
             
            }  
        }
</script> 
<apex:form id="frmId">
<apex:outputLabel value="Choose Video "/>
<apex:outputLink onClick="check();return false;"> <br/>
Click here to choose session </apex:outputLink>
<br/><br/>
<apex:outputLabel value="Body" for="Body"/>:<br/>
<apex:inputtextarea value="{!body}" id="body" styleClass="ckeditor" richtext="false" style="width: 500px; height: 150px;">
</apex:inputtextarea>
<br/><br/><br/>        
<apex:includescript value="{!URLFOR($Resource.CkEditor,'ckeditor/ckeditor.js')}" />
</apex:pageblock>
</apex:form>
</apex:page>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ child Pop up page////////////////////////////////
<apex:commandButton value="Done" onclick="CloseWindow(); return false;" action="{!callapi2}" />
</apex:pageBlock>
<script>
        function CloseWindow(){
            var winMain=window.opener;
            if (null==winMain){
                winMain=window.parent.opener;
            }
            winMain.closePopup()   
        }
</script>    
</apex:form>

/////////////////////////Controller\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

public void callapi2(){
 //body = '';
 String  SessionId = '';
 for( consolewrap cwt : selectedWrapperList){
 if(cwt.selected){
  if(SessionId == ''){
   SessionId += cwt.sid;
  }else{
   SessionId += ','+ cwt.sid;
  }
  }
   } 
 
      List<video> ConsoleWrapperList1 = new List<video>();
        HttpRequest req = new HttpRequest(); 
        HttpResponse res = new HttpResponse();
        Http http = new Http(); 
        req.setEndpoint('http://webapi.demomail.net/test/SendVideoBody.js?id='+SessionId); 
        req.setMethod('GET');
        res = http.send(req);
        if(res.getstatusCode() == 200 && res.getbody() != null){ 
            String replaceIllegal= res.getbody().replaceAll('\n','').replaceAll('\r','').replace('','');
            ConsoleWrapperList1=(List<video>)System.JSON.deserialize(replaceIllegal,List<video>.class);
            
            body = ConsoleWrapperList1.get(0).bodyT;
            System.debug('***********: '+ body );
        }
  
 }
Problem is not getting mail to List mail of address  only mail goes to "rupesh@webmindinfotech.com". But i want List of mail that should be fire.

Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
     List<String> toAddress =new List<String>();
     String emailadd = 'rupesh@webmindinfotech.com';
 List<String> toAddresses = emailadd.split(';');
     email.setToAddresses(toAddresses );
    email.setSubject(subject);
    email.setPlainTextBody(body);
    email.setBccSender(true);
  Messaging.SendEmailResult [] res = Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});  
  for ( Messaging.sendEmailResult result : res ) {
           if ( !res[0].isSuccess () ) {
               System.debug ( result  );
           }
           else{
               ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' );
               ApexPages.addMessage(msg);
           }
       }
  return null;        
}
public SendEmail(){
        body = apexpages.currentpage().getparameters().get('att');
    }
I want to send email. 
But TO Address should be number of email address. 
Note :- email address are not relating with any contact or Lead Object

Some sample Code plss