Test Contexts

How to initialize documents, process and document properties

In a Test Method you create and provide all the necessary information that is needed in the script. The Test Method creates the ScriptContext (see Concepts) and passes it to the script.

def context = new ProcessScriptContext(
        inputDocuments: [
                Document.fromText('''
                { 
                        "firstname" : "Walter", 
                        "lastname" : "Schmidt" 
                }''')
        ],
        dynProcPros: [ 
                DPP_Prop01: "2024",        
        ])
_testScript.run(context)

The Script Context Properties

The ScriptContext has the following properties:

public List<ProcessExecutionProperties> processCallChain;
public Map dynProcPros;
public Map procPros;
public final Map executionProperties;
  
// additional, ProcessScriptContext, only, properties
public List<Document> inputDocuments;
public final List<Document> outputDocuments;

See in the following chapter how to set and pass a content to a Process Script.

Documents and Dynamic Document Properties

IMPORTANT

In this section you will learn how to initialize properties in a Test class to use them in a script. If you want to know how to access (read/write) properties in a Boomi Script, read here: How to use Properties in a Boomi Script

Add input Documents from code (inline)

Use the Document.fromText() factory method to add any number of documents to the ProcessScriptContext.inputDocuments list.

Add input Documents from file

Use a TestFilesHelper _testFiles instance to support access to files in a specified sub-directory.

Use the Document.fromFile() factory method to add any number of documents to the ProcessScriptContext.inputDocuments list.

Mixed input documents

You can mix fromText and fromFile as you want. The input documents do not care where they are coming from.

Add input Documents with Dynamic Document Properties

Use the Document.fromText() factory method to add any number of documents to the ProcessScriptContext.inputDocuments list. Dynamic Dcoument Properties are represented as Groovy Map, which is a key : value list.

Dynamic Process Properties

Standard
Explicit assignment to the script context

Process Properties

Process Properties need a little bit more effort. You need to provide

  • the Process Property Component Id (b91d87a4-7e8b-4a98-8ea8-a85e32bb5677) and

  • the Process Property Value Key (fcc4749d-5135-4eaa-a9cf-1b2ddc1ad12)

Process Property Ids

Process Property Ids are system independent. This means, these IDs won't change even if you copy or export process properties to a different account. The Ids remain the same!

Standard Initialization

Last updated