• vicky rathi
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
Hello Developers
  pls help me How to cover these line in test class I am try a lot but not success. MY test code is below
@isTest
private class MSDbugScheduleLogHistoryCl_Test {
  static testMethod void MSDbugScheduleLogHistoryCl_method() {
    MS_Sync_App__c oMSSyncApp = new MS_Sync_App__c(Name = 'WooCommerce');
    insert oMSSyncApp;
    
    MS_Connector__c oMSConnector = new MS_Connector__c(Name = 'WooCommArcs', Connector_Type__c = oMSSyncApp.Id);
    insert oMSConnector;
    
    String sConId = ApexPages.currentPage().getParameters().put('conTypeId', oMSSyncApp.Id);
    
    MS_Schedule__c oMSSchedule = new MS_Schedule__c(Name = 'Test', Connector__c = oMSConnector.Id);
    insert oMSSchedule;
    String sId = ApexPages.currentPage().getParameters().put('ScheduleId', oMSSchedule.Id);
    
    MS_Schedule_History__c oMSScheduleHistory = new MS_Schedule_History__c(MS_Schedule__c = oMSSchedule.Id);
    insert oMSScheduleHistory;
    String slogId = ApexPages.currentPage().getParameters().put('logid', oMSScheduleHistory.Id);
    
    MSDbugScheduleLogHistoryCl oMSDbugScheduleLogHistoryCl = new MSDbugScheduleLogHistoryCl();
    oMSDbugScheduleLogHistoryCl.sScheduleId = sId;
    oMSDbugScheduleLogHistoryCl.slogId = slogId;
    oMSDbugScheduleLogHistoryCl.sId = oMSScheduleHistory.Id;
    oMSDbugScheduleLogHistoryCl.beginning();
	oMSDbugScheduleLogHistoryCl.next();
	oMSDbugScheduleLogHistoryCl.previousRecord();
	oMSDbugScheduleLogHistoryCl.last();
	oMSDbugScheduleLogHistoryCl.getDisableNext();
    oMSDbugScheduleLogHistoryCl.getDisablePrevious();
	oMSDbugScheduleLogHistoryCl.Previous();
    oMSDbugScheduleLogHistoryCl.Mapping(); 
    oMSDbugScheduleLogHistoryCl.closePopup();
    oMSDbugScheduleLogHistoryCl.showPopup();
    System.assert(oMSSchedule.Id != null);
  }
}

How to cover these line in test class
Here is my class 

public with sharing class XeroOAuthUtility {
    
    
    public static HttpRequest signRequest(HttpRequest req, String consumerKey) {

      
        String nonce = String.valueOf(Crypto.getRandomLong());

        
        String timestamp = String.valueOf(DateTime.now().getTime() / 1000);

        
        Map<String,String> parameters = new Map<String,String>();
        parameters.put('oauth_version', '1.0');
        parameters.put('oauth_nonce', nonce);
        parameters.put('oauth_timestamp', timestamp);

        // RSA-SHA1 is the signature method used for the Xero authentication
        parameters.put('oauth_signature_method','RSA-SHA1');
        parameters.put('oauth_consumer_key', consumerKey);

        // As no token is requested, set the token as the consumer key. The Xero API doesn't use tokens, but rather uses 1-legged OAuth to make requests
        parameters.put('oauth_token', consumerKey);

        // Generate signature
        String signature = generateSignature(req, consumerKey, parameters);

        // Now take the generated signature add to the headers
        req.setHeader('Authorization', generateHeader(signature, parameters));

        return req;
    }


    private static String generateHeader(String signature, Map<String,String> parameters) {

        // Add OAuth value to the start of the header
        String header = 'OAuth ';

        // Itererate of all paramneters
        for (String key : parameters.keySet()) {

            // Add each paramaeter to the header string
            header = header + key + '="' +parameters.get(key)+ '", ';
        }
        
       
        return header + 'oauth_signature="' + EncodingUtil.urlEncode(signature, 'UTF-8') + '"';
    }

   
    private static String generateSignature(HttpRequest req, String consumerSecret, Map<String,String> parameters) {

        
        String baseString = createBaseString(req, parameters);
        Blob signatureBlob = System.Crypto.signWithCertificate('RSA-SHA1', Blob.valueOf(baseString), 'XeroCertificate');
        return EncodingUtil.base64Encode(signatureBlob);  
    }


   
    private static String createBaseString(HttpRequest req, Map<String,String> parameters) {

       
        Map<String,String> p = parameters.clone();

       
        if (req.getMethod().equalsIgnoreCase('post') && req.getBody() != null &&
            req.getHeader('Content-Type') == 'application/x-www-form-urlencoded'
        ) {
            
        
            p.putAll(getUrlParams(req.getBody()));
        }

       
        String host = req.getEndpoint();

      
        Integer n = host.indexOf('?');

       
        if (n > -1) {

            p.putAll(getUrlParams(host.substring(n + 1)));

            
            host = host.substring(0,n);
        }

        
        List<String> keys = new List<String>();
        keys.addAll(p.keySet());
        keys.sort();

        
        String urlString = keys.get(0) + '=' + p.get(keys.get(0));
        for (Integer i = 1; i < keys.size(); i++) {

            urlString = urlString + '&' + keys.get(i) + '=' + p.get(keys.get(i));
        }

       
        return req.getMethod().toUpperCase() + '&' + EncodingUtil.urlEncode(host, 'UTF-8') + '&' + EncodingUtil.urlEncode(urlString, 'UTF-8');
    }
    private static Map<String,String> getUrlParams(String value) {

        Map<String,String> res = new Map<String,String>();

      
        if (value == null || value=='') {

            return res;
        }

       
        for (String s : value.split('&')) {

            List<String> kv = s.split('=');

            if (kv.size() > 1) {

               
                String encName = EncodingUtil.urlEncode(EncodingUtil.urlDecode(kv[0], 'UTF-8'), 'UTF-8').replace('+','%20');
                String encValue = EncodingUtil.urlEncode(EncodingUtil.urlDecode(kv[1], 'UTF-8'), 'UTF-8').replace('+','%20');
                res.put(encName,encValue);
            }
        }
        return res;
    }

}

