# SDK Testing

This article will cover common and unique use cases that can be tested with SDK and through the Developer Console.

## S-Docs UserInput

```apex
Opportunity oppObj = [SELECT Id FROM Opportunity WHERE Id = 'BASE_RECORD_ID' LIMIT 1];
SDOC__SDTemplate__c template = [SELECT Id FROM SDOC__SDTemplate__c WHERE Name = 'TEMPLATE_NAME' LIMIT 1];

String generatedSDoc;
SDOC.GenerationOptions genOptions = new SDOC.GenerationOptions();

Map<String, String> userInput = new Map<String, String>{
    'Field_1' => 'Value 1',
    'Field_2' => 'Value 2'
        };
            genOptions.documentOptions = new SDOC.DocumentOptions(userInput);

generatedSDoc = SDOC.DocumentSDK.generateDocument(template.Id , oppObj.Id, genOptions);
```

## SDBatch: 2 templates, X records

```apex
Set<Id> templateList = new Set<Id>();

List<SDOC__SDTemplate__c> templates = [SELECT Id FROM SDOC__SDTemplate__c WHERE Name in ('Opportunity Template','Opportunity Template TWO')];

for (SDOC__SDTemplate__c template : templates) {
templateList.add(template.Id);   
}

List<Opportunity> opps = [SELECT Id FROM Opportunity where name like '%Airport%'];
List<Id> objs = new List<Id>();
for (Opportunity opp : opps) {
    objs.add(opp.Id);
}

Id asyncId = SDOC.DocumentSDK.generateDocsInBatch(objs, templateList, 2);
```

## CombineAll: 2 templates, X records

```apex
Set<Id> templateList = new Set<Id>();

List<SDOC__SDTemplate__c> templates = [SELECT Id FROM SDOC__SDTemplate__c WHERE Name in ('Opportunity Template','Opportunity Template TWO')];

for (SDOC__SDTemplate__c template : templates) {
templateList.add(template.Id);   
}

List<Opportunity> opps = [SELECT Id FROM Opportunity where name like '%Airport%'];
List<Id> objs = new List<Id>();
for (Opportunity opp : opps) {
    objs.add(opp.Id);
}
SDOC.CombinedDocumentHandler handler = new SDOC.CombinedDocumentHandler();
handler.fileName = 'YOUR_FILE_NAME'; // No extension
List<SDOC.BatchAction> handlers = new List<SDOC.BatchAction>{
    handler
};
Id asyncId = SDOC.DocumentSDK.generateDocsInBatch(objs, templateList, 2, handlers);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/developer-hub/document-generation-workflows/apex-and-programmatic-automation/software-development-kit/sdk-code-snippets-and-boilerplates/sdk-testing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
