+ Start a Discussion
rupesh ranjanrupesh ranjan 

Need to write test class urgent basis

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; 
             
          }
 }

 
Mahesh DMahesh D
Hi

Please follow the below link:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm

Regards,
Mahesh