my test class is 

@isTest(SeeAllData=true)
public with sharing class XeroOAuthUtilityTest{
        
        Public Static TestMethod Void TestOAuth(){
       
                Test.StartTest();
                 Xero_Settings__c xeroseting = new Xero_Settings__c();
                xeroseting.name = 'testName';
               xeroseting.Consumer_Key__c = 'testConsumer';
                xeroseting.Endpoint__c = 'www.xero.com';
                insert xeroseting;
           
           /* SingleRequestMock fakeResponse = new SingleRequestMock(200, 'Complete', '[{"Name": "sForceTest1"}]', null);
       Test.setMock(HttpCalloutMock.class, fakeResponse);  
       XeroCalloutUtility.executeCallout(' request.setMethod','request.setEndpoint','request.setBody');   */  
        
         HttpRequest request =  new HttpRequest();
       request.setMethod('post');
       request.setHeader('Content-Type', 'application/x-www-form-urlencoded');
       request.setBody('abc');    
        //HttpResponse response = new HTTP().send(request);
       
         
        XeroOAuthUtility.signRequest(request, 'testConsumer');
        Test.StopTest();
        }

how to pass the test class 
Hello 

Can any one help me to solve my issue
how to cover the these line I am try but not success

these line not coveringthis is my code to cover those line
how to cover those lines
Hello  Community

I have multiple grand parent Account and multiple email template(chose per account) .when the new order is create which grand child account is select in the order 
I want to send the email  to (grand accounts child) contact's email . I am try to send. I am success but problem is how to do when 10000 k accounts in my org and 1000k email templtes. I want to send dynamiclly. Any one Help me to do this senerio

Thanks in advance 
I am new in Salesforce. I want to show the Doc content on my vf page . I am able to show the PDF and Txt Content on the same page 
but when try to show the doc content its download or its show the cript formate. 

page code

 <!--    <apex:iframe frameborder="true" src="https://c.cs24.content.force.com/servlet/servlet.FileDownload?file={!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe> -->
         
       <apex:iframe frameborder="true" src="data:{!att.ContentType};base64,{!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe>  

controller code 
 public Document att {
        get {
            if (att == null) {
                att = [SELECT Id,Body, ContentType, Name FROM Document WHERE Name =: 'vcc credential data'];
            }
            return att;
        }
       private set;
    }
    public String pdf {
        get {
            
            List<Attachment> attch = [Select Id,Body, contentType, name from Attachment where  parentId =: AccountIdStr and Name='vcc credential data2.docx'];
                   // Blob  file = attch[0].body;
              system.debug('.......attch.........'+attch);
            if(attch!=Null && attch.Size()>0)
            return    EncodingUtil.Base64Encode(attch[0].body); 
                     //  return attch[0].Id;
            else  return  EncodingUtil.Base64Encode(att.body);
                          //  return att.Id; 
        }
Any One guide me how to show the doc content on vf page
               
 
Hello Developers
  pls help me How to cover these line in test class I am try a lot but not success. MY test code is below
@isTest
private class MSDbugScheduleLogHistoryCl_Test {
  static testMethod void MSDbugScheduleLogHistoryCl_method() {
    MS_Sync_App__c oMSSyncApp = new MS_Sync_App__c(Name = 'WooCommerce');
    insert oMSSyncApp;
    
    MS_Connector__c oMSConnector = new MS_Connector__c(Name = 'WooCommArcs', Connector_Type__c = oMSSyncApp.Id);
    insert oMSConnector;
    
    String sConId = ApexPages.currentPage().getParameters().put('conTypeId', oMSSyncApp.Id);
    
    MS_Schedule__c oMSSchedule = new MS_Schedule__c(Name = 'Test', Connector__c = oMSConnector.Id);
    insert oMSSchedule;
    String sId = ApexPages.currentPage().getParameters().put('ScheduleId', oMSSchedule.Id);
    
    MS_Schedule_History__c oMSScheduleHistory = new MS_Schedule_History__c(MS_Schedule__c = oMSSchedule.Id);
    insert oMSScheduleHistory;
    String slogId = ApexPages.currentPage().getParameters().put('logid', oMSScheduleHistory.Id);
    
    MSDbugScheduleLogHistoryCl oMSDbugScheduleLogHistoryCl = new MSDbugScheduleLogHistoryCl();
    oMSDbugScheduleLogHistoryCl.sScheduleId = sId;
    oMSDbugScheduleLogHistoryCl.slogId = slogId;
    oMSDbugScheduleLogHistoryCl.sId = oMSScheduleHistory.Id;
    oMSDbugScheduleLogHistoryCl.beginning();
	oMSDbugScheduleLogHistoryCl.next();
	oMSDbugScheduleLogHistoryCl.previousRecord();
	oMSDbugScheduleLogHistoryCl.last();
	oMSDbugScheduleLogHistoryCl.getDisableNext();
    oMSDbugScheduleLogHistoryCl.getDisablePrevious();
	oMSDbugScheduleLogHistoryCl.Previous();
    oMSDbugScheduleLogHistoryCl.Mapping(); 
    oMSDbugScheduleLogHistoryCl.closePopup();
    oMSDbugScheduleLogHistoryCl.showPopup();
    System.assert(oMSSchedule.Id != null);
  }
}

How to cover these line in test class
I am new in Salesforce. I want to show the Doc content on my vf page . I am able to show the PDF and Txt Content on the same page 
but when try to show the doc content its download or its show the cript formate. 

page code

 <!--    <apex:iframe frameborder="true" src="https://c.cs24.content.force.com/servlet/servlet.FileDownload?file={!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe> -->
         
       <apex:iframe frameborder="true" src="data:{!att.ContentType};base64,{!pdf}" scrolling="true" id="theIframe" width="470px" height="250px"></apex:iframe>  

controller code 
 public Document att {
        get {
            if (att == null) {
                att = [SELECT Id,Body, ContentType, Name FROM Document WHERE Name =: 'vcc credential data'];
            }
            return att;
        }
       private set;
    }
    public String pdf {
        get {
            
            List<Attachment> attch = [Select Id,Body, contentType, name from Attachment where  parentId =: AccountIdStr and Name='vcc credential data2.docx'];
                   // Blob  file = attch[0].body;
              system.debug('.......attch.........'+attch);
            if(attch!=Null && attch.Size()>0)
            return    EncodingUtil.Base64Encode(attch[0].body); 
                     //  return attch[0].Id;
            else  return  EncodingUtil.Base64Encode(att.body);
                          //  return att.Id; 
        }
Any One guide me how to show the doc content on vf page
               
 
Hi guys.. I want to integrate facebook on salesforce.i want to know the process regarding this.
I want to fetch some data regaring the user..
pls tell me what things are required as i am using REST api.
 

I have a .doc type  attachment  , Attachment contains some images and text . I want to show all content of this attachment on vf page. 

I am able to show pdf, images type attachment preview on vf page , issue is only with (.doc, docx, .ppt ) file. it downloads the attachment instead of showing in new tab.

If attachment is 'attach' which is document file and it may contain images and text.
If I convert body to string like this  and show string on vf page in outputtext
string attachbody =  attach.body.tostring();
I am getting error not UTF-8 type string,

if I use this code show string on vf page in outputtext
string attachbody =  base64Encode(attach.body);
I am getting exceed 135 kb error

Your help would be appriciated. Please send me sample code. 
OR javascript jquery code if required. 

Hi

 

I have word docx file in notes and attachments.I want to display it on my vf page.Is there any way to do this?

 

Thanks

Ishan Sharma