Loading
Feature degradation | Gmail Email delivery failureRead More
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Integration Procedure Unit Testing from Apex

          Integration Procedure Unit Testing from Apex

          You can set up a test class in Apex and use it to call and test an Integration Procedure. In the core runtime, HTTP mocking isn’t possible, and real HTTP calls occur during test execution.

          The following is an example unit test of an Integration Procedure:

          @isTest(seeAllData=true)
          global with sharing class TestIntegrationProcedure
          {
              static testMethod void testIP()
              {
                  Map<String, Object> inputMap = new Map<String, Object>();
                  inputMap.put('AccountName', 'Acme');
                  ConnectAPI.IntegrationProcedureServiceRunInputRepresentation apexInput = new ConnectAPI.IntegrationProcedureServiceRunInputRepresentation();
                  List<String> stringList = new List<String>();
                  String serializedInputMap = JSON.serialize(inputMap);
                  stringList.add(serializedInputMap);
                  apexInput.input = stringList;
          
                  ConnectAPI.IntegrationProcedureServiceRunOutputRepresentation output = ConnectAPI.OmniDesignerConnect.integrationProcedureExecute('Type_Subtype', apexInput);
                  List<String> responseList = output.response;
                  String currentSerResponse = responseList[0];
                  Map<String, Object> currentResponseObj = (Map<String, Object>)JSON.deserializeUntyped(currentSerResponse);
          
                  Object response = currentResponseObj.get('result');
                  System.assertNotEquals(null, response);
              }
          }   

          Note these features of the example:

          • You must use Salesforce's seeAllData property on the @isTest annotation. This ensures that the unit test sees the Omnistudio SObject data in the org.

          • Use the ConnectAPI.OmniDesignerConnect.integrationProcedureExecute() Connect API to run the Integration Procedure.

          • The Type_Subtype parameter specifies the Integration Procedure to test. Replace it with the Type and SubType of your Integration Procedure, separated by an underscore.

           
          Loading
          Salesforce Help | Article