afv-library/skills/generating-eval-seed-data/tests/evals/generating-eval-seed-data-apex-callout/seed-data/classes/QueueableWithCalloutRecipes.cls
ysachdeva-sfdc 808127c03a
@W-22335628 add generating-eval-seed-data skill (#237)
* feat: add generating-eval-seed-data skill

New skill that generates minimal seed-data stubs (custom fields, objects,
Apex class stubs) for evaluation datasets in the afv-library. Adapted from
the adk-eval-seed-data-generator with afv-library conventions and all
PR #194 review feedback addressed (scoped allowed-tools, no hardcoded
paths, progressive disclosure, skills referenced by name).

* fix: replace stub eval data with real adk-core datasets

Replace fabricated eval stubs with actual gold files and seed-data from
adk-core: payment_overdue (formula field), AssetFedexValidationRule
(validation rule with lookup deps), QueueableWithCalloutRecipes (Apex
with class dependencies).

* fix: remove related-skills from generating-eval-seed-data frontmatter

* fix: use detailed allowed-tools command signatures

* fix: scope allowed-tools to sf project deploy start only

* fix: change stage from Draft to Pilot
2026-05-05 13:13:46 +05:30

71 lines
2.3 KiB
OpenEdge ABL

/**
* @description Demmonstrates the use of the Queueable interface to make
* callouts. The methods in this class are called by the system at run time.
* To enqueue this job and see it's results, use `System.enqueueJob(new QueueableWithCalloutRecipes());`
*
* More on the Queable interface:
* https://sfdc.co/queueable-apex
*
* @group Async Apex Recipes
* @see RestClient
*/
public with sharing class QueueableWithCalloutRecipes implements Queueable, Database.AllowsCallouts {
// This allows us to cause a DML failure in execute batch, enabling testing.
@testVisible
private static Boolean throwError = false;
@testVisible
private static Boolean circuitBreakerThrown = false;
/**
* @description Internal custom exception class
*/
public class QueueableWithCalloutRecipesException extends Exception {
}
/**
* @description This is the only required method to implement Queueable.
* Queueable classes that also implement Database.allowsCallouts can make
* HTTP requests to external services. In this recipe we make a GET request
* to developer.salesforce.com
* @param qc dependency injected by the system
* @example
* ```
* System.enqueueJob(new QueueableWithCalloutRecipes());
* ```
*/
public static void execute(QueueableContext qc) {
HttpResponse response = RestClient.makeApiCall(
'GoogleBooksAPI',
RestClient.HttpVerb.GET,
'volumes?q=salesforce'
);
List<Account> accounts = [
SELECT Id
FROM Account
ORDER BY Id
LIMIT 1000
];
for (Account acct : accounts) {
acct.Description = String.valueOf(response.getStatusCode());
}
if (Test.isRunningTest() && throwError) {
accounts = (List<Account>) TestFactory.invalidateSObjectList(
accounts
);
}
try {
update accounts;
} catch (DmlException dmle) {
System.debug(
LoggingLevel.INFO,
'real life use cases should do something more than just logging the error: ' +
dmle.getMessage()
);
if (Test.isRunningTest()) {
QueueableWithCalloutRecipes.circuitBreakerThrown = true;
}
}
}
}