• Prateek jain 39
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hi All, 

I am trying to Write an test class for the below Get Method inside one class.

public List<Invoice_Line_Item__c> lstInvoiceLineItemsShow{
        get{
            lstInvoiceLineItemsShow = new List<Invoice_Line_Item__c>();
            for(Integer i = 0 ; i < (lstInvoiceLineItems.size() < MAX_RECORDS_TO_SHOW ? lstInvoiceLineItems.size() : MAX_RECORDS_TO_SHOW) ; i++){
                lstInvoiceLineItemsShow.add(lstInvoiceLineItems.get(i));
            }
            return lstInvoiceLineItemsShow;
        }
        set;
    }

Here i am not able to cover code inside get part.

I am trying the below code in test class in order to cover it..

   List<Invoice_Line_Item__c> instance = new List<Invoice_Line_Item__c>();
instance.lstInvoiceLineItems = listinvioceitem;

Any idea , what else can be done here, thanks

 
Hi All,

Has anybody done integration from Salesforce to Job portals Like "Naukri" and "Monster" , I have a requirement where i need to integrate salesforce With for Publishing jobs to Naukri.

Please Let me know if any bodody have Any Sample Link Or Code that can get me started Here.

Regards,
Prateek 
Hi All, 

I am trying to Host a CSV file to Amazone Server and get the Url and Use it further in my Next Call , Please see the below code that i am trying here.

public class amazonservices1 {

    public String result { get; set; }





public void show (){

Attachment attach = [
    select Body,
        ContentType,
        Name
    from Attachment where id = '00Pp0000001SG84'
    limit 1
];

String attachmentBody = EncodingUtil.base64Encode(attach.Body);


String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
String key = 'AKIAI4T5HLSA7WIMB6TQ';
String secret = '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';
String bucketname = 'documentfromsalesforce';
String host = 's3-us-west-2.amazonaws.com';
String method = 'PUT';
String filename = attach.Id + '-' + attach.Name;

HttpRequest req = new HttpRequest();
req.setMethod(method);
req.setEndpoint('https://' + bucketname + '.' + host + '/' + bucketname + '/' + filename);
req.setHeader('Host', bucketname + '.' + host);
req.setHeader('Content-Length', String.valueOf(attachmentBody.length()));
req.setHeader('Content-Encoding', 'UTF-8');
req.setHeader('Content-type', attach.ContentType);
req.setHeader('Connection', 'keep-alive');
req.setHeader('Date', formattedDateString);
req.setHeader('ACL', 'public-read');
req.setBody(attachmentBody);

String stringToSign = 'PUT\n\n' +
    attach.ContentType + '\n' +
    formattedDateString + '\n' +
    '/' + bucketname + '/' + bucketname + '/' + filename;

String encodedStringToSign = EncodingUtil.urlEncode(stringToSign, 'UTF-8');
Blob mac = Crypto.generateMac('HMACSHA1', blob.valueof(stringToSign),blob.valueof(secret));
String signed = EncodingUtil.base64Encode(mac);
String authHeader = 'AWS' + ' ' + key + ':' + signed;
req.setHeader('Authorization',authHeader);
String decoded = EncodingUtil.urlDecode(encodedStringToSign , 'UTF-8');

Http http = new Http();

HTTPResponse res = http.send(req);

result = res.getBody();

}

But Whenever i am Hitting the Amazone server i am Getting the Below Error:

<?xml version="1.0" encoding="UTF-8"?><Error><Code>HttpVersionNotSupported</Code><Message>The HTTP version specified is not supported.</Message><RequestId>F7ADFC5847D19928</RequestId><HostId>BNow8MtftjhZQkzeQzgZqyUVX+M6fSLbeW0HGysyu+1wF+Dr+Tcf+IO+1Ht1VfxA6F00J6Z0D64FXUxCFjMZz62UW6pkPGzS</HostId></Error>

Please Help Me out from This as its very Ungent for Mee, Thanks
 
HI All,

I have a Requirement where i need to create a Dynamic Custom setting based on the input Custom setting type., Please Check the below Code.

//Here i am creating generic Method for Deleting the sahre record which can be called from any other Functionality.

