I am working with a supplier who proscribes DML operations on its application's objects. Instead, they ask us to call Rest resources in our org that they developed in order to interact with the data. I have developed a batch apex class which acts as a middle-ware component to pull data from an external system does some manipulations and then calls the rest resource the supplier created to push data. See below psuedo code:
global class BatchJob implements Database.Batchable<sObject>, Database.AllowsCallouts{
String query;
String Endpoint = 'https://api.*******';
private String API_Key;
private date cutOffDate= Date.newInstance(2001,01,01);
global Database.QueryLocator start(Database.BatchableContext bc){
query = 'Select Employee__ExternalId__c from Employee__c where Employee__EndDate__c != null';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Employee__c> scope){
/* 1. Call external API to get the required Data
2. With the data returned from above api call, do some stuff
and then generate as json and post it to the supplier's rest resource */
}
global void finish(Database.BatchableContext BC){
//Send Email
}
}
Coming to my question, for my test class now I need to insert into Employee__c but I would need to call the rest resource(another one not in the above code) of the supplier to insert into Employee__c. Would the employee insertion be rolled back?