• Jithin Chand
  • NEWBIE
  • 10 Points
  • Member since 2016
  • mindtree ltd

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

I have a REST callout to an external API. The Apex callout is causing callout error as it is taking more than 2 minutes to execute. 
However, when i use the same record in POSTMAN tool, i am getting the response in 10 seconds.

What could be the reson that there is so much variation in the time to execute the same functionality.
Hi,

Is it possible to integrate a third party content to einstein bots. My requirement is to set the dialogue and publish the content from third party to einstein bots. 

Is this possible?
Hi Friends,
Please help me on below scenerio, and let me know why the assert is failing. experts please suggest
As per my understanding the LeadSource value is populated in the batch class, but after executing the test class assert is not finding it, eventhough I placed assert after the Test.stopTest() method.

Again by providing the value in the test class, the assert works, is this the correct way to test?
as the value is suppose to be set by the execute method, it seems odd to me to set that value in the test class to pass the test
eg:
l.LeadSource = 'Dreamforce';

LeadProcessor.class
global class LeadProcessor implements Database.Batchable<sObject> {
   
    global Integer count = 0;

    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('SELECT Id, LeadSource FROM Lead');
    }

    global void execute(Database.BatchableContext bc, List<Lead>l_lst){
        List<lead> l_lst_New = new List<Lead>();
        for(Lead l:l_lst){
            l.LeadSource = 'Dreamforce';
            l_lst_New.add(l);
            count = count + 1;
        }
        Update l_lst_New;
    }

    global void finish(Database.BatchableContext bc){
        System.debug('count = '+count);
    }
}

LeadProcessorTest.class
@isTest
public class LeadProcessorTest {
@isTest
    public static void testit(){
        List<Lead> l_lst = new List<Lead>();
        for(Integer i=0;i<200;i++ ){
            Lead l = new Lead();
            l.LastName = 'name'+i;
            l.Company = 'Company';
            l.status = 'Random Status';
            l_lst.add(l);
        }
        INSERT l_lst;

        Test.startTest();
        LeadProcessor lp = new LeadProcessor();
        Database.executeBatch(lp);
        Test.stopTest();
        List<Lead> l_lstX = [SELECT Id, LastName, LeadSource FROM Lead];
        for(Lead l:l_lstX){
            //System.debug('Lead Last Name ' + l.LastName + ' LeadSource='+l.LeadSource);
        }
        System.assertEquals(200, [select count() from Lead where LeadSource = 'Dreamforce'],'The count should be 200');
    }
}

Thanks,
James
Hi All,

I have a REST callout to an external API. The Apex callout is causing callout error as it is taking more than 2 minutes to execute. 
However, when i use the same record in POSTMAN tool, i am getting the response in 10 seconds.

What could be the reson that there is so much variation in the time to execute the same functionality.
Hi,

Is it possible to integrate a third party content to einstein bots. My requirement is to set the dialogue and publish the content from third party to einstein bots. 

Is this possible?
While implementing emp API in LWC to subscribe the platform event I  find out that there is small issue in sample code snipit given in documentation.
Issue is in handleSubscribe method in js below is the code given in documentation:
handleSubscribe() {
        // Callback invoked whenever a new event message is received
        const messageCallback = function(response) {
            console.log('New message received : ', JSON.stringify(response));
            // Response contains the payload of the new message received
        };

        // Invoke subscribe method of empApi. Pass reference to messageCallback
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on successful subscribe call
            console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
            this.subscription = response;
            this.toggleSubscribeButton(true);
        });
    }
 Correction is required in messageCallback method which should be as below:
const messageCallback = (response) => {
        console.log('New message received : ', JSON.stringify(response));
        this.payload = JSON.stringify(response);
        console.log('this.payload: ' + this.payload);
        // Response contains the payload of the new message received
    };
We have to use arrow function as it does not have its own scope.  
While implementing emp API in LWC to subscribe the platform event I  find out that there is small issue in sample code snipit given in documentation.
Issue is in handleSubscribe method in js below is the code given in documentation:
handleSubscribe() {
        // Callback invoked whenever a new event message is received
        const messageCallback = function(response) {
            console.log('New message received : ', JSON.stringify(response));
            // Response contains the payload of the new message received
        };

        // Invoke subscribe method of empApi. Pass reference to messageCallback
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on successful subscribe call
            console.log('Successfully subscribed to : ', JSON.stringify(response.channel));
            this.subscription = response;
            this.toggleSubscribeButton(true);
        });
    }
 Correction is required in messageCallback method which should be as below:
const messageCallback = (response) => {
        console.log('New message received : ', JSON.stringify(response));
        this.payload = JSON.stringify(response);
        console.log('this.payload: ' + this.payload);
        // Response contains the payload of the new message received
    };
We have to use arrow function as it does not have its own scope.