I have implemented several callouts using the Continuation object based on the documentation here. But there is no reference for unit tests. The section in the developer guide only shows how to test with instance methods not with Aura Enabled static methods. I have tried to follow along and found one other discussion on Stack Exchange. But I don't seem to get the correct data into my continuation method. It throws a null pointer exception when I try to get the response status code.

Below is my Continuation and my call back method

 @AuraEnabled(Cacheable=true Continuation=true)
    public static Object resetPassWord(String federationId) {
        URLEndpoints__mdt endpoints = [
                SELECT Url__c,
                FROM URLEndpoints__mdt
                WHERE DeveloperName = :'Okta_Reset'
                LIMIT 1
        Continuation con = new Continuation(40);
        con.continuationMethod = 'processResetResponse';

        con.state = 'hello world';
        HttpRequest req = new HttpRequest();
        req.setEndpoint(endpoints.Url__c + federationId +
        req.setHeader('Authorization', 'SSWS' + Label.OktaApiToken);
        return con;
    public static Object processResetResponse(List<String> labels, Object state) {
        HttpResponse res = Continuation.getResponse(labels[0]);       
        if (res.getStatusCode() != 200) {
            return res.getBody();
        if (res.getStatusCode() == 200) {
            return res.getBody();
        return null;

Here is my unit test - I was just trying to pass anything into the call back to see if I get get a value. That is why the list of strings and I also tried setting the response.statuscode. But no luck.

    static void testOktaPasswordReset(){
        List<String>strings = new List<String>{'200'};
        String state = 'State';
        HttpResponse response = new HttpResponse();
        response.setBody('Mock response body');
        Continuation continuation =(Continuation)PatientOktaController.resetPassWord('123456');
        Test.setContinuationResponse('Continuation-1', response);
        //Map<String, HttpRequest> requestMap = obj.getRequests();
        Test.setContinuationResponse('Continuation -1', response);
        Object result = Test.invokeContinuationMethod(PatientOktaController.processResetResponse(strings, state), continuation);


1 Answer 1


I heard back from Salesforce about this today. The long and the short is that you can not test Static Continuation Methods. There is a workaround though.


I will post my code later if I get this working.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .