function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
eclutarioeclutario 

Need help in unit testing Informatica Cloud REST API

Hi there,

 

Does anybody know how to create a unit test for this code below? I came across this when looking for a way to run my Informatica Cloud task in Salesforce remotely. Thanks in advance for the help!

 

Eric

 

public with sharing class OrderIntegration {

    @future (callout=true) 

    public static void runjob(String username, String password, String jobName, String jobType) {

        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http(); 

        req.setEndpoint('https://app.informaticaondemand.com/saas/api/1/runjob');
        req.setMethod('POST');
        req.setBody('username='+EncodingUtil.urlEncode(username, 'UTF-8')+
                           '&password='+EncodingUtil.urlEncode(password, 'UTF-8')+
                           '&jobName='+EncodingUtil.urlEncode(jobName, 'UTF-8')+
                           '&jobType='+EncodingUtil.urlEncode(jobType, 'UTF-8')); 

        try {
            res = http.send(req);
           }
           catch(System.CalloutException e) {
            System.debug('Job Error: '+ e);
            System.debug(res.toString());
        } 

    } 

}
amarcuteamarcute

Hi,

 

Here is an article covering how to write test methods for web service callouts.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_wsdl2apex_testing.htm

 

 

Nancy raiNancy rai
Following tutorial helps to learn - How to Import JSON data using Informatica (Read JSON Files or REST API)

https://zappysys.com/blog/read-json-informatica-import-rest-api-json-file/

Hope it helps!