  public List<SObject> haringDeletion(Map < String, set< id>> recordIdsMap, String FuncName) {

// Here Key i want to Make Dynamic
Map<String, BR_OpenPositiion__c> CustomMap;
    
    //Here FuncName  is Functionality Name.
    if(FuncName == 'SharingWithBackupUser'){

    CustomMap = BR_OpenPositiion__c.getAll();

    }else if (FuncName == 'StopVacationSharing'){
    //Map<String, BR_RTVOnVacation__c> CustomMap;
    
    CustomMap = BR_RTVOnVacation__c.getAll();
    
    }

So as you can see from above Code based on the Functionlaty Name i want to Populate CustomMap with Custom setting data, I.e "BR_RTVOnVacation__c" or "BR_OpenPositiion__c".

Can you guys Please Suggest something Here to sort it out, thanks.
Hi All,

i trying to hit request to external Gateway using Https request Like this.

    public PageReference test() {
    
    XMLData=new List<String>();
    
       HttpRequest req = new HttpRequest();
   // creation of list     
       
    string enddata = 'https://api.exacttouch.com/API/mailing/?type=list&activity=Add&data=<DATASET><CONSTANT><ApiKey>17cb2d34f158ddcdf427ca31ecd7b952</ApiKey><RefIp></RefIp><RefWeb></RefWeb></CONSTANT><INPUT><Name>newvflist11</Name><Description></Description><Active>1</Active></INPUT></DATASET>';
     
     
    // string enddata ='https://github.com//api.exacttouch.com/API/mailing/?type=contact&activity=Add&data=<DATASET><CONSTANT><ApiKey>17cb2d34f158ddcdf427ca31ecd7b952</ApiKey><RefIp></RefIp><RefWeb></RefWeb></CONSTANT><INPUT><Unique_id></Unique_id><AddEmail>'+email+'</AddEmail><AttributeValues></AttributeValues><Attributecount>1</Attributecount><ListMember>138</ListMember><DoubleOptin></DoubleOptin><TriggerEmail></TriggerEmail></INPUT></DATASET>';
       
    req.setEndpoint(enddata);
    req.setMethod('GET');
    system.debug('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'+req);
    Http http = new Http();
    HttpResponse res = http.send(req);
    
     result1 =  res.getBody();
   
    Dom.Document doc = res.getBodyDocument();
 
    Dom.XMLNode DATASET=  doc.getRootElement();
    
    Dom.XMLNode OUTPUT =  DATASET.getChildElement('OUTPUT', null);
      return null ;

    }

But Getting this Error : System.CalloutException: Server chose TLSv1, but that protocol version is not enabled or not supported by the client.

IF i am hitting the Url Directly its sending back the response.

Can any one Please Help.



 
Hi All, 

I am trying to Write an test class for the below Get Method inside one class.

public List<Invoice_Line_Item__c> lstInvoiceLineItemsShow{
        get{
            lstInvoiceLineItemsShow = new List<Invoice_Line_Item__c>();
            for(Integer i = 0 ; i < (lstInvoiceLineItems.size() < MAX_RECORDS_TO_SHOW ? lstInvoiceLineItems.size() : MAX_RECORDS_TO_SHOW) ; i++){
                lstInvoiceLineItemsShow.add(lstInvoiceLineItems.get(i));
            }
            return lstInvoiceLineItemsShow;
        }
        set;
    }

Here i am not able to cover code inside get part.

I am trying the below code in test class in order to cover it..

   List<Invoice_Line_Item__c> instance = new List<Invoice_Line_Item__c>();
instance.lstInvoiceLineItems = listinvioceitem;

Any idea , what else can be done here, thanks